[cff] Partially handle `load' and `store' ops in old CFF engine. Now all glyphs of MM CFFs like `ITCGaramondMM-It.otf' can be displayed. * src/cff/cffgload.c (cff_decoder_parse_charstrings) <cff_op_store, cff_op_load>: Partially implement it. * src/cff/cffparse.c (cff_parser_init): Add new parameter to pass the number of Multiple Master axes. Update all callers. (cff_parse_multiple_master): Get number of axes. (cff_parser_run) <opcode 31>: Updated. * src/cff/cffparse.h: Updated. (CFF_ParserRec): Add `num_axes' field. * src/cff/cffload.c: Updated. * src/cff/cfftypes.h (CFF_FontRecDictRec): Add `num_axes' field.
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
diff --git a/ChangeLog b/ChangeLog
index b884755..ceb6166 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
2016-02-15 Werner Lemberg <wl@gnu.org>
+ [cff] Partially handle `load' and `store' ops in old CFF engine.
+
+ Now all glyphs of MM CFFs like `ITCGaramondMM-It.otf' can be
+ displayed.
+
+ * src/cff/cffgload.c (cff_decoder_parse_charstrings) <cff_op_store,
+ cff_op_load>: Partially implement it.
+
+ * src/cff/cffparse.c (cff_parser_init): Add new parameter to pass
+ the number of Multiple Master axes.
+ Update all callers.
+ (cff_parse_multiple_master): Get number of axes.
+ (cff_parser_run) <opcode 31>: Updated.
+ * src/cff/cffparse.h: Updated.
+ (CFF_ParserRec): Add `num_axes' field.
+
+ * src/cff/cffload.c: Updated.
+
+ * src/cff/cfftypes.h (CFF_FontRecDictRec): Add `num_axes' field.
+
+2016-02-15 Werner Lemberg <wl@gnu.org>
+
[cff] Correctly trace SIDs that contain NULL bytes.
We need this to properly trace Multiple Master CFFs, which contain
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 2a2f60f..752c18e 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -919,6 +919,8 @@
decoder->cff->top_font.font_dict.charstring_type;
FT_UShort num_designs =
decoder->cff->top_font.font_dict.num_designs;
+ FT_UShort num_axes =
+ decoder->cff->top_font.font_dict.num_axes;
T2_Hints_Funcs hinter;
@@ -2248,6 +2250,10 @@
FT_TRACE4(( " put\n" ));
+ /* the Type2 specification before version 16-March-2000 */
+ /* didn't give a hard-coded size limit of the temporary */
+ /* storage array; instead, an argument of the */
+ /* `MultipleMaster' operator set the size */
if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
decoder->buildchar[idx] = val;
}
@@ -2272,16 +2278,43 @@
case cff_op_store:
/* this operator was removed from the Type2 specification */
/* in version 16-March-2000 */
- FT_TRACE4(( " store\n"));
- goto Unimplemented;
+ /* since we currently don't handle interpolation of multiple */
+ /* master fonts, this is a no-op */
+ FT_TRACE4(( " store\n"));
+ break;
case cff_op_load:
/* this operator was removed from the Type2 specification */
/* in version 16-March-2000 */
- FT_TRACE4(( " load\n" ));
+ {
+ FT_Int reg_idx = (FT_Int)args[0];
+ FT_Int idx = (FT_Int)args[1];
+ FT_Int count = (FT_Int)args[2];
- goto Unimplemented;
+
+ FT_TRACE4(( " load\n" ));
+
+ /* since we currently don't handle interpolation of multiple */
+ /* master fonts, we store a vector [1 0 0 ...] in the */
+ /* temporary storage array regardless of the Registry index */
+ if ( reg_idx >= 0 && reg_idx <= 2 &&
+ idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS &&
+ count >= 0 && count <= num_axes )
+ {
+ FT_Int end, i;
+
+
+ end = FT_MIN( idx + count, CFF_MAX_TRANS_ELEMENTS );
+
+ if ( idx < end )
+ decoder->buildchar[idx] = 1 << 16;
+
+ for ( i = idx + 1; i < end; i++ )
+ decoder->buildchar[i] = 0;
+ }
+ }
+ break;
case cff_op_blend:
/* this operator was removed from the Type2 specification */
@@ -2577,7 +2610,6 @@
break;
default:
- Unimplemented:
FT_ERROR(( "Unimplemented opcode: %d", ip[-1] ));
if ( ip[-1] == 12 )
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 920f10b..9d3846c 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1325,6 +1325,7 @@
CFF_CODE_TOPDICT,
&font->font_dict,
library,
+ 0,
0 );
/* set defaults */
@@ -1383,7 +1384,8 @@
CFF_CODE_PRIVATE,
priv,
library,
- top->num_designs );
+ top->num_designs,
+ top->num_axes );
if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) ||
FT_FRAME_ENTER( font->font_dict.private_size ) )
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 616023a..921c1a1 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -41,7 +41,8 @@
FT_UInt code,
void* object,
FT_Library library,
- FT_UShort num_designs )
+ FT_UShort num_designs,
+ FT_UShort num_axes )
{
FT_MEM_ZERO( parser, sizeof ( *parser ) );
@@ -50,6 +51,7 @@
parser->object = object;
parser->library = library;
parser->num_designs = num_designs;
+ parser->num_axes = num_axes;
}
@@ -682,7 +684,11 @@
else
{
dict->num_designs = (FT_UShort)num_designs;
+ dict->num_axes = (FT_UShort)( parser->top - parser->stack - 4 );
+
parser->num_designs = dict->num_designs;
+ parser->num_axes = dict->num_axes;
+
error = FT_Err_Ok;
}
}
@@ -1075,6 +1081,7 @@
FT_MEM_ZERO( &cff_rec, sizeof ( cff_rec ) );
cff_rec.top_font.font_dict.num_designs = parser->num_designs;
+ cff_rec.top_font.font_dict.num_axes = parser->num_axes;
decoder.cff = &cff_rec;
error = cff_decoder_parse_charstrings( &decoder,
diff --git a/src/cff/cffparse.h b/src/cff/cffparse.h
index 682ada0..a95970e 100644
--- a/src/cff/cffparse.h
+++ b/src/cff/cffparse.h
@@ -36,18 +36,19 @@ FT_BEGIN_HEADER
typedef struct CFF_ParserRec_
{
- FT_Library library;
- FT_Byte* start;
- FT_Byte* limit;
- FT_Byte* cursor;
+ FT_Library library;
+ FT_Byte* start;
+ FT_Byte* limit;
+ FT_Byte* cursor;
- FT_Byte* stack[CFF_MAX_STACK_DEPTH + 1];
- FT_Byte** top;
+ FT_Byte* stack[CFF_MAX_STACK_DEPTH + 1];
+ FT_Byte** top;
- FT_UInt object_code;
- void* object;
+ FT_UInt object_code;
+ void* object;
- FT_UShort num_designs; /* a copy of `CFF_FontRecDict->num_designs' */
+ FT_UShort num_designs; /* a copy of `CFF_FontRecDict->num_designs' */
+ FT_UShort num_axes; /* a copy of `CFF_FontRecDict->num_axes' */
} CFF_ParserRec, *CFF_Parser;
@@ -57,7 +58,8 @@ FT_BEGIN_HEADER
FT_UInt code,
void* object,
FT_Library library,
- FT_UShort num_designs );
+ FT_UShort num_designs,
+ FT_UShort num_axes );
FT_LOCAL( FT_Error )
cff_parser_run( CFF_Parser parser,
diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h
index b2320fd..4426c7e 100644
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -145,10 +145,11 @@ FT_BEGIN_HEADER
FT_ULong cid_fd_select_offset;
FT_UInt cid_font_name;
- /* the next field comes from the data of the deprecated */
- /* `MultipleMaster' operator; it is needed to parse the (also */
- /* deprecated) `blend' operator in Type 2 charstrings */
+ /* the next fields come from the data of the deprecated */
+ /* `MultipleMaster' operator; they are needed to parse the (also */
+ /* deprecated) `blend' operator in Type 2 charstrings */
FT_UShort num_designs;
+ FT_UShort num_axes;
} CFF_FontRecDictRec, *CFF_FontRecDict;