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
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);
}
}
+/*
+ * \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.
{
point->x = drawing->point_scale_x * point->x;
point->y = drawing->point_scale_y * -point->y;
+
+ update_cbox(drawing, point);
}
/*
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) {