Skip to content

Commit

Permalink
Make changes needed for MSVC compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoyne committed Oct 9, 2013
1 parent 71ab600 commit a394599
Show file tree
Hide file tree
Showing 13 changed files with 332 additions and 107 deletions.
5 changes: 4 additions & 1 deletion libass/ass.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <inttypes.h>
#include <ctype.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#ifdef CONFIG_ICONV
#include <iconv.h>
#endif
Expand Down
9 changes: 6 additions & 3 deletions libass/ass_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,13 @@ int outline_to_bitmap3(ASS_Library *library, ASS_SynthPriv *priv_blur,
int be, double blur_radius, FT_Vector shadow_offset,
int border_style, int border_visible)
{
int bbord;
int gbord;
int bord;
blur_radius *= 2;
int bbord = be > 0 ? sqrt(2 * be) : 0;
int gbord = blur_radius > 0.0 ? blur_radius + 1 : 0;
int bord = FFMAX(bbord, gbord);
bbord = be > 0 ? sqrt(2 * be) : 0;
gbord = blur_radius > 0.0 ? blur_radius + 1 : 0;
bord = FFMAX(bbord, gbord);
if (bord == 0 && (shadow_offset.x || shadow_offset.y))
bord = 1;

Expand Down
18 changes: 10 additions & 8 deletions libass/ass_drawing.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,26 +248,28 @@ static void drawing_evaluate_curve(ASS_Drawing *drawing,
double cx3, cx2, cx1, cx0, cy3, cy2, cy1, cy0;
double t, h, max_accel, max_accel1, max_accel2;
FT_Vector cur = {0, 0};
int x0, x1, x2, x3;
int y0, y1, y2, y3;

cur = token->point;
translate_point(drawing, &cur);
int x0 = cur.x;
int y0 = cur.y;
x0 = cur.x;
y0 = cur.y;
token = token->next;
cur = token->point;
translate_point(drawing, &cur);
int x1 = cur.x;
int y1 = cur.y;
x1 = cur.x;
y1 = cur.y;
token = token->next;
cur = token->point;
translate_point(drawing, &cur);
int x2 = cur.x;
int y2 = cur.y;
x2 = cur.x;
y2 = cur.y;
token = token->next;
cur = token->point;
translate_point(drawing, &cur);
int x3 = cur.x;
int y3 = cur.y;
x3 = cur.x;
y3 = cur.y;

if (spline) {
// 1 [-1 +3 -3 +1]
Expand Down
74 changes: 42 additions & 32 deletions libass/ass_font.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,23 @@ 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);

FT_Vector points[4];

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},
};
points[0].x = bear;
points[0].y = pos + size;
points[1].x = advance;
points[1].y = pos + size;
points[2].x = advance;
points[2].y = pos - size;
points[3].x = bear;
points[3].y = pos - size;

if (dir == FT_ORIENTATION_TRUETYPE) {
for (i = 0; i < 4; i++) {
Expand All @@ -350,19 +353,21 @@ static int ass_strike_outline_glyph(FT_Face face, ASS_Font *font,
}

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);
FT_Vector points[4];

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},
};
points[0].x = bear;
points[0].y = pos + size;
points[1].x = advance;
points[1].y = pos + size;
points[2].x = advance;
points[2].y = pos - size;
points[3].x = bear;
points[3].y = pos - size;

if (dir == FT_ORIENTATION_TRUETYPE) {
for (i = 0; i < 4; i++) {
Expand Down Expand Up @@ -470,6 +475,7 @@ int ass_font_get_index(void *fcpriv, ASS_Font *font, uint32_t symbol,
index = FT_Get_Char_Index(face, symbol);
if (index == 0 && face->num_charmaps > 0) {
int i;
FT_CharMap cur = face->charmap;
ass_msg(font->library, MSGL_WARN,
"Glyph 0x%X not found, broken font? Trying all charmaps", symbol);
for (i = 0; i < face->num_charmaps; i++) {
Expand Down Expand Up @@ -562,15 +568,17 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
}

// Apply scaling and shift
FT_Matrix scale = { double_to_d16(font->scale_x), 0, 0,
double_to_d16(font->scale_y) };
FT_Outline *outl = &((FT_OutlineGlyph) glyph)->outline;
FT_Outline_Transform(outl, &scale);
FT_Outline_Translate(outl, font->v.x, font->v.y);
glyph->advance.x *= font->scale_x;

ass_strike_outline_glyph(face, font, glyph, deco & DECO_UNDERLINE,
deco & DECO_STRIKETHROUGH);
{
FT_Matrix scale = { double_to_d16(font->scale_x), 0, 0,
double_to_d16(font->scale_y) };
FT_Outline *outl = &((FT_OutlineGlyph) glyph)->outline;
FT_Outline_Transform(outl, &scale);
FT_Outline_Translate(outl, font->v.x, font->v.y);
glyph->advance.x *= font->scale_x;

ass_strike_outline_glyph(face, font, glyph, deco & DECO_UNDERLINE,
deco & DECO_STRIKETHROUGH);
}

return glyph;
}
Expand Down Expand Up @@ -622,9 +630,9 @@ void ass_font_free(ASS_Font *font)
static void
get_contour_cbox(FT_BBox *box, FT_Vector *points, int start, int end)
{
int i;
box->xMin = box->yMin = INT_MAX;
box->xMax = box->yMax = INT_MIN;
int i;

for (i = start; i <= end; i++) {
box->xMin = (points[i].x < box->xMin) ? points[i].x : box->xMin;
Expand Down Expand Up @@ -695,9 +703,10 @@ void fix_freetype_stroker(FT_Outline *outline, int border_x, int border_y)
// or contained in another contour
end = -1;
for (i = 0; i < nc; i++) {
int dir;
start = end + 1;
end = outline->contours[i];
int dir = get_contour_direction(outline->points, start, end);
dir = get_contour_direction(outline->points, start, end);
valid_cont[i] = 1;
if (dir == inside_direction) {
for (j = 0; j < nc; j++) {
Expand Down Expand Up @@ -725,9 +734,10 @@ void fix_freetype_stroker(FT_Outline *outline, int border_x, int border_y)
check_inside:
if (dir == inside_direction) {
FT_BBox box;
int width, height;
get_contour_cbox(&box, outline->points, start, end);
int width = box.xMax - box.xMin;
int height = box.yMax - box.yMin;
width = box.xMax - box.xMin;
height = box.yMax - box.yMin;
if (width < border_x * 2 || height < border_y * 2) {
valid_cont[i] = 0;
modified = 1;
Expand Down

0 comments on commit a394599

Please sign in to comment.