Debian Codegraph @

texk/web2c/mfluadir/otfcc/lib/font/caryll-font.c

raw
1 #include "support/util.h"
2 #include "otfcc/font.h"
3 #include "table/all.h"
4 #include "otfcc/sfnt-builder.h"
5 #include "consolidate/consolidate.h"
6
7 #define OTFCC_CHR(a,b,c,d) ( ((a)<<24) | ((b)<<16) | ((c)<<8) | (d) )
8
9 static void *createFontTable(otfcc_Font *font, const uint32_t tag) {
10 switch (tag) {
11 case OTFCC_CHR('n','a','m','e'):
12 return table_iName.create();
13 case OTFCC_CHR('G','S','U','B'):
14 case OTFCC_CHR('G','P','O','S'):
15 return table_iOTL.create();
16 default:
17 return NULL;
18 }
19 }
20
21 static void deleteFontTable(otfcc_Font *font, const uint32_t tag) {
22 switch (tag) {
23 case OTFCC_CHR('h','e','a','d'):
24 if (font->head) DELETE(table_iHead.free, font->head);
25 return;
26 case OTFCC_CHR('h','h','e','a'):
27 if (font->hhea) DELETE(table_iHhea.free, font->hhea);
28 return;
29 case OTFCC_CHR('m','a','x','p'):
30 if (font->maxp) DELETE(table_iMaxp.free, font->maxp);
31 return;
32 case OTFCC_CHR('O','S','_','2'):
33 case OTFCC_CHR('O','S','/','2'):
34 if (font->OS_2) DELETE(table_iOS_2.free, font->OS_2);
35 return;
36 case OTFCC_CHR('n','a','m','e'):
37 if (font->name) DELETE(table_iName.free, font->name);
38 return;
39 case OTFCC_CHR('m','e','t','a'):
40 if (font->meta) DELETE(table_iMeta.free, font->meta);
41 return;
42 case OTFCC_CHR('h','m','t','x'):
43 if (font->hmtx) DELETE(table_iHmtx.free, font->hmtx);
44 return;
45 case OTFCC_CHR('v','m','t','x'):
46 if (font->vmtx) DELETE(table_iVmtx.free, font->vmtx);
47 return;
48 case OTFCC_CHR('p','o','s','t'):
49 if (font->post) DELETE(iTable_post.free, font->post);
50 return;
51 #if 0
52 case OTFCC_CHR('h','d','m','x'):
53 if (font->hdmx) DELETE(otfcc_deleteHdmx, font->hdmx);
54 return;
55 #endif
56 case OTFCC_CHR('v','h','e','a'):
57 if (font->vhea) DELETE(table_iVhea.free, font->vhea);
58 return;
59 case OTFCC_CHR('f','p','g','m'):
60 if (font->fpgm) DELETE(table_iFpgm_prep.free, font->fpgm);
61 return;
62 case OTFCC_CHR('p','r','e','p'):
63 if (font->prep) DELETE(table_iFpgm_prep.free, font->prep);
64 return;
65 case OTFCC_CHR('c','v','t','_'):
66 case OTFCC_CHR('c','v','t',' '):
67 if (font->cvt_) DELETE(table_iCvt.free, font->cvt_);
68 return;
69 case OTFCC_CHR('g','a','s','p'):
70 if (font->gasp) DELETE(table_iGasp.free, font->gasp);
71 return;
72 case OTFCC_CHR('C','F','F','_'):
73 case OTFCC_CHR('C','F','F',' '):
74 if (font->CFF_) DELETE(table_iCFF.free, font->CFF_);
75 return;
76 case OTFCC_CHR('g','l','y','f'):
77 if (font->glyf) DELETE(table_iGlyf.free, font->glyf);
78 return;
79 case OTFCC_CHR('c','m','a','p'):
80 if (font->cmap) DELETE(table_iCmap.free, font->cmap);
81 return;
82 case OTFCC_CHR('L','T','S','H'):
83 if (font->LTSH) DELETE(table_iLTSH.free, font->LTSH);
84 return;
85 case OTFCC_CHR('G','S','U','B'):
86 if (font->GSUB) DELETE(table_iOTL.free, font->GSUB);
87 return;
88 case OTFCC_CHR('G','P','O','S'):
89 if (font->GPOS) DELETE(table_iOTL.free, font->GPOS);
90 return;
91 case OTFCC_CHR('G','D','E','F'):
92 if (font->GDEF) DELETE(table_iGDEF.free, font->GDEF);
93 return;
94 case OTFCC_CHR('B','A','S','E'):
95 if (font->BASE) DELETE(table_iBASE.free, font->BASE);
96 return;
97 case OTFCC_CHR('V','O','R','G'):
98 if (font->VORG) DELETE(table_iVORG.free, font->VORG);
99 return;
100 case OTFCC_CHR('C','P','A','L'):
101 if (font->CPAL) DELETE(table_iCPAL.free, font->CPAL);
102 return;
103 case OTFCC_CHR('C','O','L','R'):
104 if (font->COLR) DELETE(table_iCOLR.free, font->COLR);
105 return;
106 case OTFCC_CHR('S','V','G',' '):
107 case OTFCC_CHR('S','V','G','_'):
108 if (font->SVG_) DELETE(table_iSVG.free, font->SVG_);
109 return;
110 case OTFCC_CHR('T','S','I','0'):
111 case OTFCC_CHR('T','S','I','1'):
112 if (font->TSI_01) DELETE(table_iTSI.free, font->TSI_01);
113 return;
114 case OTFCC_CHR('T','S','I','2'):
115 case OTFCC_CHR('T','S','I','3'):
116 if (font->TSI_23) DELETE(table_iTSI.free, font->TSI_23);
117 return;
118 case OTFCC_CHR('T','S','I','5'):
119 if (font->TSI5) DELETE(otl_iClassDef.free, font->TSI5);
120 return;
121 }
122 }
123
124 static INLINE void initFont(otfcc_Font *font) {
125 memset(font, 0, sizeof(*font));
126 }
127 static INLINE void disposeFont(otfcc_Font *font) {
128 deleteFontTable(font, OTFCC_CHR('h','e','a','d'));
129 deleteFontTable(font, OTFCC_CHR('h','h','e','a'));
130 deleteFontTable(font, OTFCC_CHR('m','a','x','p'));
131 deleteFontTable(font, OTFCC_CHR('O','S','_','2'));
132 deleteFontTable(font, OTFCC_CHR('n','a','m','e'));
133 deleteFontTable(font, OTFCC_CHR('m','e','t','a'));
134 deleteFontTable(font, OTFCC_CHR('h','m','t','x'));
135 deleteFontTable(font, OTFCC_CHR('v','m','t','x'));
136 deleteFontTable(font, OTFCC_CHR('p','o','s','t'));
137 deleteFontTable(font, OTFCC_CHR('h','d','m','x'));
138 deleteFontTable(font, OTFCC_CHR('v','h','e','a'));
139 deleteFontTable(font, OTFCC_CHR('f','p','g','m'));
140 deleteFontTable(font, OTFCC_CHR('p','r','e','p'));
141 deleteFontTable(font, OTFCC_CHR('c','v','t','_'));
142 deleteFontTable(font, OTFCC_CHR('g','a','s','p'));
143 deleteFontTable(font, OTFCC_CHR('C','F','F','_'));
144 deleteFontTable(font, OTFCC_CHR('g','l','y','f'));
145 deleteFontTable(font, OTFCC_CHR('c','m','a','p'));
146 deleteFontTable(font, OTFCC_CHR('L','T','S','H'));
147 deleteFontTable(font, OTFCC_CHR('G','S','U','B'));
148 deleteFontTable(font, OTFCC_CHR('G','P','O','S'));
149 deleteFontTable(font, OTFCC_CHR('G','D','E','F'));
150 deleteFontTable(font, OTFCC_CHR('B','A','S','E'));
151 deleteFontTable(font, OTFCC_CHR('V','O','R','G'));
152 deleteFontTable(font, OTFCC_CHR('C','P','A','L'));
153 deleteFontTable(font, OTFCC_CHR('C','O','L','R'));
154 deleteFontTable(font, OTFCC_CHR('S','V','G','_'));
155 deleteFontTable(font, OTFCC_CHR('T','S','I','0'));
156 deleteFontTable(font, OTFCC_CHR('T','S','I','2'));
157 deleteFontTable(font, OTFCC_CHR('T','S','I','5'));
158
159 GlyphOrder.free(font->glyph_order);
160 }
161 caryll_standardRefTypeFn(otfcc_Font, initFont, disposeFont);
162
163 caryll_ElementInterfaceOf(otfcc_Font) otfcc_iFont = {
164 caryll_standardRefTypeMethods(otfcc_Font),
165 .createTable = createFontTable,
166 .deleteTable = deleteFontTable,
167 .consolidate = otfcc_consolidateFont,
168 };