diff options
author | Grigori Goronzy <greg@blackbox> | 2010-02-18 05:27:16 +0100 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2010-04-11 01:59:28 +0200 |
commit | 6e9557cd6c54c99f0d6d9c11096a2f38be47493a (patch) | |
tree | 9606f9ae65bfa5f8c69d5b1dc608ba01fe555600 /libass/ass_font.c | |
parent | 29167f37cf188f0b4dc6003ff6e733388112d183 (diff) | |
download | libass-6e9557cd6c54c99f0d6d9c11096a2f38be47493a.tar.bz2 libass-6e9557cd6c54c99f0d6d9c11096a2f38be47493a.tar.xz |
Basic @font support
Do not skip '@' at the start of a font name in styles; detect '@' at
font name start and set a new attribute in ASS_Font accordingly.
Rotate affected glyphs after loading and calculate a suitable advance.
Diffstat (limited to 'libass/ass_font.c')
-rw-r--r-- | libass/ass_font.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c index bb2b96a..109390f 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -188,6 +188,7 @@ ASS_Font *ass_font_new(void *font_cache, ASS_Library *library, font.desc.treat_family_as_pattern = desc->treat_family_as_pattern; font.desc.bold = desc->bold; font.desc.italic = desc->italic; + font.desc.vertical = desc->vertical; font.scale_x = font.scale_y = 1.; font.v.x = font.v.y = 0; @@ -207,11 +208,20 @@ ASS_Font *ass_font_new(void *font_cache, ASS_Library *library, void ass_font_set_transform(ASS_Font *font, double scale_x, double scale_y, FT_Vector *v) { - font->scale_x = scale_x; - font->scale_y = scale_y; - if (v) { - font->v.x = v->x; - font->v.y = v->y; + if (font->desc.vertical) { + font->scale_x = scale_y; + font->scale_y = scale_x; + if (v) { + font->v.x = v->y; + font->v.y = v->x; + } + } else { + font->scale_x = scale_x; + font->scale_y = scale_y; + if (v) { + font->v.x = v->x; + font->v.y = v->y; + } } update_transform(font); } @@ -414,6 +424,7 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font, FT_Glyph glyph; FT_Face face = 0; int flags = 0; + int vertical = font->desc.vertical; if (ch < 0x20) return 0; @@ -488,6 +499,15 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font, return 0; } + if (vertical) { + FT_Matrix m = { 0, double_to_d16(-1.0), double_to_d16(1.0), 0 }; + FT_Outline_Transform(&((FT_OutlineGlyph) glyph)->outline, &m); + FT_Outline_Translate(&((FT_OutlineGlyph) glyph)->outline, + face->glyph->metrics.vertAdvance * font->scale_y, + 0); + glyph->advance.x = face->glyph->linearVertAdvance * font->scale_y; + } + ass_strike_outline_glyph(face, font, glyph, deco & DECO_UNDERLINE, deco & DECO_STRIKETHROUGH); @@ -502,6 +522,9 @@ FT_Vector ass_font_get_kerning(ASS_Font *font, uint32_t c1, uint32_t c2) FT_Vector v = { 0, 0 }; int i; + if (font->desc.vertical) + return v; + for (i = 0; i < font->n_faces; ++i) { FT_Face face = font->faces[i]; int i1 = FT_Get_Char_Index(face, c1); |