diff options
author | Grigori Goronzy <greg@blackbox> | 2010-07-29 02:38:29 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2010-07-29 02:38:29 +0200 |
commit | 7152891c65fc50a809a20632160901bea41f13da (patch) | |
tree | cbe0856358b18c8ef102d33c8485bb0b61869abe /libass/ass_drawing.c | |
parent | 87c7e53c357375fe19dada6e2e3cc87464ae8ec5 (diff) | |
download | libass-7152891c65fc50a809a20632160901bea41f13da.tar.bz2 libass-7152891c65fc50a809a20632160901bea41f13da.tar.xz |
Fix drawing cbox calculation
Use extremes of all points fed to the parser, instead of only points
that are added to the outline.
Fixes a rendering problem reported on IRC and should fix Issue #7.
Diffstat (limited to 'libass/ass_drawing.c')
-rw-r--r-- | libass/ass_drawing.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libass/ass_drawing.c b/libass/ass_drawing.c index 4be03ba5..6bf9ee1f 100644 --- a/libass/ass_drawing.c +++ b/libass/ass_drawing.c @@ -112,7 +112,7 @@ static void drawing_prepare(ASS_Drawing *drawing) static void drawing_finish(ASS_Drawing *drawing, int raw_mode) { int i, offset; - FT_BBox bbox; + FT_BBox bbox = drawing->cbox; FT_Outline *ol = &drawing->glyph->outline; // Close the last contour @@ -137,7 +137,6 @@ static void drawing_finish(ASS_Drawing *drawing, int raw_mode) if (raw_mode) return; - FT_Outline_Get_CBox(&drawing->glyph->outline, &bbox); drawing->glyph->root.advance.x = d6_to_d16(bbox.xMax - bbox.xMin); drawing->desc = double_to_d6(-drawing->pbo * drawing->scale_y); @@ -256,6 +255,19 @@ static void drawing_free_tokens(ASS_DrawingToken *token) } /* + * \brief Update drawing cbox + */ +static inline void update_cbox(ASS_Drawing *drawing, FT_Vector *point) +{ + FT_BBox *box = &drawing->cbox; + + box->xMin = FFMIN(box->xMin, point->x); + box->xMax = FFMAX(box->xMax, point->x); + box->yMin = FFMIN(box->yMin, point->y); + box->yMax = FFMAX(box->yMax, point->y); +} + +/* * \brief Translate and scale a point coordinate according to baseline * offset and scale. */ @@ -263,6 +275,8 @@ static inline void translate_point(ASS_Drawing *drawing, FT_Vector *point) { point->x = drawing->point_scale_x * point->x; point->y = drawing->point_scale_y * -point->y; + + update_cbox(drawing, point); } /* @@ -369,6 +383,8 @@ ASS_Drawing *ass_drawing_new(void *fontconfig_priv, ASS_Font *font, drawing = calloc(1, sizeof(*drawing)); drawing->text = calloc(1, DRAWING_INITIAL_SIZE); drawing->size = DRAWING_INITIAL_SIZE; + drawing->cbox.xMin = drawing->cbox.yMin = INT_MAX; + drawing->cbox.xMax = drawing->cbox.yMax = INT_MIN; drawing->ftlibrary = lib; if (font) { |