In function parse_font_matrix, added heuristic to get units_per_EM from the font matrix. In parse_dict, deleted test to see if the FontInfo keyword has been seen. Deletion of this test allows fonts without FontInfo dictionaries to be parsed by the Type 1 driver. In T1_Open_Face, deleted empty subroutines array test to make sure fonts with no subroutines still are parsed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index f7133d4..53d2a4a 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -878,7 +878,9 @@
T1_ParserRec* parser = &loader->parser;
FT_Matrix* matrix = &face->type1.font_matrix;
FT_Vector* offset = &face->type1.font_offset;
+ FT_Face root = (FT_Face)&face->root;
FT_Fixed temp[6];
+ FT_Fixed temp_scale;
if ( matrix->xx || matrix->yx )
@@ -887,14 +889,21 @@
(void)T1_ToFixedArray( parser, 6, temp, 3 );
- /* we need to scale the values by 1.0/temp[3] */
- if ( temp[3] != 0x10000L )
+ temp_scale = ABS( temp[3] );
+
+ /* Set Units per EM based on FontMatrix values. We set the value to */
+ /* 1000 / temp_scale, because temp_scale was already multiplied by */
+ /* 1000 (in t1_tofixed, from psobjs.c). */
+ root->units_per_EM = FT_DivFix( 0x10000L, FT_DivFix( temp_scale, 1000 ) );
+
+ /* we need to scale the values by 1.0/temp_scale */
+ if ( temp_scale != 0x10000L )
{
- temp[0] = FT_DivFix( temp[0], temp[3] );
- temp[1] = FT_DivFix( temp[1], temp[3] );
- temp[2] = FT_DivFix( temp[2], temp[3] );
- temp[4] = FT_DivFix( temp[4], temp[3] );
- temp[5] = FT_DivFix( temp[5], temp[3] );
+ temp[0] = FT_DivFix( temp[0], temp_scale );
+ temp[1] = FT_DivFix( temp[1], temp_scale );
+ temp[2] = FT_DivFix( temp[2], temp_scale );
+ temp[4] = FT_DivFix( temp[4], temp_scale );
+ temp[5] = FT_DivFix( temp[5], temp_scale );
temp[3] = 0x10000L;
}
@@ -1461,12 +1470,6 @@
len = cur2 - cur;
if ( len > 0 && len < 22 )
{
- if ( !loader->fontdata )
- {
- if ( strncmp( (char*)cur, "FontInfo", 8 ) == 0 )
- loader->fontdata = 1;
- }
- else
{
/* now, compare the immediate name to the keyword table */
T1_Field* keyword = (T1_Field*)t1_keywords;
@@ -1594,10 +1597,13 @@
/* to the Type1 data */
type1->num_glyphs = loader.num_glyphs;
- if ( !loader.subrs.init )
+ if ( loader.subrs.init )
{
- FT_ERROR(( "T1_Open_Face: no subrs array in face!\n" ));
- error = T1_Err_Invalid_File_Format;
+ loader.subrs.init = 0;
+ type1->num_subrs = loader.num_subrs;
+ type1->subrs_block = loader.subrs.block;
+ type1->subrs = loader.subrs.elements;
+ type1->subrs_len = loader.subrs.lengths;
}
if ( !loader.charstrings.init )
@@ -1606,12 +1612,6 @@
error = T1_Err_Invalid_File_Format;
}
- loader.subrs.init = 0;
- type1->num_subrs = loader.num_subrs;
- type1->subrs_block = loader.subrs.block;
- type1->subrs = loader.subrs.elements;
- type1->subrs_len = loader.subrs.lengths;
-
loader.charstrings.init = 0;
type1->charstrings_block = loader.charstrings.block;
type1->charstrings = loader.charstrings.elements;