summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2014-01-03 19:27:34 +0200
committerOleg Oshmyan <chortos@inbox.lv>2014-01-07 22:23:54 +0200
commit1636a551c7d7b05ea15c63a4ad041f2e8d8eb79f (patch)
tree3b593e77ca70acd366128ef0bc05b2c83e61a863
parent62df9e8345813a12834329ba6258af61e7ce0865 (diff)
downloadlibass-1636a551c7d7b05ea15c63a4ad041f2e8d8eb79f.tar.bz2
libass-1636a551c7d7b05ea15c63a4ad041f2e8d8eb79f.tar.xz
shaper: actually correctly handle @font advance
The code was confusing glyph index and Unicode codepoint. 256df617 attempted a fix but merely moved the wrong code. Fixes Google Code issue #94. Vertical ligatures are possibly still broken, but horizontal ligatures and non-ligatures are correct now.
-rw-r--r--libass/ass_shaper.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c
index 395f9c5..d5a970e 100644
--- a/libass/ass_shaper.c
+++ b/libass/ass_shaper.c
@@ -185,7 +185,7 @@ static void update_hb_size(hb_font_t *hb_font, FT_Face face)
GlyphMetricsHashValue *
get_cached_metrics(struct ass_shaper_metrics_data *metrics, FT_Face face,
- hb_codepoint_t glyph)
+ hb_codepoint_t unicode, hb_codepoint_t glyph)
{
GlyphMetricsHashValue *val;
@@ -204,7 +204,7 @@ get_cached_metrics(struct ass_shaper_metrics_data *metrics, FT_Face face,
// if @font rendering is enabled and the glyph should be rotated,
// make cached_h_advance pick up the right advance later
- if (metrics->vertical && glyph >= VERTICAL_LOWER_BOUND)
+ if (metrics->vertical && unicode >= VERTICAL_LOWER_BOUND)
new_val.metrics.horiAdvance = new_val.metrics.vertAdvance;
val = ass_cache_put(metrics->metrics_cache, &metrics->hash_key, &new_val);
@@ -218,12 +218,17 @@ get_glyph(hb_font_t *font, void *font_data, hb_codepoint_t unicode,
hb_codepoint_t variation, hb_codepoint_t *glyph, void *user_data)
{
FT_Face face = font_data;
+ struct ass_shaper_metrics_data *metrics_priv = user_data;
if (variation)
*glyph = FT_Face_GetCharVariantIndex(face, ass_font_index_magic(face, unicode), variation);
else
*glyph = FT_Get_Char_Index(face, ass_font_index_magic(face, unicode));
+ // rotate glyph advances for @fonts while we still know the Unicode codepoints
+ if (*glyph != 0)
+ get_cached_metrics(metrics_priv, face, unicode, glyph);
+
return *glyph != 0;
}
@@ -233,7 +238,7 @@ cached_h_advance(hb_font_t *font, void *font_data, hb_codepoint_t glyph,
{
FT_Face face = font_data;
struct ass_shaper_metrics_data *metrics_priv = user_data;
- GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, glyph);
+ GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, 0, glyph);
if (!metrics)
return 0;
@@ -247,7 +252,7 @@ cached_v_advance(hb_font_t *font, void *font_data, hb_codepoint_t glyph,
{
FT_Face face = font_data;
struct ass_shaper_metrics_data *metrics_priv = user_data;
- GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, glyph);
+ GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, 0, glyph);
if (!metrics)
return 0;
@@ -269,7 +274,7 @@ cached_v_origin(hb_font_t *font, void *font_data, hb_codepoint_t glyph,
{
FT_Face face = font_data;
struct ass_shaper_metrics_data *metrics_priv = user_data;
- GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, glyph);
+ GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, 0, glyph);
if (!metrics)
return 0;
@@ -306,7 +311,7 @@ cached_extents(hb_font_t *font, void *font_data, hb_codepoint_t glyph,
{
FT_Face face = font_data;
struct ass_shaper_metrics_data *metrics_priv = user_data;
- GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, glyph);
+ GlyphMetricsHashValue *metrics = get_cached_metrics(metrics_priv, face, 0, glyph);
if (!metrics)
return 0;