From 353287746137a7eb34e425fd214b83b204f7ce0a Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Tue, 4 Nov 2025 19:21:49 -0500 Subject: [PATCH] [cff,cid,type1,type42] Fix up `PS_FontInfo`. The italic angle is commonly specified in fractional degrees in Type 1 fonts and its derivatives. This change clarifies and fixes these values. Note that CFF fonts has always reported them as such, but truncated the underline position and thickness. Fixes #1367. * include/freetype/t1tables.h (PS_FontInfoRec): Use FT_Fixed for italic_angle. * src/cid/cidtoken.h, src/type1/t1tokens.h, src/type42/t42parse.c: Modify the italic_angle token. * src/cff/cffdrivr.c (cff_ps_get_font_info): Fix the underline position and thickness. * docs/CHANGES: Note this change. --- docs/CHANGES | 12 ++++++++++++ include/freetype/t1tables.h | 2 +- src/cff/cffdrivr.c | 6 ++++-- src/cid/cidtoken.h | 2 +- src/type1/t1tokens.h | 2 +- src/type42/t42parse.c | 2 +- 6 files changed, 20 insertions(+), 6 deletions(-) diff --git a/docs/CHANGES b/docs/CHANGES index 056f5edbf..a3e51a8b5 100644 --- a/docs/CHANGES +++ b/docs/CHANGES @@ -1,3 +1,15 @@ +CHANGES BETWEEN 2.14.1 and 2.14.2 (2025-Mmm-DD) + + I. IMPORTANT BUG FIXES + + - The italic angle in `PS_FontInfo` is now stored as a fixed-point + value in degrees for all Type 1 fonts and their derivatives, + consistent with CFF fonts and common practices. The broken + underline position and thickness values are fixed for CFF fonts. + + +====================================================================== + CHANGES BETWEEN 2.14.0 and 2.14.1 (2025-Sep-11) I. IMPORTANT BUG FIXES diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h index fc3c1706d..0640e925b 100644 --- a/include/freetype/t1tables.h +++ b/include/freetype/t1tables.h @@ -92,7 +92,7 @@ FT_BEGIN_HEADER FT_String* full_name; FT_String* family_name; FT_String* weight; - FT_Long italic_angle; + FT_Fixed italic_angle; FT_Bool is_fixed_pitch; FT_Short underline_position; FT_UShort underline_thickness; diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c index 0079ddd19..909573271 100644 --- a/src/cff/cffdrivr.c +++ b/src/cff/cffdrivr.c @@ -456,8 +456,10 @@ dict->weight ); font_info->italic_angle = dict->italic_angle; font_info->is_fixed_pitch = dict->is_fixed_pitch; - font_info->underline_position = (FT_Short)dict->underline_position; - font_info->underline_thickness = (FT_UShort)dict->underline_thickness; + font_info->underline_position = + (FT_Short)( dict->underline_position >> 16 ); + font_info->underline_thickness = + (FT_UShort)( dict->underline_thickness >> 16 ); cff->font_info = font_info; } diff --git a/src/cid/cidtoken.h b/src/cid/cidtoken.h index 25ba74fed..d40ebfab8 100644 --- a/src/cid/cidtoken.h +++ b/src/cid/cidtoken.h @@ -47,7 +47,7 @@ T1_FIELD_STRING( "FullName", full_name, 0 ) T1_FIELD_STRING( "FamilyName", family_name, 0 ) T1_FIELD_STRING( "Weight", weight, 0 ) - T1_FIELD_NUM ( "ItalicAngle", italic_angle, 0 ) + T1_FIELD_FIXED ( "ItalicAngle", italic_angle, 0 ) T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, 0 ) T1_FIELD_NUM ( "UnderlinePosition", underline_position, 0 ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, 0 ) diff --git a/src/type1/t1tokens.h b/src/type1/t1tokens.h index c3736cd42..a526406a4 100644 --- a/src/type1/t1tokens.h +++ b/src/type1/t1tokens.h @@ -33,7 +33,7 @@ T1_FIELD_DICT_FONTDICT ) /* we use pointers to detect modifications made by synthetic fonts */ - T1_FIELD_NUM ( "ItalicAngle", italic_angle, + T1_FIELD_FIXED ( "ItalicAngle", italic_angle, T1_FIELD_DICT_FONTDICT ) T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, T1_FIELD_DICT_FONTDICT ) diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c index 5beab0b5a..55a29fecb 100644 --- a/src/type42/t42parse.c +++ b/src/type42/t42parse.c @@ -65,7 +65,7 @@ T1_FIELD_STRING( "FullName", full_name, 0 ) T1_FIELD_STRING( "FamilyName", family_name, 0 ) T1_FIELD_STRING( "Weight", weight, 0 ) - T1_FIELD_NUM ( "ItalicAngle", italic_angle, 0 ) + T1_FIELD_FIXED ( "ItalicAngle", italic_angle, 0 ) T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch, 0 ) T1_FIELD_NUM ( "UnderlinePosition", underline_position, 0 ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, 0 )