1 /***************************************************************************/ |
1 /**************************************************************************** |
2 /* */ |
2 * |
3 /* ttcmap.c */ |
3 * ttcmap.c |
4 /* */ |
4 * |
5 /* TrueType character mapping table (cmap) support (body). */ |
5 * TrueType character mapping table (cmap) support (body). |
6 /* */ |
6 * |
7 /* Copyright 2002-2018 by */ |
7 * Copyright (C) 2002-2019 by |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
8 * David Turner, Robert Wilhelm, and Werner Lemberg. |
9 /* */ |
9 * |
10 /* This file is part of the FreeType project, and may only be used, */ |
10 * This file is part of the FreeType project, and may only be used, |
11 /* modified, and distributed under the terms of the FreeType project */ |
11 * modified, and distributed under the terms of the FreeType project |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute |
13 /* this file you indicate that you have read the license and */ |
13 * this file you indicate that you have read the license and |
14 /* understand and accept it fully. */ |
14 * understand and accept it fully. |
15 /* */ |
15 * |
16 /***************************************************************************/ |
16 */ |
17 |
17 |
18 |
18 |
19 #include <ft2build.h> |
19 #include <ft2build.h> |
20 #include FT_INTERNAL_DEBUG_H |
20 #include FT_INTERNAL_DEBUG_H |
21 |
21 |
25 #include FT_INTERNAL_STREAM_H |
25 #include FT_INTERNAL_STREAM_H |
26 #include FT_SERVICE_POSTSCRIPT_CMAPS_H |
26 #include FT_SERVICE_POSTSCRIPT_CMAPS_H |
27 #include "ttload.h" |
27 #include "ttload.h" |
28 #include "ttcmap.h" |
28 #include "ttcmap.h" |
29 #include "ttpost.h" |
29 #include "ttpost.h" |
30 #include "sfntpic.h" |
30 |
31 |
31 |
32 |
32 /************************************************************************** |
33 /*************************************************************************/ |
33 * |
34 /* */ |
34 * The macro FT_COMPONENT is used in trace mode. It is an implicit |
35 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
35 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log |
36 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
36 * messages during execution. |
37 /* messages during execution. */ |
37 */ |
38 /* */ |
|
39 #undef FT_COMPONENT |
38 #undef FT_COMPONENT |
40 #define FT_COMPONENT trace_ttcmap |
39 #define FT_COMPONENT ttcmap |
41 |
40 |
42 |
41 |
43 #define TT_PEEK_SHORT FT_PEEK_SHORT |
42 #define TT_PEEK_SHORT FT_PEEK_SHORT |
44 #define TT_PEEK_USHORT FT_PEEK_USHORT |
43 #define TT_PEEK_USHORT FT_PEEK_USHORT |
45 #define TT_PEEK_UINT24 FT_PEEK_UOFF3 |
44 #define TT_PEEK_UINT24 FT_PEEK_UOFF3 |
75 /***** FORMAT 0 *****/ |
74 /***** FORMAT 0 *****/ |
76 /***** *****/ |
75 /***** *****/ |
77 /*************************************************************************/ |
76 /*************************************************************************/ |
78 /*************************************************************************/ |
77 /*************************************************************************/ |
79 |
78 |
80 /*************************************************************************/ |
79 /************************************************************************** |
81 /* */ |
80 * |
82 /* TABLE OVERVIEW */ |
81 * TABLE OVERVIEW |
83 /* -------------- */ |
82 * -------------- |
84 /* */ |
83 * |
85 /* NAME OFFSET TYPE DESCRIPTION */ |
84 * NAME OFFSET TYPE DESCRIPTION |
86 /* */ |
85 * |
87 /* format 0 USHORT must be 0 */ |
86 * format 0 USHORT must be 0 |
88 /* length 2 USHORT table length in bytes */ |
87 * length 2 USHORT table length in bytes |
89 /* language 4 USHORT Mac language code */ |
88 * language 4 USHORT Mac language code |
90 /* glyph_ids 6 BYTE[256] array of glyph indices */ |
89 * glyph_ids 6 BYTE[256] array of glyph indices |
91 /* 262 */ |
90 * 262 |
92 /* */ |
91 */ |
93 |
92 |
94 #ifdef TT_CONFIG_CMAP_FORMAT_0 |
93 #ifdef TT_CONFIG_CMAP_FORMAT_0 |
95 |
94 |
96 FT_CALLBACK_DEF( FT_Error ) |
95 FT_CALLBACK_DEF( FT_Error ) |
97 tt_cmap0_validate( FT_Byte* table, |
96 tt_cmap0_validate( FT_Byte* table, |
236 /***** arguments. *****/ |
235 /***** arguments. *****/ |
237 /***** *****/ |
236 /***** *****/ |
238 /*************************************************************************/ |
237 /*************************************************************************/ |
239 /*************************************************************************/ |
238 /*************************************************************************/ |
240 |
239 |
241 /*************************************************************************/ |
240 /************************************************************************** |
242 /* */ |
241 * |
243 /* TABLE OVERVIEW */ |
242 * TABLE OVERVIEW |
244 /* -------------- */ |
243 * -------------- |
245 /* */ |
244 * |
246 /* NAME OFFSET TYPE DESCRIPTION */ |
245 * NAME OFFSET TYPE DESCRIPTION |
247 /* */ |
246 * |
248 /* format 0 USHORT must be 2 */ |
247 * format 0 USHORT must be 2 |
249 /* length 2 USHORT table length in bytes */ |
248 * length 2 USHORT table length in bytes |
250 /* language 4 USHORT Mac language code */ |
249 * language 4 USHORT Mac language code |
251 /* keys 6 USHORT[256] sub-header keys */ |
250 * keys 6 USHORT[256] sub-header keys |
252 /* subs 518 SUBHEAD[NSUBS] sub-headers array */ |
251 * subs 518 SUBHEAD[NSUBS] sub-headers array |
253 /* glyph_ids 518+NSUB*8 USHORT[] glyph ID array */ |
252 * glyph_ids 518+NSUB*8 USHORT[] glyph ID array |
254 /* */ |
253 * |
255 /* The `keys' table is used to map charcode high bytes to sub-headers. */ |
254 * The `keys' table is used to map charcode high bytes to sub-headers. |
256 /* The value of `NSUBS' is the number of sub-headers defined in the */ |
255 * The value of `NSUBS' is the number of sub-headers defined in the |
257 /* table and is computed by finding the maximum of the `keys' table. */ |
256 * table and is computed by finding the maximum of the `keys' table. |
258 /* */ |
257 * |
259 /* Note that for any `n', `keys[n]' is a byte offset within the `subs' */ |
258 * Note that for any `n', `keys[n]' is a byte offset within the `subs' |
260 /* table, i.e., it is the corresponding sub-header index multiplied */ |
259 * table, i.e., it is the corresponding sub-header index multiplied |
261 /* by 8. */ |
260 * by 8. |
262 /* */ |
261 * |
263 /* Each sub-header has the following format. */ |
262 * Each sub-header has the following format. |
264 /* */ |
263 * |
265 /* NAME OFFSET TYPE DESCRIPTION */ |
264 * NAME OFFSET TYPE DESCRIPTION |
266 /* */ |
265 * |
267 /* first 0 USHORT first valid low-byte */ |
266 * first 0 USHORT first valid low-byte |
268 /* count 2 USHORT number of valid low-bytes */ |
267 * count 2 USHORT number of valid low-bytes |
269 /* delta 4 SHORT see below */ |
268 * delta 4 SHORT see below |
270 /* offset 6 USHORT see below */ |
269 * offset 6 USHORT see below |
271 /* */ |
270 * |
272 /* A sub-header defines, for each high byte, the range of valid */ |
271 * A sub-header defines, for each high byte, the range of valid |
273 /* low bytes within the charmap. Note that the range defined by `first' */ |
272 * low bytes within the charmap. Note that the range defined by `first' |
274 /* and `count' must be completely included in the interval [0..255] */ |
273 * and `count' must be completely included in the interval [0..255] |
275 /* according to the specification. */ |
274 * according to the specification. |
276 /* */ |
275 * |
277 /* If a character code is contained within a given sub-header, then */ |
276 * If a character code is contained within a given sub-header, then |
278 /* mapping it to a glyph index is done as follows. */ |
277 * mapping it to a glyph index is done as follows. |
279 /* */ |
278 * |
280 /* * The value of `offset' is read. This is a _byte_ distance from the */ |
279 * - The value of `offset' is read. This is a _byte_ distance from the |
281 /* location of the `offset' field itself into a slice of the */ |
280 * location of the `offset' field itself into a slice of the |
282 /* `glyph_ids' table. Let's call it `slice' (it is a USHORT[], too). */ |
281 * `glyph_ids' table. Let's call it `slice' (it is a USHORT[], too). |
283 /* */ |
282 * |
284 /* * The value `slice[char.lo - first]' is read. If it is 0, there is */ |
283 * - The value `slice[char.lo - first]' is read. If it is 0, there is |
285 /* no glyph for the charcode. Otherwise, the value of `delta' is */ |
284 * no glyph for the charcode. Otherwise, the value of `delta' is |
286 /* added to it (modulo 65536) to form a new glyph index. */ |
285 * added to it (modulo 65536) to form a new glyph index. |
287 /* */ |
286 * |
288 /* It is up to the validation routine to check that all offsets fall */ |
287 * It is up to the validation routine to check that all offsets fall |
289 /* within the glyph IDs table (and not within the `subs' table itself or */ |
288 * within the glyph IDs table (and not within the `subs' table itself or |
290 /* outside of the CMap). */ |
289 * outside of the CMap). |
291 /* */ |
290 */ |
292 |
291 |
293 #ifdef TT_CONFIG_CMAP_FORMAT_2 |
292 #ifdef TT_CONFIG_CMAP_FORMAT_2 |
294 |
293 |
295 FT_CALLBACK_DEF( FT_Error ) |
294 FT_CALLBACK_DEF( FT_Error ) |
296 tt_cmap2_validate( FT_Byte* table, |
295 tt_cmap2_validate( FT_Byte* table, |
624 /***** FORMAT 4 *****/ |
623 /***** FORMAT 4 *****/ |
625 /***** *****/ |
624 /***** *****/ |
626 /*************************************************************************/ |
625 /*************************************************************************/ |
627 /*************************************************************************/ |
626 /*************************************************************************/ |
628 |
627 |
629 /*************************************************************************/ |
628 /************************************************************************** |
630 /* */ |
629 * |
631 /* TABLE OVERVIEW */ |
630 * TABLE OVERVIEW |
632 /* -------------- */ |
631 * -------------- |
633 /* */ |
632 * |
634 /* NAME OFFSET TYPE DESCRIPTION */ |
633 * NAME OFFSET TYPE DESCRIPTION |
635 /* */ |
634 * |
636 /* format 0 USHORT must be 4 */ |
635 * format 0 USHORT must be 4 |
637 /* length 2 USHORT table length */ |
636 * length 2 USHORT table length |
638 /* in bytes */ |
637 * in bytes |
639 /* language 4 USHORT Mac language code */ |
638 * language 4 USHORT Mac language code |
640 /* */ |
639 * |
641 /* segCountX2 6 USHORT 2*NUM_SEGS */ |
640 * segCountX2 6 USHORT 2*NUM_SEGS |
642 /* searchRange 8 USHORT 2*(1 << LOG_SEGS) */ |
641 * searchRange 8 USHORT 2*(1 << LOG_SEGS) |
643 /* entrySelector 10 USHORT LOG_SEGS */ |
642 * entrySelector 10 USHORT LOG_SEGS |
644 /* rangeShift 12 USHORT segCountX2 - */ |
643 * rangeShift 12 USHORT segCountX2 - |
645 /* searchRange */ |
644 * searchRange |
646 /* */ |
645 * |
647 /* endCount 14 USHORT[NUM_SEGS] end charcode for */ |
646 * endCount 14 USHORT[NUM_SEGS] end charcode for |
648 /* each segment; last */ |
647 * each segment; last |
649 /* is 0xFFFF */ |
648 * is 0xFFFF |
650 /* */ |
649 * |
651 /* pad 14+NUM_SEGS*2 USHORT padding */ |
650 * pad 14+NUM_SEGS*2 USHORT padding |
652 /* */ |
651 * |
653 /* startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for */ |
652 * startCount 16+NUM_SEGS*2 USHORT[NUM_SEGS] first charcode for |
654 /* each segment */ |
653 * each segment |
655 /* */ |
654 * |
656 /* idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each */ |
655 * idDelta 16+NUM_SEGS*4 SHORT[NUM_SEGS] delta for each |
657 /* segment */ |
656 * segment |
658 /* idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for */ |
657 * idOffset 16+NUM_SEGS*6 SHORT[NUM_SEGS] range offset for |
659 /* each segment; can be */ |
658 * each segment; can be |
660 /* zero */ |
659 * zero |
661 /* */ |
660 * |
662 /* glyphIds 16+NUM_SEGS*8 USHORT[] array of glyph ID */ |
661 * glyphIds 16+NUM_SEGS*8 USHORT[] array of glyph ID |
663 /* ranges */ |
662 * ranges |
664 /* */ |
663 * |
665 /* Character codes are modelled by a series of ordered (increasing) */ |
664 * Character codes are modelled by a series of ordered (increasing) |
666 /* intervals called segments. Each segment has start and end codes, */ |
665 * intervals called segments. Each segment has start and end codes, |
667 /* provided by the `startCount' and `endCount' arrays. Segments must */ |
666 * provided by the `startCount' and `endCount' arrays. Segments must |
668 /* not overlap, and the last segment should always contain the value */ |
667 * not overlap, and the last segment should always contain the value |
669 /* 0xFFFF for `endCount'. */ |
668 * 0xFFFF for `endCount'. |
670 /* */ |
669 * |
671 /* The fields `searchRange', `entrySelector' and `rangeShift' are better */ |
670 * The fields `searchRange', `entrySelector' and `rangeShift' are better |
672 /* ignored (they are traces of over-engineering in the TrueType */ |
671 * ignored (they are traces of over-engineering in the TrueType |
673 /* specification). */ |
672 * specification). |
674 /* */ |
673 * |
675 /* Each segment also has a signed `delta', as well as an optional offset */ |
674 * Each segment also has a signed `delta', as well as an optional offset |
676 /* within the `glyphIds' table. */ |
675 * within the `glyphIds' table. |
677 /* */ |
676 * |
678 /* If a segment's idOffset is 0, the glyph index corresponding to any */ |
677 * If a segment's idOffset is 0, the glyph index corresponding to any |
679 /* charcode within the segment is obtained by adding the value of */ |
678 * charcode within the segment is obtained by adding the value of |
680 /* `idDelta' directly to the charcode, modulo 65536. */ |
679 * `idDelta' directly to the charcode, modulo 65536. |
681 /* */ |
680 * |
682 /* Otherwise, a glyph index is taken from the glyph IDs sub-array for */ |
681 * Otherwise, a glyph index is taken from the glyph IDs sub-array for |
683 /* the segment, and the value of `idDelta' is added to it. */ |
682 * the segment, and the value of `idDelta' is added to it. |
684 /* */ |
683 * |
685 /* */ |
684 * |
686 /* Finally, note that a lot of fonts contain an invalid last segment, */ |
685 * Finally, note that a lot of fonts contain an invalid last segment, |
687 /* where `start' and `end' are correctly set to 0xFFFF but both `delta' */ |
686 * where `start' and `end' are correctly set to 0xFFFF but both `delta' |
688 /* and `offset' are incorrect (e.g., `opens___.ttf' which comes with */ |
687 * and `offset' are incorrect (e.g., `opens___.ttf' which comes with |
689 /* OpenOffice.org). We need special code to deal with them correctly. */ |
688 * OpenOffice.org). We need special code to deal with them correctly. |
690 /* */ |
689 */ |
691 |
690 |
692 #ifdef TT_CONFIG_CMAP_FORMAT_4 |
691 #ifdef TT_CONFIG_CMAP_FORMAT_4 |
693 |
692 |
694 typedef struct TT_CMap4Rec_ |
693 typedef struct TT_CMap4Rec_ |
695 { |
694 { |
1571 /***** FORMAT 6 *****/ |
1570 /***** FORMAT 6 *****/ |
1572 /***** *****/ |
1571 /***** *****/ |
1573 /*************************************************************************/ |
1572 /*************************************************************************/ |
1574 /*************************************************************************/ |
1573 /*************************************************************************/ |
1575 |
1574 |
1576 /*************************************************************************/ |
1575 /************************************************************************** |
1577 /* */ |
1576 * |
1578 /* TABLE OVERVIEW */ |
1577 * TABLE OVERVIEW |
1579 /* -------------- */ |
1578 * -------------- |
1580 /* */ |
1579 * |
1581 /* NAME OFFSET TYPE DESCRIPTION */ |
1580 * NAME OFFSET TYPE DESCRIPTION |
1582 /* */ |
1581 * |
1583 /* format 0 USHORT must be 6 */ |
1582 * format 0 USHORT must be 6 |
1584 /* length 2 USHORT table length in bytes */ |
1583 * length 2 USHORT table length in bytes |
1585 /* language 4 USHORT Mac language code */ |
1584 * language 4 USHORT Mac language code |
1586 /* */ |
1585 * |
1587 /* first 6 USHORT first segment code */ |
1586 * first 6 USHORT first segment code |
1588 /* count 8 USHORT segment size in chars */ |
1587 * count 8 USHORT segment size in chars |
1589 /* glyphIds 10 USHORT[count] glyph IDs */ |
1588 * glyphIds 10 USHORT[count] glyph IDs |
1590 /* */ |
1589 * |
1591 /* A very simplified segment mapping. */ |
1590 * A very simplified segment mapping. |
1592 /* */ |
1591 */ |
1593 |
1592 |
1594 #ifdef TT_CONFIG_CMAP_FORMAT_6 |
1593 #ifdef TT_CONFIG_CMAP_FORMAT_6 |
1595 |
1594 |
1596 FT_CALLBACK_DEF( FT_Error ) |
1595 FT_CALLBACK_DEF( FT_Error ) |
1597 tt_cmap6_validate( FT_Byte* table, |
1596 tt_cmap6_validate( FT_Byte* table, |
1766 /***** `is32[char_hi] != 0' and `is32[char_lo] != 0'. *****/ |
1765 /***** `is32[char_hi] != 0' and `is32[char_lo] != 0'. *****/ |
1767 /***** *****/ |
1766 /***** *****/ |
1768 /*************************************************************************/ |
1767 /*************************************************************************/ |
1769 /*************************************************************************/ |
1768 /*************************************************************************/ |
1770 |
1769 |
1771 /*************************************************************************/ |
1770 /************************************************************************** |
1772 /* */ |
1771 * |
1773 /* TABLE OVERVIEW */ |
1772 * TABLE OVERVIEW |
1774 /* -------------- */ |
1773 * -------------- |
1775 /* */ |
1774 * |
1776 /* NAME OFFSET TYPE DESCRIPTION */ |
1775 * NAME OFFSET TYPE DESCRIPTION |
1777 /* */ |
1776 * |
1778 /* format 0 USHORT must be 8 */ |
1777 * format 0 USHORT must be 8 |
1779 /* reserved 2 USHORT reserved */ |
1778 * reserved 2 USHORT reserved |
1780 /* length 4 ULONG length in bytes */ |
1779 * length 4 ULONG length in bytes |
1781 /* language 8 ULONG Mac language code */ |
1780 * language 8 ULONG Mac language code |
1782 /* is32 12 BYTE[8192] 32-bitness bitmap */ |
1781 * is32 12 BYTE[8192] 32-bitness bitmap |
1783 /* count 8204 ULONG number of groups */ |
1782 * count 8204 ULONG number of groups |
1784 /* */ |
1783 * |
1785 /* This header is followed by `count' groups of the following format: */ |
1784 * This header is followed by `count' groups of the following format: |
1786 /* */ |
1785 * |
1787 /* start 0 ULONG first charcode */ |
1786 * start 0 ULONG first charcode |
1788 /* end 4 ULONG last charcode */ |
1787 * end 4 ULONG last charcode |
1789 /* startId 8 ULONG start glyph ID for the group */ |
1788 * startId 8 ULONG start glyph ID for the group |
1790 /* */ |
1789 */ |
1791 |
1790 |
1792 #ifdef TT_CONFIG_CMAP_FORMAT_8 |
1791 #ifdef TT_CONFIG_CMAP_FORMAT_8 |
1793 |
1792 |
1794 FT_CALLBACK_DEF( FT_Error ) |
1793 FT_CALLBACK_DEF( FT_Error ) |
1795 tt_cmap8_validate( FT_Byte* table, |
1794 tt_cmap8_validate( FT_Byte* table, |
2035 /***** FORMAT 10 *****/ |
2034 /***** FORMAT 10 *****/ |
2036 /***** *****/ |
2035 /***** *****/ |
2037 /*************************************************************************/ |
2036 /*************************************************************************/ |
2038 /*************************************************************************/ |
2037 /*************************************************************************/ |
2039 |
2038 |
2040 /*************************************************************************/ |
2039 /************************************************************************** |
2041 /* */ |
2040 * |
2042 /* TABLE OVERVIEW */ |
2041 * TABLE OVERVIEW |
2043 /* -------------- */ |
2042 * -------------- |
2044 /* */ |
2043 * |
2045 /* NAME OFFSET TYPE DESCRIPTION */ |
2044 * NAME OFFSET TYPE DESCRIPTION |
2046 /* */ |
2045 * |
2047 /* format 0 USHORT must be 10 */ |
2046 * format 0 USHORT must be 10 |
2048 /* reserved 2 USHORT reserved */ |
2047 * reserved 2 USHORT reserved |
2049 /* length 4 ULONG length in bytes */ |
2048 * length 4 ULONG length in bytes |
2050 /* language 8 ULONG Mac language code */ |
2049 * language 8 ULONG Mac language code |
2051 /* */ |
2050 * |
2052 /* start 12 ULONG first char in range */ |
2051 * start 12 ULONG first char in range |
2053 /* count 16 ULONG number of chars in range */ |
2052 * count 16 ULONG number of chars in range |
2054 /* glyphIds 20 USHORT[count] glyph indices covered */ |
2053 * glyphIds 20 USHORT[count] glyph indices covered |
2055 /* */ |
2054 */ |
2056 |
2055 |
2057 #ifdef TT_CONFIG_CMAP_FORMAT_10 |
2056 #ifdef TT_CONFIG_CMAP_FORMAT_10 |
2058 |
2057 |
2059 FT_CALLBACK_DEF( FT_Error ) |
2058 FT_CALLBACK_DEF( FT_Error ) |
2060 tt_cmap10_validate( FT_Byte* table, |
2059 tt_cmap10_validate( FT_Byte* table, |
2207 /***** FORMAT 12 *****/ |
2206 /***** FORMAT 12 *****/ |
2208 /***** *****/ |
2207 /***** *****/ |
2209 /*************************************************************************/ |
2208 /*************************************************************************/ |
2210 /*************************************************************************/ |
2209 /*************************************************************************/ |
2211 |
2210 |
2212 /*************************************************************************/ |
2211 /************************************************************************** |
2213 /* */ |
2212 * |
2214 /* TABLE OVERVIEW */ |
2213 * TABLE OVERVIEW |
2215 /* -------------- */ |
2214 * -------------- |
2216 /* */ |
2215 * |
2217 /* NAME OFFSET TYPE DESCRIPTION */ |
2216 * NAME OFFSET TYPE DESCRIPTION |
2218 /* */ |
2217 * |
2219 /* format 0 USHORT must be 12 */ |
2218 * format 0 USHORT must be 12 |
2220 /* reserved 2 USHORT reserved */ |
2219 * reserved 2 USHORT reserved |
2221 /* length 4 ULONG length in bytes */ |
2220 * length 4 ULONG length in bytes |
2222 /* language 8 ULONG Mac language code */ |
2221 * language 8 ULONG Mac language code |
2223 /* count 12 ULONG number of groups */ |
2222 * count 12 ULONG number of groups |
2224 /* 16 */ |
2223 * 16 |
2225 /* */ |
2224 * |
2226 /* This header is followed by `count' groups of the following format: */ |
2225 * This header is followed by `count' groups of the following format: |
2227 /* */ |
2226 * |
2228 /* start 0 ULONG first charcode */ |
2227 * start 0 ULONG first charcode |
2229 /* end 4 ULONG last charcode */ |
2228 * end 4 ULONG last charcode |
2230 /* startId 8 ULONG start glyph ID for the group */ |
2229 * startId 8 ULONG start glyph ID for the group |
2231 /* */ |
2230 */ |
2232 |
2231 |
2233 #ifdef TT_CONFIG_CMAP_FORMAT_12 |
2232 #ifdef TT_CONFIG_CMAP_FORMAT_12 |
2234 |
2233 |
2235 typedef struct TT_CMap12Rec_ |
2234 typedef struct TT_CMap12Rec_ |
2236 { |
2235 { |
2563 /***** FORMAT 13 *****/ |
2562 /***** FORMAT 13 *****/ |
2564 /***** *****/ |
2563 /***** *****/ |
2565 /*************************************************************************/ |
2564 /*************************************************************************/ |
2566 /*************************************************************************/ |
2565 /*************************************************************************/ |
2567 |
2566 |
2568 /*************************************************************************/ |
2567 /************************************************************************** |
2569 /* */ |
2568 * |
2570 /* TABLE OVERVIEW */ |
2569 * TABLE OVERVIEW |
2571 /* -------------- */ |
2570 * -------------- |
2572 /* */ |
2571 * |
2573 /* NAME OFFSET TYPE DESCRIPTION */ |
2572 * NAME OFFSET TYPE DESCRIPTION |
2574 /* */ |
2573 * |
2575 /* format 0 USHORT must be 13 */ |
2574 * format 0 USHORT must be 13 |
2576 /* reserved 2 USHORT reserved */ |
2575 * reserved 2 USHORT reserved |
2577 /* length 4 ULONG length in bytes */ |
2576 * length 4 ULONG length in bytes |
2578 /* language 8 ULONG Mac language code */ |
2577 * language 8 ULONG Mac language code |
2579 /* count 12 ULONG number of groups */ |
2578 * count 12 ULONG number of groups |
2580 /* 16 */ |
2579 * 16 |
2581 /* */ |
2580 * |
2582 /* This header is followed by `count' groups of the following format: */ |
2581 * This header is followed by `count' groups of the following format: |
2583 /* */ |
2582 * |
2584 /* start 0 ULONG first charcode */ |
2583 * start 0 ULONG first charcode |
2585 /* end 4 ULONG last charcode */ |
2584 * end 4 ULONG last charcode |
2586 /* glyphId 8 ULONG glyph ID for the whole group */ |
2585 * glyphId 8 ULONG glyph ID for the whole group |
2587 /* */ |
2586 */ |
2588 |
2587 |
2589 #ifdef TT_CONFIG_CMAP_FORMAT_13 |
2588 #ifdef TT_CONFIG_CMAP_FORMAT_13 |
2590 |
2589 |
2591 typedef struct TT_CMap13Rec_ |
2590 typedef struct TT_CMap13Rec_ |
2592 { |
2591 { |
2889 /***** FORMAT 14 *****/ |
2888 /***** FORMAT 14 *****/ |
2890 /***** *****/ |
2889 /***** *****/ |
2891 /*************************************************************************/ |
2890 /*************************************************************************/ |
2892 /*************************************************************************/ |
2891 /*************************************************************************/ |
2893 |
2892 |
2894 /*************************************************************************/ |
2893 /************************************************************************** |
2895 /* */ |
2894 * |
2896 /* TABLE OVERVIEW */ |
2895 * TABLE OVERVIEW |
2897 /* -------------- */ |
2896 * -------------- |
2898 /* */ |
2897 * |
2899 /* NAME OFFSET TYPE DESCRIPTION */ |
2898 * NAME OFFSET TYPE DESCRIPTION |
2900 /* */ |
2899 * |
2901 /* format 0 USHORT must be 14 */ |
2900 * format 0 USHORT must be 14 |
2902 /* length 2 ULONG table length in bytes */ |
2901 * length 2 ULONG table length in bytes |
2903 /* numSelector 6 ULONG number of variation sel. records */ |
2902 * numSelector 6 ULONG number of variation sel. records |
2904 /* */ |
2903 * |
2905 /* Followed by numSelector records, each of which looks like */ |
2904 * Followed by numSelector records, each of which looks like |
2906 /* */ |
2905 * |
2907 /* varSelector 0 UINT24 Unicode codepoint of sel. */ |
2906 * varSelector 0 UINT24 Unicode codepoint of sel. |
2908 /* defaultOff 3 ULONG offset to a default UVS table */ |
2907 * defaultOff 3 ULONG offset to a default UVS table |
2909 /* describing any variants to be found in */ |
2908 * describing any variants to be found in |
2910 /* the normal Unicode subtable. */ |
2909 * the normal Unicode subtable. |
2911 /* nonDefOff 7 ULONG offset to a non-default UVS table */ |
2910 * nonDefOff 7 ULONG offset to a non-default UVS table |
2912 /* describing any variants not in the */ |
2911 * describing any variants not in the |
2913 /* standard cmap, with GIDs here */ |
2912 * standard cmap, with GIDs here |
2914 /* (either offset may be 0 NULL) */ |
2913 * (either offset may be 0 NULL) |
2915 /* */ |
2914 * |
2916 /* Selectors are sorted by code point. */ |
2915 * Selectors are sorted by code point. |
2917 /* */ |
2916 * |
2918 /* A default Unicode Variation Selector (UVS) subtable is just a list of */ |
2917 * A default Unicode Variation Selector (UVS) subtable is just a list of |
2919 /* ranges of code points which are to be found in the standard cmap. No */ |
2918 * ranges of code points which are to be found in the standard cmap. No |
2920 /* glyph IDs (GIDs) here. */ |
2919 * glyph IDs (GIDs) here. |
2921 /* */ |
2920 * |
2922 /* numRanges 0 ULONG number of ranges following */ |
2921 * numRanges 0 ULONG number of ranges following |
2923 /* */ |
2922 * |
2924 /* A range looks like */ |
2923 * A range looks like |
2925 /* */ |
2924 * |
2926 /* uniStart 0 UINT24 code point of the first character in */ |
2925 * uniStart 0 UINT24 code point of the first character in |
2927 /* this range */ |
2926 * this range |
2928 /* additionalCnt 3 UBYTE count of additional characters in this */ |
2927 * additionalCnt 3 UBYTE count of additional characters in this |
2929 /* range (zero means a range of a single */ |
2928 * range (zero means a range of a single |
2930 /* character) */ |
2929 * character) |
2931 /* */ |
2930 * |
2932 /* Ranges are sorted by `uniStart'. */ |
2931 * Ranges are sorted by `uniStart'. |
2933 /* */ |
2932 * |
2934 /* A non-default Unicode Variation Selector (UVS) subtable is a list of */ |
2933 * A non-default Unicode Variation Selector (UVS) subtable is a list of |
2935 /* mappings from codepoint to GID. */ |
2934 * mappings from codepoint to GID. |
2936 /* */ |
2935 * |
2937 /* numMappings 0 ULONG number of mappings */ |
2936 * numMappings 0 ULONG number of mappings |
2938 /* */ |
2937 * |
2939 /* A range looks like */ |
2938 * A range looks like |
2940 /* */ |
2939 * |
2941 /* uniStart 0 UINT24 code point of the first character in */ |
2940 * uniStart 0 UINT24 code point of the first character in |
2942 /* this range */ |
2941 * this range |
2943 /* GID 3 USHORT and its GID */ |
2942 * GID 3 USHORT and its GID |
2944 /* */ |
2943 * |
2945 /* Ranges are sorted by `uniStart'. */ |
2944 * Ranges are sorted by `uniStart'. |
|
2945 */ |
2946 |
2946 |
2947 #ifdef TT_CONFIG_CMAP_FORMAT_14 |
2947 #ifdef TT_CONFIG_CMAP_FORMAT_14 |
2948 |
2948 |
2949 typedef struct TT_CMap14Rec_ |
2949 typedef struct TT_CMap14Rec_ |
2950 { |
2950 { |
3747 (TT_CMap_Info_GetFunc)NULL /* get_cmap_info */ |
3750 (TT_CMap_Info_GetFunc)NULL /* get_cmap_info */ |
3748 ) |
3751 ) |
3749 |
3752 |
3750 #endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ |
3753 #endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ |
3751 |
3754 |
3752 #ifndef FT_CONFIG_OPTION_PIC |
|
3753 |
3755 |
3754 static const TT_CMap_Class tt_cmap_classes[] = |
3756 static const TT_CMap_Class tt_cmap_classes[] = |
3755 { |
3757 { |
3756 #define TTCMAPCITEM( a ) &a, |
3758 #define TTCMAPCITEM( a ) &a, |
3757 #include "ttcmapc.h" |
3759 #include "ttcmapc.h" |
3758 NULL, |
3760 NULL, |
3759 }; |
3761 }; |
3760 |
|
3761 #else /*FT_CONFIG_OPTION_PIC*/ |
|
3762 |
|
3763 void |
|
3764 FT_Destroy_Class_tt_cmap_classes( FT_Library library, |
|
3765 TT_CMap_Class* clazz ) |
|
3766 { |
|
3767 FT_Memory memory = library->memory; |
|
3768 |
|
3769 |
|
3770 if ( clazz ) |
|
3771 FT_FREE( clazz ); |
|
3772 } |
|
3773 |
|
3774 |
|
3775 FT_Error |
|
3776 FT_Create_Class_tt_cmap_classes( FT_Library library, |
|
3777 TT_CMap_Class** output_class ) |
|
3778 { |
|
3779 TT_CMap_Class* clazz = NULL; |
|
3780 TT_CMap_ClassRec* recs; |
|
3781 FT_Error error; |
|
3782 FT_Memory memory = library->memory; |
|
3783 |
|
3784 int i = 0; |
|
3785 |
|
3786 |
|
3787 #define TTCMAPCITEM( a ) i++; |
|
3788 #include "ttcmapc.h" |
|
3789 |
|
3790 /* allocate enough space for both the pointers */ |
|
3791 /* plus terminator and the class instances */ |
|
3792 if ( FT_ALLOC( clazz, sizeof ( *clazz ) * ( i + 1 ) + |
|
3793 sizeof ( TT_CMap_ClassRec ) * i ) ) |
|
3794 return error; |
|
3795 |
|
3796 /* the location of the class instances follows the array of pointers */ |
|
3797 recs = (TT_CMap_ClassRec*)( (char*)clazz + |
|
3798 sizeof ( *clazz ) * ( i + 1 ) ); |
|
3799 i = 0; |
|
3800 |
|
3801 #undef TTCMAPCITEM |
|
3802 #define TTCMAPCITEM( a ) \ |
|
3803 FT_Init_Class_ ## a( &recs[i] ); \ |
|
3804 clazz[i] = &recs[i]; \ |
|
3805 i++; |
|
3806 #include "ttcmapc.h" |
|
3807 |
|
3808 clazz[i] = NULL; |
|
3809 |
|
3810 *output_class = clazz; |
|
3811 return FT_Err_Ok; |
|
3812 } |
|
3813 |
|
3814 #endif /*FT_CONFIG_OPTION_PIC*/ |
|
3815 |
3762 |
3816 |
3763 |
3817 /* parse the `cmap' table and build the corresponding TT_CMap objects */ |
3764 /* parse the `cmap' table and build the corresponding TT_CMap objects */ |
3818 /* in the current face */ |
3765 /* in the current face */ |
3819 /* */ |
3766 /* */ |