summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2012-10-16 19:55:55 +0200
committerGrigori Goronzy <greg@blackbox>2012-10-16 19:55:55 +0200
commitc207000c7cdde335679b53a8cffc22bef61ffa45 (patch)
tree3ca434f41a77b0ec18d56e26010f8aaf0f7aa897
parent28353ecb2b17731ffecfb6d618484588ab79a4ec (diff)
downloadlibass-c207000c7cdde335679b53a8cffc22bef61ffa45.tar.bz2
libass-c207000c7cdde335679b53a8cffc22bef61ffa45.tar.xz
shaper: add hack to workaround grid-fitting
This complements commit 7af780, which didn't correctly apply the hack to the advance/position as calculated by the shaper.
-rw-r--r--libass/ass_render.c3
-rw-r--r--libass/ass_shaper.c14
2 files changed, 10 insertions, 7 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c
index 980dac3..9e111c2 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -1099,7 +1099,8 @@ get_outline_glyph(ASS_Renderer *priv, GlyphInfo *info)
key.u.drawing.text = strdup(drawing->text);
} else {
// arbitrary, not too small to prevent grid fitting rounding effects
- double ft_size = 256.0;
+ // XXX: this is a rather crude hack
+ const double ft_size = 256.0;
ass_face_set_size(info->font->faces[info->face_index], ft_size);
ass_font_set_transform(info->font,
info->scale_x * info->font_size / ft_size,
diff --git a/libass/ass_shaper.c b/libass/ass_shaper.c
index 937cadc..9434f43 100644
--- a/libass/ass_shaper.c
+++ b/libass/ass_shaper.c
@@ -391,7 +391,9 @@ static hb_font_t *get_hb_font(ASS_Shaper *shaper, GlyphInfo *info)
font->faces[info->face_index], NULL);
}
- ass_face_set_size(font->faces[info->face_index], info->font_size);
+ // XXX: this is a rather crude hack
+ const double ft_size = 256.0;
+ ass_face_set_size(font->faces[info->face_index], ft_size);
update_hb_size(hb_fonts[info->face_index], font->faces[info->face_index]);
// update hash key for cached metrics
@@ -421,7 +423,7 @@ static void shape_harfbuzz(ASS_Shaper *shaper, GlyphInfo *glyphs, size_t len)
hb_buffer_t *buf;
hb_font_t *font;
} runs[MAX_RUNS];
-
+ const double ft_size = 256.0;
for (i = 0; i < len && run < MAX_RUNS; i++, run++) {
// get length and level of the current run
@@ -474,10 +476,10 @@ static void shape_harfbuzz(ASS_Shaper *shaper, GlyphInfo *glyphs, size_t len)
// set position and advance
info->skip = 0;
info->glyph_index = glyph_info[j].codepoint;
- info->offset.x = pos[j].x_offset * info->scale_x;
- info->offset.y = -pos[j].y_offset * info->scale_y;
- info->advance.x = pos[j].x_advance * info->scale_x;
- info->advance.y = -pos[j].y_advance * info->scale_y;
+ info->offset.x = pos[j].x_offset * info->scale_x * (info->font_size / ft_size);
+ info->offset.y = -pos[j].y_offset * info->scale_y * (info->font_size / ft_size);
+ info->advance.x = pos[j].x_advance * info->scale_x * (info->font_size / ft_size);
+ info->advance.y = -pos[j].y_advance * info->scale_y * (info->font_size / ft_size);
// accumulate advance in the root glyph
root->cluster_advance.x += info->advance.x;