diff options
author | Thomas Goyne <tgoyne@gmail.com> | 2013-12-10 16:21:53 -0800 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-12-12 16:49:48 +0100 |
commit | de3f0e7572fb927d10857d4177ef58be2c9b3dbc (patch) | |
tree | 856bb5e70f5640def5a75d46e9574d3ccbcf4dbf /libass/ass_font.c | |
parent | bc738076f3a2162c50e74fe2bcc03b36a4b6c9a0 (diff) | |
download | libass-de3f0e7572fb927d10857d4177ef58be2c9b3dbc.tar.bz2 libass-de3f0e7572fb927d10857d4177ef58be2c9b3dbc.tar.xz |
Fix compilation with VC++ 2013
For whatever reason FT_Vector points[4] = { ... }; needs to come at the
beginning of a scope. Since that block was duplicated, just extract it
to a function.
This does not include buildsystem support, so actually compiling with
VC++ requires creating a project and supplying a config.h file.
Signed-off-by: wm4 <wm4@nowhere>
Diffstat (limited to 'libass/ass_font.c')
-rw-r--r-- | libass/ass_font.c | 79 |
1 files changed, 32 insertions, 47 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c index 00f3a81..dd275c1 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -295,6 +295,31 @@ void ass_font_get_asc_desc(ASS_Font *font, uint32_t ch, int *asc, *asc = *desc = 0; } +static void add_line(FT_Outline *ol, int bear, int advance, int dir, int pos, int size) { + FT_Vector points[4] = { + {.x = bear, .y = pos + size}, + {.x = advance, .y = pos + size}, + {.x = advance, .y = pos - size}, + {.x = bear, .y = pos - size}, + }; + + if (dir == FT_ORIENTATION_TRUETYPE) { + int i; + for (i = 0; i < 4; i++) { + ol->points[ol->n_points] = points[i]; + ol->tags[ol->n_points++] = 1; + } + } else { + int i; + for (i = 3; i >= 0; i--) { + ol->points[ol->n_points] = points[i]; + ol->tags[ol->n_points++] = 1; + } + } + + ol->contours[ol->n_contours++] = ol->n_points - 1; +} + /* * Strike a glyph with a horizontal line; it's possible to underline it * and/or strike through it. For the line's position and size, truetype @@ -334,64 +359,24 @@ static int ass_strike_outline_glyph(FT_Face face, ASS_Font *font, // Add points to the outline if (under && ps) { - int pos, size; - pos = FT_MulFix(ps->underlinePosition, y_scale * font->scale_y); - size = FT_MulFix(ps->underlineThickness, - y_scale * font->scale_y / 2); + int pos = FT_MulFix(ps->underlinePosition, y_scale * font->scale_y); + int size = FT_MulFix(ps->underlineThickness, + y_scale * font->scale_y / 2); if (pos > 0 || size <= 0) return 1; - FT_Vector points[4] = { - {.x = bear, .y = pos + size}, - {.x = advance, .y = pos + size}, - {.x = advance, .y = pos - size}, - {.x = bear, .y = pos - size}, - }; - - if (dir == FT_ORIENTATION_TRUETYPE) { - for (i = 0; i < 4; i++) { - ol->points[ol->n_points] = points[i]; - ol->tags[ol->n_points++] = 1; - } - } else { - for (i = 3; i >= 0; i--) { - ol->points[ol->n_points] = points[i]; - ol->tags[ol->n_points++] = 1; - } - } - - ol->contours[ol->n_contours++] = ol->n_points - 1; + add_line(ol, bear, advance, dir, pos, size); } if (through && os2) { - int pos, size; - pos = FT_MulFix(os2->yStrikeoutPosition, y_scale * font->scale_y); - size = FT_MulFix(os2->yStrikeoutSize, y_scale * font->scale_y / 2); + int pos = FT_MulFix(os2->yStrikeoutPosition, y_scale * font->scale_y); + int size = FT_MulFix(os2->yStrikeoutSize, y_scale * font->scale_y / 2); if (pos < 0 || size <= 0) return 1; - FT_Vector points[4] = { - {.x = bear, .y = pos + size}, - {.x = advance, .y = pos + size}, - {.x = advance, .y = pos - size}, - {.x = bear, .y = pos - size}, - }; - - if (dir == FT_ORIENTATION_TRUETYPE) { - for (i = 0; i < 4; i++) { - ol->points[ol->n_points] = points[i]; - ol->tags[ol->n_points++] = 1; - } - } else { - for (i = 3; i >= 0; i--) { - ol->points[ol->n_points] = points[i]; - ol->tags[ol->n_points++] = 1; - } - } - - ol->contours[ol->n_contours++] = ol->n_points - 1; + add_line(ol, bear, advance, dir, pos, size); } return 0; |