Debian Codegraph @

texk/xdvipsk/otflib/cff_dict.c

raw
1 /* This is xdvipsk, an eXtended version of dvips(k) by Tomas Rokicki.
2
3 Copyright (C) 2016 by VTeX Ltd (www.vtex.lt),
4 the xdvipsk project team - Sigitas Tolusis and Arunas Povilaitis.
5
6 Program original code copyright (C) 2007-2014 by Jin-Hwan Cho and
7 Shunsaku Hirata, the dvipdfmx project team.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 */
23
24 /*
25 * CFF Font Dictionary
26 *
27 * Adobe Technical Note #5176 "The Compact Font Format Specification"
28 */
29
30 #include <config.h>
31
32 #include <math.h>
33 #include <stdlib.h>
34 #include <errno.h>
35
36 #include "error.h"
37 #include "mem.h"
38
39 #ifndef CFF_DEBUG_STR
40 #define CFF_DEBUG_STR "CFF"
41 #define CFF_DEBUG 5
42 #endif
43
44 /* work_buffer for get_real() */
45 #include "mfileio.h"
46
47 #include "cff_types.h"
48 #include "cff_limits.h"
49
50 /* #include "cff_string.h" */
51 #include "cff_dict.h"
52 /* cff_update_dict requires this. */
53 #include "cff.h"
54
55 #define CFF_PARSE_OK 0
56 #define CFF_ERROR_PARSE_ERROR -1
57 #define CFF_ERROR_STACK_OVERFLOW -2
58 #define CFF_ERROR_STACK_UNDERFLOW -3
59 #define CFF_ERROR_STACK_RANGECHECK -4
60
61 #define DICT_ENTRY_MAX 16
62 cff_dict *cff_new_dict (void)
63 {
64 cff_dict *dict;
65
66 dict = NEW(1, cff_dict);
67 dict->max = DICT_ENTRY_MAX;
68 dict->count = 0;
69 dict->entries = NEW(dict->max, cff_dict_entry);
70
71 return dict;
72 }
73
74 void cff_release_dict (cff_dict *dict)
75 {
76 if (dict) {
77 if (dict->entries) {
78 int i;
79 for (i=0;i<dict->count;i++) {
80 if ((dict->entries)[i].values)
81 RELEASE((dict->entries)[i].values);
82 }
83 RELEASE(dict->entries);
84 }
85 RELEASE(dict);
86 }
87 }
88
89 /*
90 * Operand stack:
91 * only numbers are stored (as double)
92 *
93 * Operand types:
94 *
95 * number : double (integer or real)
96 * boolean: stored as a number
97 * SID : stored as a number
98 * array : array of numbers
99 * delta : array of numbers
100 */
101
102 #define CFF_DICT_STACK_LIMIT 64
103 static int stack_top = 0;
104 static double arg_stack[CFF_DICT_STACK_LIMIT];
105
106 /*
107 * CFF DICT encoding:
108 * TODO: default values
109 */
110
111 #define CFF_LAST_DICT_OP1 22
112 #define CFF_LAST_DICT_OP2 39
113 #define CFF_LAST_DICT_OP (CFF_LAST_DICT_OP1 + CFF_LAST_DICT_OP2)
114
115 static struct {
116 const char *opname;
117 int argtype;
118 } dict_operator[CFF_LAST_DICT_OP] = {
119 {"version", CFF_TYPE_SID},
120 {"Notice", CFF_TYPE_SID},
121 {"FullName", CFF_TYPE_SID},
122 {"FamilyName", CFF_TYPE_SID},
123 {"Weight", CFF_TYPE_SID},
124 {"FontBBox", CFF_TYPE_ARRAY},
125 {"BlueValues", CFF_TYPE_DELTA},
126 {"OtherBlues", CFF_TYPE_DELTA},
127 {"FamilyBlues", CFF_TYPE_DELTA},
128 {"FamilyOtherBlues", CFF_TYPE_DELTA},
129 {"StdHW", CFF_TYPE_NUMBER},
130 {"StdVW", CFF_TYPE_NUMBER},
131 {NULL, -1}, /* first byte of two-byte operator */
132 /* Top */
133 {"UniqueID", CFF_TYPE_NUMBER},
134 {"XUID", CFF_TYPE_ARRAY},
135 {"charset", CFF_TYPE_OFFSET},
136 {"Encoding", CFF_TYPE_OFFSET},
137 {"CharStrings", CFF_TYPE_OFFSET},
138 {"Private", CFF_TYPE_SZOFF}, /* two numbers (size and offset) */
139 /* Private */
140 {"Subrs", CFF_TYPE_OFFSET},
141 {"defaultWidthX", CFF_TYPE_NUMBER},
142 {"nominalWidthX", CFF_TYPE_NUMBER},
143 /* Operator 2 */
144 {"Copyright", CFF_TYPE_SID},
145 {"IsFixedPitch", CFF_TYPE_BOOLEAN},
146 {"ItalicAngle", CFF_TYPE_NUMBER},
147 {"UnderlinePosition", CFF_TYPE_NUMBER},
148 {"UnderlineThickness", CFF_TYPE_NUMBER},
149 {"PaintType", CFF_TYPE_NUMBER},
150 {"CharstringType", CFF_TYPE_NUMBER},
151 {"FontMatrix", CFF_TYPE_ARRAY},
152 {"StrokeWidth", CFF_TYPE_NUMBER},
153 {"BlueScale", CFF_TYPE_NUMBER},
154 {"BlueShift", CFF_TYPE_NUMBER},
155 {"BlueFuzz", CFF_TYPE_NUMBER},
156 {"StemSnapH", CFF_TYPE_DELTA},
157 {"StemSnapV", CFF_TYPE_DELTA},
158 {"ForceBold", CFF_TYPE_BOOLEAN},
159 {NULL, -1},
160 {NULL, -1},
161 {"LanguageGroup", CFF_TYPE_NUMBER},
162 {"ExpansionFactor", CFF_TYPE_NUMBER},
163 {"InitialRandomSeed", CFF_TYPE_NUMBER},
164 {"SyntheticBase", CFF_TYPE_NUMBER},
165 {"PostScript", CFF_TYPE_SID},
166 {"BaseFontName", CFF_TYPE_SID},
167 {"BaseFontBlend", CFF_TYPE_DELTA}, /* MMaster ? */
168 {NULL, -1},
169 {NULL, -1},
170 {NULL, -1},
171 {NULL, -1},
172 {NULL, -1},
173 {NULL, -1},
174 /* CID-Keyed font */
175 {"ROS", CFF_TYPE_ROS}, /* SID SID number */
176 {"CIDFontVersion", CFF_TYPE_NUMBER},
177 {"CIDFontRevision", CFF_TYPE_NUMBER},
178 {"CIDFontType", CFF_TYPE_NUMBER},
179 {"CIDCount", CFF_TYPE_NUMBER},
180 {"UIDBase", CFF_TYPE_NUMBER},
181 {"FDArray", CFF_TYPE_OFFSET},
182 {"FDSelect", CFF_TYPE_OFFSET},
183 {"FontName", CFF_TYPE_SID},
184 };
185
186 /* Parse DICT data */
187 static double get_integer (card8 **data, card8 *endptr, int *status)
188 {
189 long result = 0;
190 card8 b0, b1, b2;
191
192 b0 = *(*data)++;
193 if (b0 == 28 && *data < endptr - 2) { /* shortint */
194 b1 = *(*data)++;
195 b2 = *(*data)++;
196 result = b1*256+b2;
197 if (result > 0x7fffL)
198 result -= 0x10000L;
199 } else if (b0 == 29 && *data < endptr - 4) { /* longint */
200 int i;
201 result = *(*data)++;
202 if (result > 0x7f)
203 result -= 0x100;
204 for (i=0;i<3;i++) {
205 result = result*256+(**data);
206 *data += 1;
207 }
208 } else if (b0 >= 32 && b0 <= 246) { /* int (1) */
209 result = b0 - 139;
210 } else if (b0 >= 247 && b0 <= 250) { /* int (2) */
211 b1 = *(*data)++;
212 result = (b0-247)*256+b1+108;
213 } else if (b0 >= 251 && b0 <= 254) {
214 b1 = *(*data)++;
215 result = -(b0-251)*256-b1-108;
216 } else {
217 *status = CFF_ERROR_PARSE_ERROR;
218 }
219
220 return (double) result;
221 }
222
223 /* Simply uses strtod */
224 static double get_real(card8 **data, card8 *endptr, int *status)
225 {
226 double result = 0.0;
227 int nibble = 0, pos = 0;
228 int len = 0, fail = 0;
229
230 if (**data != 30 || *data >= endptr -1) {
231 *status = CFF_ERROR_PARSE_ERROR;
232 return 0.0;
233 }
234
235 *data += 1; /* skip first byte (30) */
236
237 pos = 0;
238 while ((! fail) && len < WORK_BUFFER_SIZE - 2 && *data < endptr) {
239 /* get nibble */
240 if (pos % 2) {
241 nibble = **data & 0x0f;
242 *data += 1;
243 } else {
244 nibble = (**data >> 4) & 0x0f;
245 }
246 if (nibble >= 0x00 && nibble <= 0x09) {
247 work_buffer[len++] = nibble + '0';
248 } else if (nibble == 0x0a) { /* . */
249 work_buffer[len++] = '.';
250 } else if (nibble == 0x0b || nibble == 0x0c) { /* E, E- */
251 work_buffer[len++] = 'e';
252 if (nibble == 0x0c)
253 work_buffer[len++] = '-';
254 } else if (nibble == 0x0e) { /* `-' */
255 work_buffer[len++] = '-';
256 } else if (nibble == 0x0d) { /* skip */
257 /* do nothing */
258 } else if (nibble == 0x0f) { /* end */
259 work_buffer[len++] = '\0';
260 if (((pos % 2) == 0) && (**data != 0xff)) {
261 fail = 1;
262 }
263 break;
264 } else { /* invalid */
265 fail = 1;
266 }
267 pos++;
268 }
269
270 /* returned values */
271 if (fail || nibble != 0x0f) {
272 *status = CFF_ERROR_PARSE_ERROR;
273 } else {
274 char *s;
275 result = strtod(work_buffer, &s);
276 if (*s != 0 || errno == ERANGE) {
277 *status = CFF_ERROR_PARSE_ERROR;
278 }
279 }
280
281 return result;
282 }
283
284 /* operators */
285 static void add_dict (cff_dict *dict,
286 card8 **data, card8 *endptr, int *status)
287 {
288 int id, argtype;
289
290 id = **data;
291 if (id == 0x0c) {
292 *data += 1;
293 if (*data >= endptr ||
294 (id = **data + CFF_LAST_DICT_OP1) >= CFF_LAST_DICT_OP) {
295 *status = CFF_ERROR_PARSE_ERROR;
296 return;
297 }
298 } else if (id >= CFF_LAST_DICT_OP1) {
299 *status = CFF_ERROR_PARSE_ERROR;
300 return;
301 }
302
303 argtype = dict_operator[id].argtype;
304 if (dict_operator[id].opname == NULL || argtype < 0) {
305 /* YuppySC-Regular.otf from OS X for instance uses op id 37, simply ignore
306 this dict instead of treat it as parsing error. */
307 return;
308 }
309
310 if (dict->count >= dict->max) {
311 dict->max += DICT_ENTRY_MAX;
312 dict->entries = RENEW(dict->entries, dict->max, cff_dict_entry);
313 }
314
315 (dict->entries)[dict->count].id = id;
316 (dict->entries)[dict->count].key = dict_operator[id].opname;
317 if (argtype == CFF_TYPE_NUMBER ||
318 argtype == CFF_TYPE_BOOLEAN ||
319 argtype == CFF_TYPE_SID ||
320 argtype == CFF_TYPE_OFFSET) {
321 /* check for underflow here, as exactly one operand is expected */
322 if (stack_top < 1) {
323 *status = CFF_ERROR_STACK_UNDERFLOW;
324 return;
325 }
326 stack_top--;
327 (dict->entries)[dict->count].count = 1;
328 (dict->entries)[dict->count].values = NEW(1, double);
329 (dict->entries)[dict->count].values[0] = arg_stack[stack_top];
330 dict->count += 1;
331 } else {
332 /* just ignore operator if there were no operands provided;
333 don't treat this as underflow (e.g. StemSnapV in TemporaLGCUni-Italic.otf) */
334 if (stack_top > 0)
335 {
336 (dict->entries)[dict->count].count = stack_top;
337 (dict->entries)[dict->count].values = NEW(stack_top, double);
338 while (stack_top > 0) {
339 stack_top--;
340 (dict->entries)[dict->count].values[stack_top] = arg_stack[stack_top];
341 }
342 dict->count += 1;
343 }
344 }
345
346 *data += 1;
347
348 return;
349 }
350
351 /*
352 * All operands are treated as number or array of numbers.
353 * Private: two numbers, size and offset
354 * ROS : three numbers, SID, SID, and a number
355 */
356 cff_dict *cff_dict_unpack (card8 *data, card8 *endptr)
357 {
358 cff_dict *dict;
359 int status = CFF_PARSE_OK;
360
361 stack_top = 0;
362
363 dict = cff_new_dict();
364 while (data < endptr && status == CFF_PARSE_OK) {
365 if (*data < 22) { /* operator */
366 add_dict(dict, &data, endptr, &status);
367 } else if (*data == 30) { /* real - First byte of a sequence (variable) */
368 if (stack_top < CFF_DICT_STACK_LIMIT) {
369 arg_stack[stack_top] = get_real(&data, endptr, &status);
370 stack_top++;
371 } else {
372 status = CFF_ERROR_STACK_OVERFLOW;
373 }
374 } else if (*data == 255 || (*data >= 22 && *data <= 27)) { /* reserved */
375 data++;
376 } else { /* everything else are integer */
377 if (stack_top < CFF_DICT_STACK_LIMIT) {
378 arg_stack[stack_top] = get_integer(&data, endptr, &status);
379 stack_top++;
380 } else {
381 status = CFF_ERROR_STACK_OVERFLOW;
382 }
383 }
384 }
385
386 if (status != CFF_PARSE_OK) {
387 ERROR("%s: Parsing CFF DICT failed. (error=%d)", CFF_DEBUG_STR, status);
388 } else if (stack_top != 0) {
389 WARN("%s: Garbage in CFF DICT data.", CFF_DEBUG_STR);
390 stack_top = 0;
391 }
392
393 return dict;
394 }
395
396 /* Pack DICT data */
397 static long pack_integer (card8 *dest, long destlen, long value)
398 {
399 long len = 0;
400
401 if (value >= -107 && value <= 107) {
402 if (destlen < 1)
403 ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
404 dest[0] = (value + 139) & 0xff;
405 len = 1;
406 } else if (value >= 108 && value <= 1131) {
407 if (destlen < 2)
408 ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
409 value = 0xf700u + value - 108;
410 dest[0] = (value >> 8) & 0xff;
411 dest[1] = value & 0xff;
412 len = 2;
413 } else if (value >= -1131 && value <= -108) {
414 if (destlen < 2)
415 ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
416 value = 0xfb00u - value - 108;
417 dest[0] = (value >> 8) & 0xff;
418 dest[1] = value & 0xff;
419 len = 2;
420 } else if (value >= -32768 && value <= 32767) { /* shortint */
421 if (destlen < 3)
422 ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
423 dest[0] = 28;
424 dest[1] = (value >> 8) & 0xff;
425 dest[2] = value & 0xff;
426 len = 3;
427 } else { /* longint */
428 if (destlen < 5)
429 ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
430 dest[0] = 29;
431 dest[1] = (value >> 24) & 0xff;
432 dest[2] = (value >> 16) & 0xff;
433 dest[3] = (value >> 8) & 0xff;
434 dest[4] = value & 0xff;
435 len = 5;
436 }
437
438 return len;
439 }
440
441 static long pack_real (card8 *dest, long destlen, double value)
442 {
443 int i = 0, pos = 2;
444 char buffer[32];
445
446 if (destlen < 2)
447 ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
448
449 dest[0] = 30;
450
451 if (value == 0.0) {
452 dest[1] = 0x0f;
453 return 2;
454 }
455
456 if (value < 0.0) {
457 dest[1] = 0xe0;
458 value *= -1.0;
459 pos++;
460 }
461
462 /* To avoid the problem with Mac OS X 10.4 Quartz,
463 * change the presion of the real numbers
464 * on June 27, 2007 for musix20.pfb */
465 sprintf(buffer, "%.13g", value);
466
467 for (i = 0; buffer[i] != '\0'; i++) {
468 unsigned char ch = 0;
469 if (buffer[i] == '.') {
470 ch = 0x0a;
471 } else if (buffer[i] >= '0' && buffer[i] <= '9') {
472 ch = buffer[i] - '0';
473 } else if (buffer[i] == 'e') {
474 ch = (buffer[++i] == '-' ? 0x0c : 0x0b);
475 } else {
476 ERROR("%s: Invalid character.", CFF_DEBUG_STR);
477 }
478
479 if (destlen < pos/2 + 1)
480 ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
481
482 if (pos % 2) {
483 dest[pos/2] += ch;
484 } else {
485 dest[pos/2] = (ch << 4);
486 }
487 pos++;
488 }
489
490 if (pos % 2) {
491 dest[pos/2] += 0x0f;
492 pos++;
493 } else {
494 if (destlen < pos/2 + 1)
495 ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
496 dest[pos/2] = 0xff;
497 pos += 2;
498 }
499
500 return pos/2;
501 }
502
503 static long cff_dict_put_number (double value,
504 card8 *dest, long destlen,
505 int type)
506 {
507 long len = 0;
508 double nearint;
509
510 nearint = floor(value+0.5);
511 /* set offset to longint */
512 if (type == CFF_TYPE_OFFSET) {
513 long lvalue;
514
515 lvalue = (long) value;
516 if (destlen < 5)
517 ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
518 dest[0] = 29;
519 dest[1] = (lvalue >> 24) & 0xff;
520 dest[2] = (lvalue >> 16) & 0xff;
521 dest[3] = (lvalue >> 8) & 0xff;
522 dest[4] = lvalue & 0xff;
523 len = 5;
524 } else if (value > CFF_INT_MAX || value < CFF_INT_MIN ||
525 (fabs(value - nearint) > 1.0e-5)) { /* real */
526 len = pack_real(dest, destlen, value);
527 } else { /* integer */
528 len = pack_integer(dest, destlen, (long) nearint);
529 }
530
531 return len;
532 }
533
534 static long
535 put_dict_entry (cff_dict_entry *de,
536 card8 *dest, long destlen)
537 {
538 long len = 0;
539 int i, type, id;
540
541 if (de->count > 0) {
542 id = de->id;
543 if (dict_operator[id].argtype == CFF_TYPE_OFFSET ||
544 dict_operator[id].argtype == CFF_TYPE_SZOFF) {
545 type = CFF_TYPE_OFFSET;
546 } else {
547 type = CFF_TYPE_NUMBER;
548 }
549 for (i = 0; i < de->count; i++) {
550 len += cff_dict_put_number(de->values[i],
551 dest+len,
552 destlen-len, type);
553 }
554 if (id >= 0 && id < CFF_LAST_DICT_OP1) {
555 if (len + 1 > destlen)
556 ERROR("%s: Buffer overflow.", CFF_DEBUG_STR);
557 dest[len++] = id;
558 } else if (id >= 0 && id < CFF_LAST_DICT_OP) {
559 if (len + 2 > destlen)
560 ERROR("in cff_dict_pack(): Buffer overflow");
561 dest[len++] = 12;
562 dest[len++] = id - CFF_LAST_DICT_OP1;
563 } else {
564 ERROR("%s: Invalid CFF DICT operator ID.", CFF_DEBUG_STR);
565 }
566 }
567
568 return len;
569 }
570
571 long cff_dict_pack (cff_dict *dict, card8 *dest, long destlen)
572 {
573 long len = 0;
574 int i;
575
576 for (i = 0; i < dict->count; i++) {
577 if (!strcmp(dict->entries[i].key, "ROS")) {
578 len += put_dict_entry(&dict->entries[i], dest, destlen);
579 break;
580 }
581 }
582 for (i = 0; i < dict->count; i++) {
583 if (strcmp(dict->entries[i].key, "ROS")) {
584 len += put_dict_entry(&dict->entries[i], dest+len, destlen-len);
585 }
586 }
587
588 return len;
589 }
590
591 void cff_dict_add (cff_dict *dict, const char *key, int count)
592 {
593 int id, i;
594
595 for (id=0;id<CFF_LAST_DICT_OP;id++) {
596 if (key && dict_operator[id].opname &&
597 strcmp(dict_operator[id].opname, key) == 0)
598 break;
599 }
600
601 if (id == CFF_LAST_DICT_OP)
602 ERROR("%s: Unknown CFF DICT operator.", CFF_DEBUG_STR);
603
604 for (i=0;i<dict->count;i++) {
605 if ((dict->entries)[i].id == id) {
606 if ((dict->entries)[i].count != count)
607 ERROR("%s: Inconsistent DICT argument number.", CFF_DEBUG_STR);
608 return;
609 }
610 }
611
612 if (dict->count + 1 >= dict->max) {
613 dict->max += 8;
614 dict->entries = RENEW(dict->entries, dict->max, cff_dict_entry);
615 }
616
617 (dict->entries)[dict->count].id = id;
618 (dict->entries)[dict->count].key = dict_operator[id].opname;
619 (dict->entries)[dict->count].count = count;
620 if (count > 0) {
621 (dict->entries)[dict->count].values = NEW(count, double);
622 memset((dict->entries)[dict->count].values,
623 0, sizeof(double)*count);
624 } else {
625 (dict->entries)[dict->count].values = NULL;
626 }
627 dict->count += 1;
628
629 return;
630 }
631
632 void cff_dict_remove (cff_dict *dict, const char *key)
633 {
634 int i;
635 for (i = 0; i < dict->count; i++) {
636 if (key && strcmp(key, (dict->entries)[i].key) == 0) {
637 (dict->entries)[i].count = 0;
638 if ((dict->entries)[i].values)
639 RELEASE((dict->entries)[i].values);
640 (dict->entries)[i].values = NULL;
641 }
642 }
643 }
644
645 int cff_dict_known (cff_dict *dict, const char *key)
646 {
647 int i;
648
649 for (i = 0; i < dict->count; i++) {
650 if (key && strcmp(key, (dict->entries)[i].key) == 0
651 && (dict->entries)[i].count > 0)
652 return 1;
653 }
654
655 return 0;
656 }
657
658 double cff_dict_get (cff_dict *dict, const char *key, int idx)
659 {
660 double value = 0.0;
661 int i;
662
663 ASSERT(key && dict);
664
665 for (i = 0; i < dict->count; i++) {
666 if (strcmp(key, (dict->entries)[i].key) == 0) {
667 if ((dict->entries)[i].count > idx)
668 value = (dict->entries)[i].values[idx];
669 else
670 ERROR("%s: Invalid index number.", CFF_DEBUG_STR);
671 break;
672 }
673 }
674
675 if (i == dict->count)
676 ERROR("%s: DICT entry \"%s\" not found.", CFF_DEBUG_STR, key);
677
678 return value;
679 }
680
681 void cff_dict_set (cff_dict *dict, const char *key, int idx, double value)
682 {
683 int i;
684
685 ASSERT(dict && key);
686
687 for (i = 0 ; i < dict->count; i++) {
688 if (strcmp(key, (dict->entries)[i].key) == 0) {
689 if ((dict->entries)[i].count > idx)
690 (dict->entries)[i].values[idx] = value;
691 else
692 ERROR("%s: Invalid index number.", CFF_DEBUG_STR);
693 break;
694 }
695 }
696
697 if (i == dict->count)
698 ERROR("%s: DICT entry \"%s\" not found.", CFF_DEBUG_STR, key);
699 }
700
701 void cff_dict_update (cff_dict *dict, cff_font *cff)
702 {
703 int i;
704
705 for (i = 0;i < dict->count; i++) {
706 if ((dict->entries)[i].count > 0) {
707 char *str;
708 int id;
709
710 id = (dict->entries)[i].id;
711 if (dict_operator[id].argtype == CFF_TYPE_SID) {
712 str = cff_get_string(cff, (dict->entries)[i].values[0]);
713 (dict->entries)[i].values[0] = cff_add_string(cff, str, 1);
714 RELEASE(str);
715 } else if (dict_operator[id].argtype == CFF_TYPE_ROS) {
716 str = cff_get_string(cff, (dict->entries)[i].values[0]);
717 (dict->entries)[i].values[0] = cff_add_string(cff, str, 1);
718 RELEASE(str);
719 str = cff_get_string(cff, (dict->entries)[i].values[1]);
720 (dict->entries)[i].values[1] = cff_add_string(cff, str, 1);
721 RELEASE(str);
722 }
723 }
724 }
725 }