PageRenderTime 41ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/harfbuzz/src/hb-old/harfbuzz-gsub-private.h

http://github.com/brson/rust-harfbuzz
C Header | 483 lines | 272 code | 115 blank | 96 comment | 0 complexity | 9dacc401aece0b6f90f8f60b480a66a1 MD5 | raw file
Possible License(s): Apache-2.0, MIT
  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. #ifdef HB_USE_PACKED_STRUCTS
  32. #pragma pack(push, 1)
  33. #endif
  34. typedef union HB_GSUB_SubTable_ HB_GSUB_SubTable;
  35. /* LookupType 1 */
  36. struct HB_SingleSubstFormat1_
  37. {
  38. HB_Short DeltaGlyphID; /* constant added to get
  39. substitution glyph index */
  40. };
  41. typedef struct HB_SingleSubstFormat1_ HB_SingleSubstFormat1;
  42. struct HB_SingleSubstFormat2_
  43. {
  44. HB_UShort* Substitute; /* array of substitute glyph IDs */
  45. HB_UShort GlyphCount; /* number of glyph IDs in
  46. Substitute array */
  47. };
  48. typedef struct HB_SingleSubstFormat2_ HB_SingleSubstFormat2;
  49. struct HB_SingleSubst_
  50. {
  51. union
  52. {
  53. HB_SingleSubstFormat1 ssf1;
  54. HB_SingleSubstFormat2 ssf2;
  55. } ssf;
  56. HB_Coverage Coverage; /* Coverage table */
  57. HB_Byte SubstFormat; /* 1 or 2 */
  58. };
  59. typedef struct HB_SingleSubst_ HB_SingleSubst;
  60. /* LookupType 2 */
  61. struct HB_Sequence_
  62. {
  63. HB_UShort* Substitute; /* string of glyph IDs to
  64. substitute */
  65. HB_UShort GlyphCount; /* number of glyph IDs in the
  66. Substitute array */
  67. };
  68. typedef struct HB_Sequence_ HB_Sequence;
  69. struct HB_MultipleSubst_
  70. {
  71. HB_Sequence* Sequence; /* array of Sequence tables */
  72. HB_Coverage Coverage; /* Coverage table */
  73. HB_UShort SubstFormat; /* always 1 */
  74. HB_UShort SequenceCount; /* number of Sequence tables */
  75. };
  76. typedef struct HB_MultipleSubst_ HB_MultipleSubst;
  77. /* LookupType 3 */
  78. struct HB_AlternateSet_
  79. {
  80. HB_UShort* Alternate; /* array of alternate glyph IDs */
  81. HB_UShort GlyphCount; /* number of glyph IDs in the
  82. Alternate array */
  83. };
  84. typedef struct HB_AlternateSet_ HB_AlternateSet;
  85. struct HB_AlternateSubst_
  86. {
  87. HB_AlternateSet* AlternateSet; /* array of AlternateSet tables */
  88. HB_Coverage Coverage; /* Coverage table */
  89. HB_UShort SubstFormat; /* always 1 */
  90. HB_UShort AlternateSetCount;
  91. /* number of AlternateSet tables */
  92. };
  93. typedef struct HB_AlternateSubst_ HB_AlternateSubst;
  94. /* LookupType 4 */
  95. struct HB_Ligature_
  96. {
  97. HB_UShort* Component; /* array of component glyph IDs */
  98. HB_UShort LigGlyph; /* glyphID of ligature
  99. to substitute */
  100. HB_UShort ComponentCount; /* number of components in ligature */
  101. };
  102. typedef struct HB_Ligature_ HB_Ligature;
  103. struct HB_LigatureSet_
  104. {
  105. HB_Ligature* Ligature; /* array of Ligature tables */
  106. HB_UShort LigatureCount; /* number of Ligature tables */
  107. };
  108. typedef struct HB_LigatureSet_ HB_LigatureSet;
  109. struct HB_LigatureSubst_
  110. {
  111. HB_LigatureSet* LigatureSet; /* array of LigatureSet tables */
  112. HB_Coverage Coverage; /* Coverage table */
  113. HB_UShort SubstFormat; /* always 1 */
  114. HB_UShort LigatureSetCount; /* number of LigatureSet tables */
  115. };
  116. typedef struct HB_LigatureSubst_ HB_LigatureSubst;
  117. /* needed by both lookup type 5 and 6 */
  118. struct HB_SubstLookupRecord_
  119. {
  120. HB_UShort SequenceIndex; /* index into current
  121. glyph sequence */
  122. HB_UShort LookupListIndex; /* Lookup to apply to that pos. */
  123. };
  124. typedef struct HB_SubstLookupRecord_ HB_SubstLookupRecord;
  125. /* LookupType 5 */
  126. struct HB_SubRule_
  127. {
  128. HB_UShort* Input; /* array of input glyph IDs */
  129. HB_SubstLookupRecord* SubstLookupRecord;
  130. /* array of SubstLookupRecord
  131. tables */
  132. HB_UShort GlyphCount; /* total number of input glyphs */
  133. HB_UShort SubstCount; /* number of SubstLookupRecord
  134. tables */
  135. };
  136. typedef struct HB_SubRule_ HB_SubRule;
  137. struct HB_SubRuleSet_
  138. {
  139. HB_SubRule* SubRule; /* array of SubRule tables */
  140. HB_UShort SubRuleCount; /* number of SubRule tables */
  141. };
  142. typedef struct HB_SubRuleSet_ HB_SubRuleSet;
  143. struct HB_ContextSubstFormat1_
  144. {
  145. HB_SubRuleSet* SubRuleSet; /* array of SubRuleSet tables */
  146. HB_Coverage Coverage; /* Coverage table */
  147. HB_UShort SubRuleSetCount; /* number of SubRuleSet tables */
  148. };
  149. typedef struct HB_ContextSubstFormat1_ HB_ContextSubstFormat1;
  150. struct HB_SubClassRule_
  151. {
  152. HB_UShort* Class; /* array of classes */
  153. HB_SubstLookupRecord* SubstLookupRecord;
  154. /* array of SubstLookupRecord
  155. tables */
  156. HB_UShort GlyphCount; /* total number of context classes */
  157. HB_UShort SubstCount; /* number of SubstLookupRecord
  158. tables */
  159. };
  160. typedef struct HB_SubClassRule_ HB_SubClassRule;
  161. struct HB_SubClassSet_
  162. {
  163. HB_SubClassRule* SubClassRule; /* array of SubClassRule tables */
  164. HB_UShort SubClassRuleCount;
  165. /* number of SubClassRule tables */
  166. };
  167. typedef struct HB_SubClassSet_ HB_SubClassSet;
  168. /* The `MaxContextLength' field is not defined in the TTO specification
  169. but simplifies the implementation of this format. It holds the
  170. maximal context length used in the context rules. */
  171. struct HB_ContextSubstFormat2_
  172. {
  173. HB_SubClassSet* SubClassSet; /* array of SubClassSet tables */
  174. HB_Coverage Coverage; /* Coverage table */
  175. HB_ClassDefinition ClassDef; /* ClassDef table */
  176. HB_UShort SubClassSetCount;
  177. /* number of SubClassSet tables */
  178. HB_UShort MaxContextLength;
  179. /* maximal context length */
  180. };
  181. typedef struct HB_ContextSubstFormat2_ HB_ContextSubstFormat2;
  182. struct HB_ContextSubstFormat3_
  183. {
  184. HB_Coverage* Coverage; /* array of Coverage tables */
  185. HB_SubstLookupRecord* SubstLookupRecord;
  186. /* array of substitution lookups */
  187. HB_UShort GlyphCount; /* number of input glyphs */
  188. HB_UShort SubstCount; /* number of SubstLookupRecords */
  189. };
  190. typedef struct HB_ContextSubstFormat3_ HB_ContextSubstFormat3;
  191. struct HB_ContextSubst_
  192. {
  193. union
  194. {
  195. HB_ContextSubstFormat1 csf1;
  196. HB_ContextSubstFormat2 csf2;
  197. HB_ContextSubstFormat3 csf3;
  198. } csf;
  199. HB_Byte SubstFormat; /* 1, 2, or 3 */
  200. };
  201. typedef struct HB_ContextSubst_ HB_ContextSubst;
  202. /* LookupType 6 */
  203. struct HB_ChainSubRule_
  204. {
  205. HB_UShort* Backtrack; /* array of backtrack glyph IDs */
  206. HB_UShort* Input; /* array of input glyph IDs */
  207. HB_UShort* Lookahead; /* array of lookahead glyph IDs */
  208. HB_SubstLookupRecord* SubstLookupRecord;
  209. /* array of SubstLookupRecords */
  210. HB_UShort BacktrackGlyphCount;
  211. /* total number of backtrack glyphs */
  212. HB_UShort InputGlyphCount;
  213. /* total number of input glyphs */
  214. HB_UShort LookaheadGlyphCount;
  215. /* total number of lookahead glyphs */
  216. HB_UShort SubstCount; /* number of SubstLookupRecords */
  217. };
  218. typedef struct HB_ChainSubRule_ HB_ChainSubRule;
  219. struct HB_ChainSubRuleSet_
  220. {
  221. HB_ChainSubRule* ChainSubRule; /* array of ChainSubRule tables */
  222. HB_UShort ChainSubRuleCount;
  223. /* number of ChainSubRule tables */
  224. };
  225. typedef struct HB_ChainSubRuleSet_ HB_ChainSubRuleSet;
  226. struct HB_ChainContextSubstFormat1_
  227. {
  228. HB_ChainSubRuleSet* ChainSubRuleSet;
  229. /* array of ChainSubRuleSet tables */
  230. HB_Coverage Coverage; /* Coverage table */
  231. HB_UShort ChainSubRuleSetCount;
  232. /* number of ChainSubRuleSet tables */
  233. };
  234. typedef struct HB_ChainContextSubstFormat1_ HB_ChainContextSubstFormat1;
  235. struct HB_ChainSubClassRule_
  236. {
  237. HB_UShort* Backtrack; /* array of backtrack classes */
  238. HB_UShort* Input; /* array of context classes */
  239. HB_UShort* Lookahead; /* array of lookahead classes */
  240. HB_SubstLookupRecord* SubstLookupRecord;
  241. /* array of substitution lookups */
  242. HB_UShort BacktrackGlyphCount;
  243. /* total number of backtrack
  244. classes */
  245. HB_UShort InputGlyphCount;
  246. /* total number of context classes */
  247. HB_UShort LookaheadGlyphCount;
  248. /* total number of lookahead
  249. classes */
  250. HB_UShort SubstCount; /* number of SubstLookupRecords */
  251. };
  252. typedef struct HB_ChainSubClassRule_ HB_ChainSubClassRule;
  253. struct HB_ChainSubClassSet_
  254. {
  255. HB_ChainSubClassRule* ChainSubClassRule;
  256. /* array of ChainSubClassRule
  257. tables */
  258. HB_UShort ChainSubClassRuleCount;
  259. /* number of ChainSubClassRule
  260. tables */
  261. };
  262. typedef struct HB_ChainSubClassSet_ HB_ChainSubClassSet;
  263. /* The `MaxXXXLength' fields are not defined in the TTO specification
  264. but simplifies the implementation of this format. It holds the
  265. maximal context length used in the specific context rules. */
  266. struct HB_ChainContextSubstFormat2_
  267. {
  268. HB_ChainSubClassSet* ChainSubClassSet;
  269. /* array of ChainSubClassSet
  270. tables */
  271. HB_Coverage Coverage; /* Coverage table */
  272. HB_ClassDefinition BacktrackClassDef;
  273. /* BacktrackClassDef table */
  274. HB_ClassDefinition InputClassDef;
  275. /* InputClassDef table */
  276. HB_ClassDefinition LookaheadClassDef;
  277. /* LookaheadClassDef table */
  278. HB_UShort ChainSubClassSetCount;
  279. /* number of ChainSubClassSet
  280. tables */
  281. HB_UShort MaxBacktrackLength;
  282. /* maximal backtrack length */
  283. HB_UShort MaxLookaheadLength;
  284. /* maximal lookahead length */
  285. HB_UShort MaxInputLength;
  286. /* maximal input length */
  287. };
  288. typedef struct HB_ChainContextSubstFormat2_ HB_ChainContextSubstFormat2;
  289. struct HB_ChainContextSubstFormat3_
  290. {
  291. HB_Coverage* BacktrackCoverage;
  292. /* array of backtrack Coverage
  293. tables */
  294. HB_Coverage* InputCoverage;
  295. /* array of input coverage
  296. tables */
  297. HB_Coverage* LookaheadCoverage;
  298. /* array of lookahead coverage
  299. tables */
  300. HB_SubstLookupRecord* SubstLookupRecord;
  301. /* array of substitution lookups */
  302. HB_UShort BacktrackGlyphCount;
  303. /* number of backtrack glyphs */
  304. HB_UShort InputGlyphCount;
  305. /* number of input glyphs */
  306. HB_UShort LookaheadGlyphCount;
  307. /* number of lookahead glyphs */
  308. HB_UShort SubstCount; /* number of SubstLookupRecords */
  309. };
  310. typedef struct HB_ChainContextSubstFormat3_ HB_ChainContextSubstFormat3;
  311. struct HB_ChainContextSubst_
  312. {
  313. union
  314. {
  315. HB_ChainContextSubstFormat1 ccsf1;
  316. HB_ChainContextSubstFormat2 ccsf2;
  317. HB_ChainContextSubstFormat3 ccsf3;
  318. } ccsf;
  319. HB_Byte SubstFormat; /* 1, 2, or 3 */
  320. };
  321. typedef struct HB_ChainContextSubst_ HB_ChainContextSubst;
  322. #if 0
  323. /* LookupType 7 */
  324. struct HB_ExtensionSubst_
  325. {
  326. HB_GSUB_SubTable *subtable; /* referenced subtable */
  327. HB_UShort SubstFormat; /* always 1 */
  328. HB_UShort LookuptType; /* lookup-type of referenced subtable */
  329. };
  330. typedef struct HB_ExtensionSubst_ HB_ExtensionSubst;
  331. #endif
  332. /* LookupType 8 */
  333. struct HB_ReverseChainContextSubst_
  334. {
  335. HB_Coverage* LookaheadCoverage; /* array of lookahead Coverage
  336. tables */
  337. HB_UShort* Substitute; /* array of substitute Glyph ID */
  338. HB_Coverage* BacktrackCoverage; /* array of backtrack Coverage
  339. tables */
  340. HB_Coverage Coverage; /* coverage table for input glyphs */
  341. HB_UShort SubstFormat; /* always 1 */
  342. HB_UShort BacktrackGlyphCount; /* number of backtrack glyphs */
  343. HB_UShort LookaheadGlyphCount; /* number of lookahead glyphs */
  344. HB_UShort GlyphCount; /* number of Glyph IDs */
  345. };
  346. typedef struct HB_ReverseChainContextSubst_ HB_ReverseChainContextSubst;
  347. union HB_GSUB_SubTable_
  348. {
  349. HB_SingleSubst single;
  350. HB_MultipleSubst multiple;
  351. HB_AlternateSubst alternate;
  352. HB_LigatureSubst ligature;
  353. HB_ContextSubst context;
  354. HB_ChainContextSubst chain;
  355. HB_ReverseChainContextSubst reverse;
  356. };
  357. HB_INTERNAL HB_Error
  358. _HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
  359. HB_Stream stream,
  360. HB_UShort lookup_type );
  361. HB_INTERNAL void
  362. _HB_GSUB_Free_SubTable( HB_GSUB_SubTable* st,
  363. HB_UShort lookup_type );
  364. #ifdef HB_USE_PACKED_STRUCTS
  365. #pragma pack(pop)
  366. #endif
  367. HB_END_HEADER
  368. #endif /* HARFBUZZ_GSUB_PRIVATE_H */