From de3f0e7572fb927d10857d4177ef58be2c9b3dbc Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 10 Dec 2013 16:21:53 -0800 Subject: 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 --- libass/ass_font.c | 79 ++++++++++++++++++++++--------------------------------- 1 file 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; -- cgit v1.2.3