summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@chown.ath.cx>2013-07-06 01:14:39 +0200
committerGrigori Goronzy <greg@chown.ath.cx>2013-07-06 01:14:39 +0200
commit8ce53c411f40bea05c8942c488ff106b473b3c2f (patch)
tree7b17f5c0e811dd1d578008fc0fe49d2a7806493c
parent05cd0bca812be7c275896d852c99df9a3a33096b (diff)
downloadlibass-8ce53c411f40bea05c8942c488ff106b473b3c2f.tar.bz2
libass-8ce53c411f40bea05c8942c488ff106b473b3c2f.tar.xz
Fix OS/2 usWinDescent/usWinAscent for quirky fonts
Some fonts stuff a signed, negative value into this unsigned field. This usually causes very small and wrongly positioned rendering. Also handle usWinAscent similarly, just in case. Fixes issue #106.
-rw-r--r--libass/ass_font.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c
index 6840e2f..35a0a65 100644
--- a/libass/ass_font.c
+++ b/libass/ass_font.c
@@ -223,7 +223,8 @@ void ass_face_set_size(FT_Face face, double size)
// The idea was borrowed from asa (http://asa.diac24.net)
if (hori && os2) {
int hori_height = hori->Ascender - hori->Descender;
- int os2_height = os2->usWinAscent + os2->usWinDescent;
+ /* sometimes used for signed values despite unsigned in spec */
+ int os2_height = (short)os2->usWinAscent + (short)os2->usWinDescent;
if (hori_height && os2_height)
mscale = (double) hori_height / os2_height;
}
@@ -266,8 +267,8 @@ void ass_font_get_asc_desc(ASS_Font *font, uint32_t ch, int *asc,
if (FT_Get_Char_Index(face, ch)) {
int y_scale = face->size->metrics.y_scale;
if (os2) {
- *asc = FT_MulFix(os2->usWinAscent, y_scale);
- *desc = FT_MulFix(os2->usWinDescent, y_scale);
+ *asc = FT_MulFix((short)os2->usWinAscent, y_scale);
+ *desc = FT_MulFix((short)os2->usWinDescent, y_scale);
} else {
*asc = FT_MulFix(face->ascender, y_scale);
*desc = FT_MulFix(-face->descender, y_scale);