diff options
Diffstat (limited to 'libass')
-rw-r--r-- | libass/ass_bitmap.c | 25 | ||||
-rw-r--r-- | libass/ass_bitmap.h | 12 | ||||
-rw-r--r-- | libass/ass_render.c | 16 |
3 files changed, 28 insertions, 25 deletions
diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c index 2d3f0d5d..d8b4063a 100644 --- a/libass/ass_bitmap.c +++ b/libass/ass_bitmap.c @@ -174,15 +174,14 @@ int check_glyph_area(ASS_Library *library, FT_Glyph glyph) return 0; } -static Bitmap *glyph_to_bitmap_internal(ASS_Library *library, - FT_Glyph glyph, int bord) +Bitmap *outline_to_bitmap(ASS_Library *library, FT_Library ftlib, + FT_Outline *outline, int bord) { Bitmap *bm; int w, h; int error; FT_BBox bbox; FT_Bitmap bitmap; - FT_Outline *outline = &((FT_OutlineGlyph)glyph)->outline; FT_Outline_Get_CBox(outline, &bbox); // move glyph to origin (0, 0) @@ -218,7 +217,7 @@ static Bitmap *glyph_to_bitmap_internal(ASS_Library *library, // render into target bitmap // XXX: this uses the FT_Library from the glyph. Instead a reference to the // FT_Library should be passed to this function (plus outline) - if ((error = FT_Outline_Get_Bitmap(glyph->library, outline, &bitmap))) { + if ((error = FT_Outline_Get_Bitmap(ftlib, outline, &bitmap))) { ass_msg(library, MSGL_WARN, "Failed to rasterize glyph: %d\n", error); ass_free_bitmap(bm); return NULL; @@ -461,11 +460,11 @@ static void be_blur(unsigned char *buf, int w, int h) } } -int glyph_to_bitmap(ASS_Library *library, ASS_SynthPriv *priv_blur, - FT_Glyph glyph, FT_Glyph outline_glyph, - Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s, - int be, double blur_radius, FT_Vector shadow_offset, - int border_style) +int outline_to_bitmap3(ASS_Library *library, ASS_SynthPriv *priv_blur, + FT_Library ftlib, FT_Outline *outline, FT_Outline *border, + Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s, + int be, double blur_radius, FT_Vector shadow_offset, + int border_style) { blur_radius *= 2; int bbord = be > 0 ? sqrt(2 * be) : 0; @@ -478,13 +477,13 @@ int glyph_to_bitmap(ASS_Library *library, ASS_SynthPriv *priv_blur, *bm_g = *bm_o = *bm_s = 0; - if (glyph) - *bm_g = glyph_to_bitmap_internal(library, glyph, bord); + if (outline) + *bm_g = outline_to_bitmap(library, ftlib, outline, bord); if (!*bm_g) return 1; - if (outline_glyph) { - *bm_o = glyph_to_bitmap_internal(library, outline_glyph, bord); + if (border) { + *bm_o = outline_to_bitmap(library, ftlib, border, bord); if (!*bm_o) { return 1; } diff --git a/libass/ass_bitmap.h b/libass/ass_bitmap.h index 287b6382..71c333ff 100644 --- a/libass/ass_bitmap.h +++ b/libass/ass_bitmap.h @@ -35,6 +35,8 @@ typedef struct { unsigned char *buffer; // w x h buffer } Bitmap; +Bitmap *outline_to_bitmap(ASS_Library *library, FT_Library ftlib, + FT_Outline *outline, int bord); /** * \brief perform glyph rendering * \param glyph original glyph @@ -44,11 +46,11 @@ typedef struct { * \param bm_g out: pointer to the bitmap of glyph shadow is returned here * \param be 1 = produces blurred bitmaps, 0 = normal bitmaps */ -int glyph_to_bitmap(ASS_Library *library, ASS_SynthPriv *priv_blur, - FT_Glyph glyph, FT_Glyph outline_glyph, - Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s, - int be, double blur_radius, FT_Vector shadow_offset, - int border_style); +int outline_to_bitmap3(ASS_Library *library, ASS_SynthPriv *priv_blur, + FT_Library ftlib, FT_Outline *outline, FT_Outline *border, + Bitmap **bm_g, Bitmap **bm_o, Bitmap **bm_s, + int be, double blur_radius, FT_Vector shadow_offset, + int border_style); void ass_free_bitmap(Bitmap *bm); int check_glyph_area(ASS_Library *library, FT_Glyph glyph); diff --git a/libass/ass_render.c b/libass/ass_render.c index 497d77e6..1d7f7a05 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -1264,13 +1264,15 @@ get_bitmap_glyph(ASS_Renderer *render_priv, GlyphInfo *info) FT_Outline_Translate(outl, key->advance.x, -key->advance.y); } // render glyph - error = glyph_to_bitmap(render_priv->library, - render_priv->synth_priv, - glyph, outline, - &info->bm, &info->bm_o, - &info->bm_s, info->be, - info->blur * render_priv->border_scale, - key->shadow_offset, key->border_style); + error = outline_to_bitmap3(render_priv->library, + render_priv->synth_priv, + render_priv->ftlibrary, + &((FT_OutlineGlyph)glyph)->outline, + &((FT_OutlineGlyph)outline)->outline, + &info->bm, &info->bm_o, + &info->bm_s, info->be, + info->blur * render_priv->border_scale, + key->shadow_offset, key->border_style); if (error) info->symbol = 0; |