PageRenderTime 54ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/src/3rdparty/harfbuzz/src/harfbuzz-gsub-private.h

https://bitbucket.org/jjgod/qt-vtl
C Header | 475 lines | 266 code | 113 blank | 96 comment | 0 complexity | f0e14a7afa50100d920073c8f5adec29 MD5 | raw file
Possible License(s): LGPL-3.0, BSD-3-Clause, CC0-1.0, CC-BY-SA-4.0, LGPL-2.1, GPL-3.0, Apache-2.0, LGPL-2.0
  1. /*
  2. * Copyright (C) 1998-2004 David Turner and Werner Lemberg
  3. * Copyright (C) 2006 Behdad Esfahbod
  4. *
  5. * This is part of HarfBuzz, an OpenType Layout engine library.
  6. *
  7. * Permission is hereby granted, without written agreement and without
  8. * license or royalty fees, to use, copy, modify, and distribute this
  9. * software and its documentation for any purpose, provided that the
  10. * above copyright notice and the following two paragraphs appear in
  11. * all copies of this software.
  12. *
  13. * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
  14. * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  15. * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
  16. * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  17. * DAMAGE.
  18. *
  19. * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  20. * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  21. * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
  22. * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  23. * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  24. */
  25. #ifndef HARFBUZZ_GSUB_PRIVATE_H
  26. #define HARFBUZZ_GSUB_PRIVATE_H
  27. #include "harfbuzz-impl.h"
  28. #include "harfbuzz-stream-private.h"
  29. #include "harfbuzz-gsub.h"
  30. HB_BEGIN_HEADER
  31. typedef union HB_GSUB_SubTable_ HB_GSUB_SubTable;
  32. /* LookupType 1 */
  33. struct HB_SingleSubstFormat1_
  34. {
  35. HB_Short DeltaGlyphID; /* constant added to get
  36. substitution glyph index */
  37. };
  38. typedef struct HB_SingleSubstFormat1_ HB_SingleSubstFormat1;
  39. struct HB_SingleSubstFormat2_
  40. {
  41. HB_UShort* Substitute; /* array of substitute glyph IDs */
  42. HB_UShort GlyphCount; /* number of glyph IDs in
  43. Substitute array */
  44. };
  45. typedef struct HB_SingleSubstFormat2_ HB_SingleSubstFormat2;
  46. struct HB_SingleSubst_
  47. {
  48. union
  49. {
  50. HB_SingleSubstFormat1 ssf1;
  51. HB_SingleSubstFormat2 ssf2;
  52. } ssf;
  53. HB_Coverage Coverage; /* Coverage table */
  54. HB_Byte SubstFormat; /* 1 or 2 */
  55. };
  56. typedef struct HB_SingleSubst_ HB_SingleSubst;
  57. /* LookupType 2 */
  58. struct HB_Sequence_
  59. {
  60. HB_UShort* Substitute; /* string of glyph IDs to
  61. substitute */
  62. HB_UShort GlyphCount; /* number of glyph IDs in the
  63. Substitute array */
  64. };
  65. typedef struct HB_Sequence_ HB_Sequence;
  66. struct HB_MultipleSubst_
  67. {
  68. HB_Sequence* Sequence; /* array of Sequence tables */
  69. HB_Coverage Coverage; /* Coverage table */
  70. HB_UShort SubstFormat; /* always 1 */
  71. HB_UShort SequenceCount; /* number of Sequence tables */
  72. };
  73. typedef struct HB_MultipleSubst_ HB_MultipleSubst;
  74. /* LookupType 3 */
  75. struct HB_AlternateSet_
  76. {
  77. HB_UShort* Alternate; /* array of alternate glyph IDs */
  78. HB_UShort GlyphCount; /* number of glyph IDs in the
  79. Alternate array */
  80. };
  81. typedef struct HB_AlternateSet_ HB_AlternateSet;
  82. struct HB_AlternateSubst_
  83. {
  84. HB_AlternateSet* AlternateSet; /* array of AlternateSet tables */
  85. HB_Coverage Coverage; /* Coverage table */
  86. HB_UShort SubstFormat; /* always 1 */
  87. HB_UShort AlternateSetCount;
  88. /* number of AlternateSet tables */
  89. };
  90. typedef struct HB_AlternateSubst_ HB_AlternateSubst;
  91. /* LookupType 4 */
  92. struct HB_Ligature_
  93. {
  94. HB_UShort* Component; /* array of component glyph IDs */
  95. HB_UShort LigGlyph; /* glyphID of ligature
  96. to substitute */
  97. HB_UShort ComponentCount; /* number of components in ligature */
  98. };
  99. typedef struct HB_Ligature_ HB_Ligature;
  100. struct HB_LigatureSet_
  101. {
  102. HB_Ligature* Ligature; /* array of Ligature tables */
  103. HB_UShort LigatureCount; /* number of Ligature tables */
  104. };
  105. typedef struct HB_LigatureSet_ HB_LigatureSet;
  106. struct HB_LigatureSubst_
  107. {
  108. HB_LigatureSet* LigatureSet; /* array of LigatureSet tables */
  109. HB_Coverage Coverage; /* Coverage table */
  110. HB_UShort SubstFormat; /* always 1 */
  111. HB_UShort LigatureSetCount; /* number of LigatureSet tables */
  112. };
  113. typedef struct HB_LigatureSubst_ HB_LigatureSubst;
  114. /* needed by both lookup type 5 and 6 */
  115. struct HB_SubstLookupRecord_
  116. {
  117. HB_UShort SequenceIndex; /* index into current
  118. glyph sequence */
  119. HB_UShort LookupListIndex; /* Lookup to apply to that pos. */
  120. };
  121. typedef struct HB_SubstLookupRecord_ HB_SubstLookupRecord;
  122. /* LookupType 5 */
  123. struct HB_SubRule_
  124. {
  125. HB_UShort* Input; /* array of input glyph IDs */
  126. HB_SubstLookupRecord* SubstLookupRecord;
  127. /* array of SubstLookupRecord
  128. tables */
  129. HB_UShort GlyphCount; /* total number of input glyphs */
  130. HB_UShort SubstCount; /* number of SubstLookupRecord
  131. tables */
  132. };
  133. typedef struct HB_SubRule_ HB_SubRule;
  134. struct HB_SubRuleSet_
  135. {
  136. HB_SubRule* SubRule; /* array of SubRule tables */
  137. HB_UShort SubRuleCount; /* number of SubRule tables */
  138. };
  139. typedef struct HB_SubRuleSet_ HB_SubRuleSet;
  140. struct HB_ContextSubstFormat1_
  141. {
  142. HB_SubRuleSet* SubRuleSet; /* array of SubRuleSet tables */
  143. HB_Coverage Coverage; /* Coverage table */
  144. HB_UShort SubRuleSetCount; /* number of SubRuleSet tables */
  145. };
  146. typedef struct HB_ContextSubstFormat1_ HB_ContextSubstFormat1;
  147. struct HB_SubClassRule_
  148. {
  149. HB_UShort* Class; /* array of classes */
  150. HB_SubstLookupRecord* SubstLookupRecord;
  151. /* array of SubstLookupRecord
  152. tables */
  153. HB_UShort GlyphCount; /* total number of context classes */
  154. HB_UShort SubstCount; /* number of SubstLookupRecord
  155. tables */
  156. };
  157. typedef struct HB_SubClassRule_ HB_SubClassRule;
  158. struct HB_SubClassSet_
  159. {
  160. HB_SubClassRule* SubClassRule; /* array of SubClassRule tables */
  161. HB_UShort SubClassRuleCount;
  162. /* number of SubClassRule tables */
  163. };
  164. typedef struct HB_SubClassSet_ HB_SubClassSet;
  165. /* The `MaxContextLength' field is not defined in the TTO specification
  166. but simplifies the implementation of this format. It holds the
  167. maximal context length used in the context rules. */
  168. struct HB_ContextSubstFormat2_
  169. {
  170. HB_SubClassSet* SubClassSet; /* array of SubClassSet tables */
  171. HB_Coverage Coverage; /* Coverage table */
  172. HB_ClassDefinition ClassDef; /* ClassDef table */
  173. HB_UShort SubClassSetCount;
  174. /* number of SubClassSet tables */
  175. HB_UShort MaxContextLength;
  176. /* maximal context length */
  177. };
  178. typedef struct HB_ContextSubstFormat2_ HB_ContextSubstFormat2;
  179. struct HB_ContextSubstFormat3_
  180. {
  181. HB_Coverage* Coverage; /* array of Coverage tables */
  182. HB_SubstLookupRecord* SubstLookupRecord;
  183. /* array of substitution lookups */
  184. HB_UShort GlyphCount; /* number of input glyphs */
  185. HB_UShort SubstCount; /* number of SubstLookupRecords */
  186. };
  187. typedef struct HB_ContextSubstFormat3_ HB_ContextSubstFormat3;
  188. struct HB_ContextSubst_
  189. {
  190. union
  191. {
  192. HB_ContextSubstFormat1 csf1;
  193. HB_ContextSubstFormat2 csf2;
  194. HB_ContextSubstFormat3 csf3;
  195. } csf;
  196. HB_Byte SubstFormat; /* 1, 2, or 3 */
  197. };
  198. typedef struct HB_ContextSubst_ HB_ContextSubst;
  199. /* LookupType 6 */
  200. struct HB_ChainSubRule_
  201. {
  202. HB_UShort* Backtrack; /* array of backtrack glyph IDs */
  203. HB_UShort* Input; /* array of input glyph IDs */
  204. HB_UShort* Lookahead; /* array of lookahead glyph IDs */
  205. HB_SubstLookupRecord* SubstLookupRecord;
  206. /* array of SubstLookupRecords */
  207. HB_UShort BacktrackGlyphCount;
  208. /* total number of backtrack glyphs */
  209. HB_UShort InputGlyphCount;
  210. /* total number of input glyphs */
  211. HB_UShort LookaheadGlyphCount;
  212. /* total number of lookahead glyphs */
  213. HB_UShort SubstCount; /* number of SubstLookupRecords */
  214. };
  215. typedef struct HB_ChainSubRule_ HB_ChainSubRule;
  216. struct HB_ChainSubRuleSet_
  217. {
  218. HB_ChainSubRule* ChainSubRule; /* array of ChainSubRule tables */
  219. HB_UShort ChainSubRuleCount;
  220. /* number of ChainSubRule tables */
  221. };
  222. typedef struct HB_ChainSubRuleSet_ HB_ChainSubRuleSet;
  223. struct HB_ChainContextSubstFormat1_
  224. {
  225. HB_ChainSubRuleSet* ChainSubRuleSet;
  226. /* array of ChainSubRuleSet tables */
  227. HB_Coverage Coverage; /* Coverage table */
  228. HB_UShort ChainSubRuleSetCount;
  229. /* number of ChainSubRuleSet tables */
  230. };
  231. typedef struct HB_ChainContextSubstFormat1_ HB_ChainContextSubstFormat1;
  232. struct HB_ChainSubClassRule_
  233. {
  234. HB_UShort* Backtrack; /* array of backtrack classes */
  235. HB_UShort* Input; /* array of context classes */
  236. HB_UShort* Lookahead; /* array of lookahead classes */
  237. HB_SubstLookupRecord* SubstLookupRecord;
  238. /* array of substitution lookups */
  239. HB_UShort BacktrackGlyphCount;
  240. /* total number of backtrack
  241. classes */
  242. HB_UShort InputGlyphCount;
  243. /* total number of context classes */
  244. HB_UShort LookaheadGlyphCount;
  245. /* total number of lookahead
  246. classes */
  247. HB_UShort SubstCount; /* number of SubstLookupRecords */
  248. };
  249. typedef struct HB_ChainSubClassRule_ HB_ChainSubClassRule;
  250. struct HB_ChainSubClassSet_
  251. {
  252. HB_ChainSubClassRule* ChainSubClassRule;
  253. /* array of ChainSubClassRule
  254. tables */
  255. HB_UShort ChainSubClassRuleCount;
  256. /* number of ChainSubClassRule
  257. tables */
  258. };
  259. typedef struct HB_ChainSubClassSet_ HB_ChainSubClassSet;
  260. /* The `MaxXXXLength' fields are not defined in the TTO specification
  261. but simplifies the implementation of this format. It holds the
  262. maximal context length used in the specific context rules. */
  263. struct HB_ChainContextSubstFormat2_
  264. {
  265. HB_ChainSubClassSet* ChainSubClassSet;
  266. /* array of ChainSubClassSet
  267. tables */
  268. HB_Coverage Coverage; /* Coverage table */
  269. HB_ClassDefinition BacktrackClassDef;
  270. /* BacktrackClassDef table */
  271. HB_ClassDefinition InputClassDef;
  272. /* InputClassDef table */
  273. HB_ClassDefinition LookaheadClassDef;
  274. /* LookaheadClassDef table */
  275. HB_UShort ChainSubClassSetCount;
  276. /* number of ChainSubClassSet
  277. tables */
  278. HB_UShort MaxBacktrackLength;
  279. /* maximal backtrack length */
  280. HB_UShort MaxLookaheadLength;
  281. /* maximal lookahead length */
  282. HB_UShort MaxInputLength;
  283. /* maximal input length */
  284. };
  285. typedef struct HB_ChainContextSubstFormat2_ HB_ChainContextSubstFormat2;
  286. struct HB_ChainContextSubstFormat3_
  287. {
  288. HB_Coverage* BacktrackCoverage;
  289. /* array of backtrack Coverage
  290. tables */
  291. HB_Coverage* InputCoverage;
  292. /* array of input coverage
  293. tables */
  294. HB_Coverage* LookaheadCoverage;
  295. /* array of lookahead coverage
  296. tables */
  297. HB_SubstLookupRecord* SubstLookupRecord;
  298. /* array of substitution lookups */
  299. HB_UShort BacktrackGlyphCount;
  300. /* number of backtrack glyphs */
  301. HB_UShort InputGlyphCount;
  302. /* number of input glyphs */
  303. HB_UShort LookaheadGlyphCount;
  304. /* number of lookahead glyphs */
  305. HB_UShort SubstCount; /* number of SubstLookupRecords */
  306. };
  307. typedef struct HB_ChainContextSubstFormat3_ HB_ChainContextSubstFormat3;
  308. struct HB_ChainContextSubst_
  309. {
  310. union
  311. {
  312. HB_ChainContextSubstFormat1 ccsf1;
  313. HB_ChainContextSubstFormat2 ccsf2;
  314. HB_ChainContextSubstFormat3 ccsf3;
  315. } ccsf;
  316. HB_Byte SubstFormat; /* 1, 2, or 3 */
  317. };
  318. typedef struct HB_ChainContextSubst_ HB_ChainContextSubst;
  319. #if 0
  320. /* LookupType 7 */
  321. struct HB_ExtensionSubst_
  322. {
  323. HB_GSUB_SubTable *subtable; /* referenced subtable */
  324. HB_UShort SubstFormat; /* always 1 */
  325. HB_UShort LookuptType; /* lookup-type of referenced subtable */
  326. };
  327. typedef struct HB_ExtensionSubst_ HB_ExtensionSubst;
  328. #endif
  329. /* LookupType 8 */
  330. struct HB_ReverseChainContextSubst_
  331. {
  332. HB_Coverage* LookaheadCoverage; /* array of lookahead Coverage
  333. tables */
  334. HB_UShort* Substitute; /* array of substitute Glyph ID */
  335. HB_Coverage* BacktrackCoverage; /* array of backtrack Coverage
  336. tables */
  337. HB_Coverage Coverage; /* coverage table for input glyphs */
  338. HB_UShort SubstFormat; /* always 1 */
  339. HB_UShort BacktrackGlyphCount; /* number of backtrack glyphs */
  340. HB_UShort LookaheadGlyphCount; /* number of lookahead glyphs */
  341. HB_UShort GlyphCount; /* number of Glyph IDs */
  342. };
  343. typedef struct HB_ReverseChainContextSubst_ HB_ReverseChainContextSubst;
  344. union HB_GSUB_SubTable_
  345. {
  346. HB_SingleSubst single;
  347. HB_MultipleSubst multiple;
  348. HB_AlternateSubst alternate;
  349. HB_LigatureSubst ligature;
  350. HB_ContextSubst context;
  351. HB_ChainContextSubst chain;
  352. HB_ReverseChainContextSubst reverse;
  353. };
  354. HB_INTERNAL HB_Error
  355. _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
  356. HB_Stream stream,
  357. HB_UShort lookup_type );
  358. HB_INTERNAL void
  359. _HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,
  360. HB_UShort lookup_type );
  361. HB_END_HEADER
  362. #endif /* HARFBUZZ_GSUB_PRIVATE_H */