OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "ttgsubtable.h" | 7 #include "ttgsubtable.h" |
8 | 8 |
9 #include "core/include/fxge/fx_freetype.h" | 9 #include "core/include/fxge/fx_freetype.h" |
10 #include "core/include/fxge/fx_ge.h" | 10 #include "core/include/fxge/fx_ge.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 header.Version = gsub[0] << 24 | gsub[1] << 16 | gsub[2] << 8 | gsub[3]; | 57 header.Version = gsub[0] << 24 | gsub[1] << 16 | gsub[2] << 8 | gsub[3]; |
58 if (header.Version != 0x00010000) { | 58 if (header.Version != 0x00010000) { |
59 return false; | 59 return false; |
60 } | 60 } |
61 header.ScriptList = gsub[4] << 8 | gsub[5]; | 61 header.ScriptList = gsub[4] << 8 | gsub[5]; |
62 header.FeatureList = gsub[6] << 8 | gsub[7]; | 62 header.FeatureList = gsub[6] << 8 | gsub[7]; |
63 header.LookupList = gsub[8] << 8 | gsub[9]; | 63 header.LookupList = gsub[8] << 8 | gsub[9]; |
64 return Parse(&gsub[header.ScriptList], &gsub[header.FeatureList], | 64 return Parse(&gsub[header.ScriptList], &gsub[header.FeatureList], |
65 &gsub[header.LookupList]); | 65 &gsub[header.LookupList]); |
66 } | 66 } |
67 bool CFX_CTTGSUBTable::GetVerticalGlyph(TT_uint32_t glyphnum, | 67 bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum, |
68 TT_uint32_t* vglyphnum) { | 68 uint32_t* vglyphnum) { |
69 TT_uint32_t tag[] = { | 69 uint32_t tag[] = { |
70 (TT_uint8_t)'v' << 24 | (TT_uint8_t)'r' << 16 | (TT_uint8_t)'t' << 8 | | 70 (uint8_t)'v' << 24 | (uint8_t)'r' << 16 | (uint8_t)'t' << 8 | |
71 (TT_uint8_t)'2', | 71 (uint8_t)'2', |
72 (TT_uint8_t)'v' << 24 | (TT_uint8_t)'e' << 16 | (TT_uint8_t)'r' << 8 | | 72 (uint8_t)'v' << 24 | (uint8_t)'e' << 16 | (uint8_t)'r' << 8 | |
73 (TT_uint8_t)'t', | 73 (uint8_t)'t', |
74 }; | 74 }; |
75 if (!m_bFeautureMapLoad) { | 75 if (!m_bFeautureMapLoad) { |
76 for (int i = 0; i < ScriptList.ScriptCount; i++) { | 76 for (int i = 0; i < ScriptList.ScriptCount; i++) { |
77 for (int j = 0; j < (ScriptList.ScriptRecord + i)->Script.LangSysCount; | 77 for (int j = 0; j < (ScriptList.ScriptRecord + i)->Script.LangSysCount; |
78 ++j) { | 78 ++j) { |
79 for (int k = 0; | 79 for (int k = 0; |
80 k < ((ScriptList.ScriptRecord + i)->Script.LangSysRecord + j) | 80 k < ((ScriptList.ScriptRecord + i)->Script.LangSysRecord + j) |
81 ->LangSys.FeatureCount; | 81 ->LangSys.FeatureCount; |
82 ++k) { | 82 ++k) { |
83 FX_DWORD index = | 83 FX_DWORD index = |
(...skipping 20 matching lines...) Expand all Loading... |
104 m_bFeautureMapLoad = TRUE; | 104 m_bFeautureMapLoad = TRUE; |
105 } | 105 } |
106 for (const auto& pair : m_featureMap) { | 106 for (const auto& pair : m_featureMap) { |
107 if (GetVerticalGlyphSub(glyphnum, vglyphnum, | 107 if (GetVerticalGlyphSub(glyphnum, vglyphnum, |
108 &FeatureList.FeatureRecord[pair.second].Feature)) { | 108 &FeatureList.FeatureRecord[pair.second].Feature)) { |
109 return true; | 109 return true; |
110 } | 110 } |
111 } | 111 } |
112 return false; | 112 return false; |
113 } | 113 } |
114 bool CFX_CTTGSUBTable::GetVerticalGlyphSub(TT_uint32_t glyphnum, | 114 bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum, |
115 TT_uint32_t* vglyphnum, | 115 uint32_t* vglyphnum, |
116 struct TFeature* Feature) { | 116 struct TFeature* Feature) { |
117 for (int i = 0; i < Feature->LookupCount; i++) { | 117 for (int i = 0; i < Feature->LookupCount; i++) { |
118 int index = Feature->LookupListIndex[i]; | 118 int index = Feature->LookupListIndex[i]; |
119 if (index < 0 || LookupList.LookupCount < index) { | 119 if (index < 0 || LookupList.LookupCount < index) { |
120 continue; | 120 continue; |
121 } | 121 } |
122 if (LookupList.Lookup[index].LookupType == 1) { | 122 if (LookupList.Lookup[index].LookupType == 1) { |
123 if (GetVerticalGlyphSub2(glyphnum, vglyphnum, | 123 if (GetVerticalGlyphSub2(glyphnum, vglyphnum, |
124 &LookupList.Lookup[index])) { | 124 &LookupList.Lookup[index])) { |
125 return true; | 125 return true; |
126 } | 126 } |
127 } | 127 } |
128 } | 128 } |
129 return false; | 129 return false; |
130 } | 130 } |
131 bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(TT_uint32_t glyphnum, | 131 bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum, |
132 TT_uint32_t* vglyphnum, | 132 uint32_t* vglyphnum, |
133 struct TLookup* Lookup) { | 133 struct TLookup* Lookup) { |
134 for (int i = 0; i < Lookup->SubTableCount; i++) { | 134 for (int i = 0; i < Lookup->SubTableCount; i++) { |
135 switch (Lookup->SubTable[i]->SubstFormat) { | 135 switch (Lookup->SubTable[i]->SubstFormat) { |
136 case 1: { | 136 case 1: { |
137 TSingleSubstFormat1* tbl1 = (TSingleSubstFormat1*)Lookup->SubTable[i]; | 137 TSingleSubstFormat1* tbl1 = (TSingleSubstFormat1*)Lookup->SubTable[i]; |
138 if (GetCoverageIndex(tbl1->Coverage, glyphnum) >= 0) { | 138 if (GetCoverageIndex(tbl1->Coverage, glyphnum) >= 0) { |
139 *vglyphnum = glyphnum + tbl1->DeltaGlyphID; | 139 *vglyphnum = glyphnum + tbl1->DeltaGlyphID; |
140 return true; | 140 return true; |
141 } | 141 } |
142 break; | 142 break; |
143 } | 143 } |
144 case 2: { | 144 case 2: { |
145 TSingleSubstFormat2* tbl2 = (TSingleSubstFormat2*)Lookup->SubTable[i]; | 145 TSingleSubstFormat2* tbl2 = (TSingleSubstFormat2*)Lookup->SubTable[i]; |
146 int index = -1; | 146 int index = -1; |
147 index = GetCoverageIndex(tbl2->Coverage, glyphnum); | 147 index = GetCoverageIndex(tbl2->Coverage, glyphnum); |
148 if (0 <= index && index < tbl2->GlyphCount) { | 148 if (0 <= index && index < tbl2->GlyphCount) { |
149 *vglyphnum = tbl2->Substitute[index]; | 149 *vglyphnum = tbl2->Substitute[index]; |
150 return true; | 150 return true; |
151 } | 151 } |
152 break; | 152 break; |
153 } | 153 } |
154 } | 154 } |
155 } | 155 } |
156 return false; | 156 return false; |
157 } | 157 } |
158 int CFX_CTTGSUBTable::GetCoverageIndex(struct TCoverageFormatBase* Coverage, | 158 int CFX_CTTGSUBTable::GetCoverageIndex(struct TCoverageFormatBase* Coverage, |
159 TT_uint32_t g) { | 159 uint32_t g) { |
160 int i = 0; | 160 int i = 0; |
161 if (Coverage == NULL) { | 161 if (Coverage == NULL) { |
162 return -1; | 162 return -1; |
163 } | 163 } |
164 switch (Coverage->CoverageFormat) { | 164 switch (Coverage->CoverageFormat) { |
165 case 1: { | 165 case 1: { |
166 TCoverageFormat1* c1 = (TCoverageFormat1*)Coverage; | 166 TCoverageFormat1* c1 = (TCoverageFormat1*)Coverage; |
167 for (i = 0; i < c1->GlyphCount; i++) { | 167 for (i = 0; i < c1->GlyphCount; i++) { |
168 if ((TT_uint32_t)c1->GlyphArray[i] == g) { | 168 if ((uint32_t)c1->GlyphArray[i] == g) { |
169 return i; | 169 return i; |
170 } | 170 } |
171 } | 171 } |
172 return -1; | 172 return -1; |
173 } | 173 } |
174 case 2: { | 174 case 2: { |
175 TCoverageFormat2* c2 = (TCoverageFormat2*)Coverage; | 175 TCoverageFormat2* c2 = (TCoverageFormat2*)Coverage; |
176 for (i = 0; i < c2->RangeCount; i++) { | 176 for (i = 0; i < c2->RangeCount; i++) { |
177 TT_uint32_t s = c2->RangeRecord[i].Start; | 177 uint32_t s = c2->RangeRecord[i].Start; |
178 TT_uint32_t e = c2->RangeRecord[i].End; | 178 uint32_t e = c2->RangeRecord[i].End; |
179 TT_uint32_t si = c2->RangeRecord[i].StartCoverageIndex; | 179 uint32_t si = c2->RangeRecord[i].StartCoverageIndex; |
180 if (s <= g && g <= e) { | 180 if (s <= g && g <= e) { |
181 return si + g - s; | 181 return si + g - s; |
182 } | 182 } |
183 } | 183 } |
184 return -1; | 184 return -1; |
185 } | 185 } |
186 } | 186 } |
187 return -1; | 187 return -1; |
188 } | 188 } |
189 bool CFX_CTTGSUBTable::Parse(FT_Bytes scriptlist, | 189 bool CFX_CTTGSUBTable::Parse(FT_Bytes scriptlist, |
190 FT_Bytes featurelist, | 190 FT_Bytes featurelist, |
191 FT_Bytes lookuplist) { | 191 FT_Bytes lookuplist) { |
192 ParseScriptList(scriptlist, &ScriptList); | 192 ParseScriptList(scriptlist, &ScriptList); |
193 ParseFeatureList(featurelist, &FeatureList); | 193 ParseFeatureList(featurelist, &FeatureList); |
194 ParseLookupList(lookuplist, &LookupList); | 194 ParseLookupList(lookuplist, &LookupList); |
195 return true; | 195 return true; |
196 } | 196 } |
197 void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, struct TScriptList* rec) { | 197 void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, struct TScriptList* rec) { |
198 int i; | 198 int i; |
199 FT_Bytes sp = raw; | 199 FT_Bytes sp = raw; |
200 rec->ScriptCount = GetUInt16(sp); | 200 rec->ScriptCount = GetUInt16(sp); |
201 if (rec->ScriptCount <= 0) { | 201 if (rec->ScriptCount <= 0) { |
202 return; | 202 return; |
203 } | 203 } |
204 rec->ScriptRecord = new struct TScriptRecord[rec->ScriptCount]; | 204 rec->ScriptRecord = new struct TScriptRecord[rec->ScriptCount]; |
205 for (i = 0; i < rec->ScriptCount; i++) { | 205 for (i = 0; i < rec->ScriptCount; i++) { |
206 rec->ScriptRecord[i].ScriptTag = GetUInt32(sp); | 206 rec->ScriptRecord[i].ScriptTag = GetUInt32(sp); |
207 TT_uint16_t offset = GetUInt16(sp); | 207 uint16_t offset = GetUInt16(sp); |
208 ParseScript(&raw[offset], &rec->ScriptRecord[i].Script); | 208 ParseScript(&raw[offset], &rec->ScriptRecord[i].Script); |
209 } | 209 } |
210 } | 210 } |
211 void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, struct TScript* rec) { | 211 void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, struct TScript* rec) { |
212 int i; | 212 int i; |
213 FT_Bytes sp = raw; | 213 FT_Bytes sp = raw; |
214 rec->DefaultLangSys = GetUInt16(sp); | 214 rec->DefaultLangSys = GetUInt16(sp); |
215 rec->LangSysCount = GetUInt16(sp); | 215 rec->LangSysCount = GetUInt16(sp); |
216 if (rec->LangSysCount <= 0) { | 216 if (rec->LangSysCount <= 0) { |
217 return; | 217 return; |
218 } | 218 } |
219 rec->LangSysRecord = new struct TLangSysRecord[rec->LangSysCount]; | 219 rec->LangSysRecord = new struct TLangSysRecord[rec->LangSysCount]; |
220 for (i = 0; i < rec->LangSysCount; i++) { | 220 for (i = 0; i < rec->LangSysCount; i++) { |
221 rec->LangSysRecord[i].LangSysTag = GetUInt32(sp); | 221 rec->LangSysRecord[i].LangSysTag = GetUInt32(sp); |
222 TT_uint16_t offset = GetUInt16(sp); | 222 uint16_t offset = GetUInt16(sp); |
223 ParseLangSys(&raw[offset], &rec->LangSysRecord[i].LangSys); | 223 ParseLangSys(&raw[offset], &rec->LangSysRecord[i].LangSys); |
224 } | 224 } |
225 } | 225 } |
226 void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, struct TLangSys* rec) { | 226 void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, struct TLangSys* rec) { |
227 FT_Bytes sp = raw; | 227 FT_Bytes sp = raw; |
228 rec->LookupOrder = GetUInt16(sp); | 228 rec->LookupOrder = GetUInt16(sp); |
229 rec->ReqFeatureIndex = GetUInt16(sp); | 229 rec->ReqFeatureIndex = GetUInt16(sp); |
230 rec->FeatureCount = GetUInt16(sp); | 230 rec->FeatureCount = GetUInt16(sp); |
231 if (rec->FeatureCount <= 0) { | 231 if (rec->FeatureCount <= 0) { |
232 return; | 232 return; |
233 } | 233 } |
234 rec->FeatureIndex = new TT_uint16_t[rec->FeatureCount]; | 234 rec->FeatureIndex = new uint16_t[rec->FeatureCount]; |
235 FXSYS_memset(rec->FeatureIndex, 0, sizeof(TT_uint16_t) * rec->FeatureCount); | 235 FXSYS_memset(rec->FeatureIndex, 0, sizeof(uint16_t) * rec->FeatureCount); |
236 for (int i = 0; i < rec->FeatureCount; ++i) { | 236 for (int i = 0; i < rec->FeatureCount; ++i) { |
237 rec->FeatureIndex[i] = GetUInt16(sp); | 237 rec->FeatureIndex[i] = GetUInt16(sp); |
238 } | 238 } |
239 } | 239 } |
240 void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) { | 240 void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) { |
241 int i; | 241 int i; |
242 FT_Bytes sp = raw; | 242 FT_Bytes sp = raw; |
243 rec->FeatureCount = GetUInt16(sp); | 243 rec->FeatureCount = GetUInt16(sp); |
244 if (rec->FeatureCount <= 0) { | 244 if (rec->FeatureCount <= 0) { |
245 return; | 245 return; |
246 } | 246 } |
247 rec->FeatureRecord = new struct TFeatureRecord[rec->FeatureCount]; | 247 rec->FeatureRecord = new struct TFeatureRecord[rec->FeatureCount]; |
248 for (i = 0; i < rec->FeatureCount; i++) { | 248 for (i = 0; i < rec->FeatureCount; i++) { |
249 rec->FeatureRecord[i].FeatureTag = GetUInt32(sp); | 249 rec->FeatureRecord[i].FeatureTag = GetUInt32(sp); |
250 TT_uint16_t offset = GetUInt16(sp); | 250 uint16_t offset = GetUInt16(sp); |
251 ParseFeature(&raw[offset], &rec->FeatureRecord[i].Feature); | 251 ParseFeature(&raw[offset], &rec->FeatureRecord[i].Feature); |
252 } | 252 } |
253 } | 253 } |
254 void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) { | 254 void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) { |
255 int i; | 255 int i; |
256 FT_Bytes sp = raw; | 256 FT_Bytes sp = raw; |
257 rec->FeatureParams = GetUInt16(sp); | 257 rec->FeatureParams = GetUInt16(sp); |
258 rec->LookupCount = GetUInt16(sp); | 258 rec->LookupCount = GetUInt16(sp); |
259 if (rec->LookupCount <= 0) { | 259 if (rec->LookupCount <= 0) { |
260 return; | 260 return; |
261 } | 261 } |
262 rec->LookupListIndex = new TT_uint16_t[rec->LookupCount]; | 262 rec->LookupListIndex = new uint16_t[rec->LookupCount]; |
263 for (i = 0; i < rec->LookupCount; i++) { | 263 for (i = 0; i < rec->LookupCount; i++) { |
264 rec->LookupListIndex[i] = GetUInt16(sp); | 264 rec->LookupListIndex[i] = GetUInt16(sp); |
265 } | 265 } |
266 } | 266 } |
267 void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw, TLookupList* rec) { | 267 void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw, TLookupList* rec) { |
268 int i; | 268 int i; |
269 FT_Bytes sp = raw; | 269 FT_Bytes sp = raw; |
270 rec->LookupCount = GetUInt16(sp); | 270 rec->LookupCount = GetUInt16(sp); |
271 if (rec->LookupCount <= 0) { | 271 if (rec->LookupCount <= 0) { |
272 return; | 272 return; |
273 } | 273 } |
274 rec->Lookup = new struct TLookup[rec->LookupCount]; | 274 rec->Lookup = new struct TLookup[rec->LookupCount]; |
275 for (i = 0; i < rec->LookupCount; i++) { | 275 for (i = 0; i < rec->LookupCount; i++) { |
276 TT_uint16_t offset = GetUInt16(sp); | 276 uint16_t offset = GetUInt16(sp); |
277 ParseLookup(&raw[offset], &rec->Lookup[i]); | 277 ParseLookup(&raw[offset], &rec->Lookup[i]); |
278 } | 278 } |
279 } | 279 } |
280 void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) { | 280 void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) { |
281 int i; | 281 int i; |
282 FT_Bytes sp = raw; | 282 FT_Bytes sp = raw; |
283 rec->LookupType = GetUInt16(sp); | 283 rec->LookupType = GetUInt16(sp); |
284 rec->LookupFlag = GetUInt16(sp); | 284 rec->LookupFlag = GetUInt16(sp); |
285 rec->SubTableCount = GetUInt16(sp); | 285 rec->SubTableCount = GetUInt16(sp); |
286 if (rec->SubTableCount <= 0) { | 286 if (rec->SubTableCount <= 0) { |
287 return; | 287 return; |
288 } | 288 } |
289 rec->SubTable = new struct TSubTableBase*[rec->SubTableCount]; | 289 rec->SubTable = new struct TSubTableBase*[rec->SubTableCount]; |
290 for (i = 0; i < rec->SubTableCount; i++) { | 290 for (i = 0; i < rec->SubTableCount; i++) { |
291 rec->SubTable[i] = NULL; | 291 rec->SubTable[i] = NULL; |
292 } | 292 } |
293 if (rec->LookupType != 1) { | 293 if (rec->LookupType != 1) { |
294 return; | 294 return; |
295 } | 295 } |
296 for (i = 0; i < rec->SubTableCount; i++) { | 296 for (i = 0; i < rec->SubTableCount; i++) { |
297 TT_uint16_t offset = GetUInt16(sp); | 297 uint16_t offset = GetUInt16(sp); |
298 ParseSingleSubst(&raw[offset], &rec->SubTable[i]); | 298 ParseSingleSubst(&raw[offset], &rec->SubTable[i]); |
299 } | 299 } |
300 } | 300 } |
301 void CFX_CTTGSUBTable::ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec) { | 301 void CFX_CTTGSUBTable::ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec) { |
302 FT_Bytes sp = raw; | 302 FT_Bytes sp = raw; |
303 TT_uint16_t Format = GetUInt16(sp); | 303 uint16_t Format = GetUInt16(sp); |
304 switch (Format) { | 304 switch (Format) { |
305 case 1: | 305 case 1: |
306 *rec = new TCoverageFormat1(); | 306 *rec = new TCoverageFormat1(); |
307 ParseCoverageFormat1(raw, (TCoverageFormat1*)*rec); | 307 ParseCoverageFormat1(raw, (TCoverageFormat1*)*rec); |
308 break; | 308 break; |
309 case 2: | 309 case 2: |
310 *rec = new TCoverageFormat2(); | 310 *rec = new TCoverageFormat2(); |
311 ParseCoverageFormat2(raw, (TCoverageFormat2*)*rec); | 311 ParseCoverageFormat2(raw, (TCoverageFormat2*)*rec); |
312 break; | 312 break; |
313 } | 313 } |
314 } | 314 } |
315 void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw, | 315 void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw, |
316 TCoverageFormat1* rec) { | 316 TCoverageFormat1* rec) { |
317 int i; | 317 int i; |
318 FT_Bytes sp = raw; | 318 FT_Bytes sp = raw; |
319 GetUInt16(sp); | 319 GetUInt16(sp); |
320 rec->GlyphCount = GetUInt16(sp); | 320 rec->GlyphCount = GetUInt16(sp); |
321 if (rec->GlyphCount <= 0) { | 321 if (rec->GlyphCount <= 0) { |
322 return; | 322 return; |
323 } | 323 } |
324 rec->GlyphArray = new TT_uint16_t[rec->GlyphCount]; | 324 rec->GlyphArray = new uint16_t[rec->GlyphCount]; |
325 for (i = 0; i < rec->GlyphCount; i++) { | 325 for (i = 0; i < rec->GlyphCount; i++) { |
326 rec->GlyphArray[i] = GetUInt16(sp); | 326 rec->GlyphArray[i] = GetUInt16(sp); |
327 } | 327 } |
328 } | 328 } |
329 void CFX_CTTGSUBTable::ParseCoverageFormat2(FT_Bytes raw, | 329 void CFX_CTTGSUBTable::ParseCoverageFormat2(FT_Bytes raw, |
330 TCoverageFormat2* rec) { | 330 TCoverageFormat2* rec) { |
331 int i; | 331 int i; |
332 FT_Bytes sp = raw; | 332 FT_Bytes sp = raw; |
333 GetUInt16(sp); | 333 GetUInt16(sp); |
334 rec->RangeCount = GetUInt16(sp); | 334 rec->RangeCount = GetUInt16(sp); |
335 if (rec->RangeCount <= 0) { | 335 if (rec->RangeCount <= 0) { |
336 return; | 336 return; |
337 } | 337 } |
338 rec->RangeRecord = new TRangeRecord[rec->RangeCount]; | 338 rec->RangeRecord = new TRangeRecord[rec->RangeCount]; |
339 for (i = 0; i < rec->RangeCount; i++) { | 339 for (i = 0; i < rec->RangeCount; i++) { |
340 rec->RangeRecord[i].Start = GetUInt16(sp); | 340 rec->RangeRecord[i].Start = GetUInt16(sp); |
341 rec->RangeRecord[i].End = GetUInt16(sp); | 341 rec->RangeRecord[i].End = GetUInt16(sp); |
342 rec->RangeRecord[i].StartCoverageIndex = GetUInt16(sp); | 342 rec->RangeRecord[i].StartCoverageIndex = GetUInt16(sp); |
343 } | 343 } |
344 } | 344 } |
345 void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec) { | 345 void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec) { |
346 FT_Bytes sp = raw; | 346 FT_Bytes sp = raw; |
347 TT_uint16_t Format = GetUInt16(sp); | 347 uint16_t Format = GetUInt16(sp); |
348 switch (Format) { | 348 switch (Format) { |
349 case 1: | 349 case 1: |
350 *rec = new TSingleSubstFormat1(); | 350 *rec = new TSingleSubstFormat1(); |
351 ParseSingleSubstFormat1(raw, (TSingleSubstFormat1*)*rec); | 351 ParseSingleSubstFormat1(raw, (TSingleSubstFormat1*)*rec); |
352 break; | 352 break; |
353 case 2: | 353 case 2: |
354 *rec = new TSingleSubstFormat2(); | 354 *rec = new TSingleSubstFormat2(); |
355 ParseSingleSubstFormat2(raw, (TSingleSubstFormat2*)*rec); | 355 ParseSingleSubstFormat2(raw, (TSingleSubstFormat2*)*rec); |
356 break; | 356 break; |
357 } | 357 } |
358 } | 358 } |
359 void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw, | 359 void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw, |
360 TSingleSubstFormat1* rec) { | 360 TSingleSubstFormat1* rec) { |
361 FT_Bytes sp = raw; | 361 FT_Bytes sp = raw; |
362 GetUInt16(sp); | 362 GetUInt16(sp); |
363 TT_uint16_t offset = GetUInt16(sp); | 363 uint16_t offset = GetUInt16(sp); |
364 ParseCoverage(&raw[offset], &rec->Coverage); | 364 ParseCoverage(&raw[offset], &rec->Coverage); |
365 rec->DeltaGlyphID = GetInt16(sp); | 365 rec->DeltaGlyphID = GetInt16(sp); |
366 } | 366 } |
367 void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw, | 367 void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw, |
368 TSingleSubstFormat2* rec) { | 368 TSingleSubstFormat2* rec) { |
369 int i; | 369 int i; |
370 FT_Bytes sp = raw; | 370 FT_Bytes sp = raw; |
371 GetUInt16(sp); | 371 GetUInt16(sp); |
372 TT_uint16_t offset = GetUInt16(sp); | 372 uint16_t offset = GetUInt16(sp); |
373 ParseCoverage(&raw[offset], &rec->Coverage); | 373 ParseCoverage(&raw[offset], &rec->Coverage); |
374 rec->GlyphCount = GetUInt16(sp); | 374 rec->GlyphCount = GetUInt16(sp); |
375 if (rec->GlyphCount <= 0) { | 375 if (rec->GlyphCount <= 0) { |
376 return; | 376 return; |
377 } | 377 } |
378 rec->Substitute = new TT_uint16_t[rec->GlyphCount]; | 378 rec->Substitute = new uint16_t[rec->GlyphCount]; |
379 for (i = 0; i < rec->GlyphCount; i++) { | 379 for (i = 0; i < rec->GlyphCount; i++) { |
380 rec->Substitute[i] = GetUInt16(sp); | 380 rec->Substitute[i] = GetUInt16(sp); |
381 } | 381 } |
382 } | 382 } |
383 FX_BOOL CFX_GSUBTable::GetVerticalGlyph(FX_DWORD glyphnum, | 383 FX_BOOL CFX_GSUBTable::GetVerticalGlyph(FX_DWORD glyphnum, |
384 FX_DWORD* vglyphnum) { | 384 FX_DWORD* vglyphnum) { |
385 return m_GsubImp.GetVerticalGlyph(glyphnum, vglyphnum); | 385 return m_GsubImp.GetVerticalGlyph(glyphnum, vglyphnum); |
386 } | 386 } |
387 // static | 387 // static |
388 IFX_GSUBTable* IFX_GSUBTable::Create(CFX_Font* pFont) { | 388 IFX_GSUBTable* IFX_GSUBTable::Create(CFX_Font* pFont) { |
(...skipping 15 matching lines...) Expand all Loading... |
404 FXFT_Load_Sfnt_Table(pFont->GetFace(), FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, | 404 FXFT_Load_Sfnt_Table(pFont->GetFace(), FT_MAKE_TAG('G', 'S', 'U', 'B'), 0, |
405 pFont->GetSubData(), NULL); | 405 pFont->GetSubData(), NULL); |
406 if (!error && pFont->GetSubData()) { | 406 if (!error && pFont->GetSubData()) { |
407 nonstd::unique_ptr<CFX_GSUBTable> pGsubTable(new CFX_GSUBTable); | 407 nonstd::unique_ptr<CFX_GSUBTable> pGsubTable(new CFX_GSUBTable); |
408 if (pGsubTable->m_GsubImp.LoadGSUBTable((FT_Bytes)pFont->GetSubData())) { | 408 if (pGsubTable->m_GsubImp.LoadGSUBTable((FT_Bytes)pFont->GetSubData())) { |
409 return pGsubTable.release(); | 409 return pGsubTable.release(); |
410 } | 410 } |
411 } | 411 } |
412 return NULL; | 412 return NULL; |
413 } | 413 } |
OLD | NEW |