PageRenderTime 52ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/from_google/skia/third_party/harfbuzz/src/harfbuzz-gsub-private.h

https://bitbucket.org/enic/elib
C Header | 476 lines | 266 code | 114 blank | 96 comment | 0 complexity | 0e5f19fed6de3112c16c3c2a00add25b MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, CC-BY-SA-3.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 GlyphCount; /* number of glyph IDs in
  42. Substitute array */
  43. HB_UShort* Substitute; /* array of substitute glyph IDs */
  44. };
  45. typedef struct HB_SingleSubstFormat2_ HB_SingleSubstFormat2;
  46. struct HB_SingleSubst_
  47. {
  48. HB_UShort SubstFormat; /* 1 or 2 */
  49. HB_Coverage Coverage; /* Coverage table */
  50. union
  51. {
  52. HB_SingleSubstFormat1 ssf1;
  53. HB_SingleSubstFormat2 ssf2;
  54. } ssf;
  55. };
  56. typedef struct HB_SingleSubst_ HB_SingleSubst;
  57. /* LookupType 2 */
  58. struct HB_Sequence_
  59. {
  60. HB_UShort GlyphCount; /* number of glyph IDs in the
  61. Substitute array */
  62. HB_UShort* Substitute; /* string of glyph IDs to
  63. substitute */
  64. };
  65. typedef struct HB_Sequence_ HB_Sequence;
  66. struct HB_MultipleSubst_
  67. {
  68. HB_UShort SubstFormat; /* always 1 */
  69. HB_Coverage Coverage; /* Coverage table */
  70. HB_UShort SequenceCount; /* number of Sequence tables */
  71. HB_Sequence* Sequence; /* array of Sequence tables */
  72. };
  73. typedef struct HB_MultipleSubst_ HB_MultipleSubst;
  74. /* LookupType 3 */
  75. struct HB_AlternateSet_
  76. {
  77. HB_UShort GlyphCount; /* number of glyph IDs in the
  78. Alternate array */
  79. HB_UShort* Alternate; /* array of alternate glyph IDs */
  80. };
  81. typedef struct HB_AlternateSet_ HB_AlternateSet;
  82. struct HB_AlternateSubst_
  83. {
  84. HB_UShort SubstFormat; /* always 1 */
  85. HB_Coverage Coverage; /* Coverage table */
  86. HB_UShort AlternateSetCount;
  87. /* number of AlternateSet tables */
  88. HB_AlternateSet* AlternateSet; /* array of AlternateSet tables */
  89. };
  90. typedef struct HB_AlternateSubst_ HB_AlternateSubst;
  91. /* LookupType 4 */
  92. struct HB_Ligature_
  93. {
  94. HB_UShort LigGlyph; /* glyphID of ligature
  95. to substitute */
  96. HB_UShort ComponentCount; /* number of components in ligature */
  97. HB_UShort* Component; /* array of component glyph IDs */
  98. };
  99. typedef struct HB_Ligature_ HB_Ligature;
  100. struct HB_LigatureSet_
  101. {
  102. HB_UShort LigatureCount; /* number of Ligature tables */
  103. HB_Ligature* Ligature; /* array of Ligature tables */
  104. };
  105. typedef struct HB_LigatureSet_ HB_LigatureSet;
  106. struct HB_LigatureSubst_
  107. {
  108. HB_UShort SubstFormat; /* always 1 */
  109. HB_Coverage Coverage; /* Coverage table */
  110. HB_UShort LigatureSetCount; /* number of LigatureSet tables */
  111. HB_LigatureSet* LigatureSet; /* array 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 GlyphCount; /* total number of input glyphs */
  126. HB_UShort SubstCount; /* number of SubstLookupRecord
  127. tables */
  128. HB_UShort* Input; /* array of input glyph IDs */
  129. HB_SubstLookupRecord* SubstLookupRecord;
  130. /* array of SubstLookupRecord
  131. tables */
  132. };
  133. typedef struct HB_SubRule_ HB_SubRule;
  134. struct HB_SubRuleSet_
  135. {
  136. HB_UShort SubRuleCount; /* number of SubRule tables */
  137. HB_SubRule* SubRule; /* array of SubRule tables */
  138. };
  139. typedef struct HB_SubRuleSet_ HB_SubRuleSet;
  140. struct HB_ContextSubstFormat1_
  141. {
  142. HB_Coverage Coverage; /* Coverage table */
  143. HB_UShort SubRuleSetCount; /* number of SubRuleSet tables */
  144. HB_SubRuleSet* SubRuleSet; /* array of SubRuleSet tables */
  145. };
  146. typedef struct HB_ContextSubstFormat1_ HB_ContextSubstFormat1;
  147. struct HB_SubClassRule_
  148. {
  149. HB_UShort GlyphCount; /* total number of context classes */
  150. HB_UShort SubstCount; /* number of SubstLookupRecord
  151. tables */
  152. HB_UShort* Class; /* array of classes */
  153. HB_SubstLookupRecord* SubstLookupRecord;
  154. /* array of SubstLookupRecord
  155. tables */
  156. };
  157. typedef struct HB_SubClassRule_ HB_SubClassRule;
  158. struct HB_SubClassSet_
  159. {
  160. HB_UShort SubClassRuleCount;
  161. /* number of SubClassRule tables */
  162. HB_SubClassRule* SubClassRule; /* array 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_UShort MaxContextLength;
  171. /* maximal context length */
  172. HB_Coverage Coverage; /* Coverage table */
  173. HB_ClassDefinition ClassDef; /* ClassDef table */
  174. HB_UShort SubClassSetCount;
  175. /* number of SubClassSet tables */
  176. HB_SubClassSet* SubClassSet; /* array of SubClassSet tables */
  177. };
  178. typedef struct HB_ContextSubstFormat2_ HB_ContextSubstFormat2;
  179. struct HB_ContextSubstFormat3_
  180. {
  181. HB_UShort GlyphCount; /* number of input glyphs */
  182. HB_UShort SubstCount; /* number of SubstLookupRecords */
  183. HB_Coverage* Coverage; /* array of Coverage tables */
  184. HB_SubstLookupRecord* SubstLookupRecord;
  185. /* array of substitution lookups */
  186. };
  187. typedef struct HB_ContextSubstFormat3_ HB_ContextSubstFormat3;
  188. struct HB_ContextSubst_
  189. {
  190. HB_UShort SubstFormat; /* 1, 2, or 3 */
  191. union
  192. {
  193. HB_ContextSubstFormat1 csf1;
  194. HB_ContextSubstFormat2 csf2;
  195. HB_ContextSubstFormat3 csf3;
  196. } csf;
  197. };
  198. typedef struct HB_ContextSubst_ HB_ContextSubst;
  199. /* LookupType 6 */
  200. struct HB_ChainSubRule_
  201. {
  202. HB_UShort BacktrackGlyphCount;
  203. /* total number of backtrack glyphs */
  204. HB_UShort* Backtrack; /* array of backtrack glyph IDs */
  205. HB_UShort InputGlyphCount;
  206. /* total number of input glyphs */
  207. HB_UShort* Input; /* array of input glyph IDs */
  208. HB_UShort LookaheadGlyphCount;
  209. /* total number of lookahead glyphs */
  210. HB_UShort* Lookahead; /* array of lookahead glyph IDs */
  211. HB_UShort SubstCount; /* number of SubstLookupRecords */
  212. HB_SubstLookupRecord* SubstLookupRecord;
  213. /* array of SubstLookupRecords */
  214. };
  215. typedef struct HB_ChainSubRule_ HB_ChainSubRule;
  216. struct HB_ChainSubRuleSet_
  217. {
  218. HB_UShort ChainSubRuleCount;
  219. /* number of ChainSubRule tables */
  220. HB_ChainSubRule* ChainSubRule; /* array of ChainSubRule tables */
  221. };
  222. typedef struct HB_ChainSubRuleSet_ HB_ChainSubRuleSet;
  223. struct HB_ChainContextSubstFormat1_
  224. {
  225. HB_Coverage Coverage; /* Coverage table */
  226. HB_UShort ChainSubRuleSetCount;
  227. /* number of ChainSubRuleSet tables */
  228. HB_ChainSubRuleSet* ChainSubRuleSet;
  229. /* array of ChainSubRuleSet tables */
  230. };
  231. typedef struct HB_ChainContextSubstFormat1_ HB_ChainContextSubstFormat1;
  232. struct HB_ChainSubClassRule_
  233. {
  234. HB_UShort BacktrackGlyphCount;
  235. /* total number of backtrack
  236. classes */
  237. HB_UShort* Backtrack; /* array of backtrack classes */
  238. HB_UShort InputGlyphCount;
  239. /* total number of context classes */
  240. HB_UShort* Input; /* array of context classes */
  241. HB_UShort LookaheadGlyphCount;
  242. /* total number of lookahead
  243. classes */
  244. HB_UShort* Lookahead; /* array of lookahead classes */
  245. HB_UShort SubstCount; /* number of SubstLookupRecords */
  246. HB_SubstLookupRecord* SubstLookupRecord;
  247. /* array of substitution lookups */
  248. };
  249. typedef struct HB_ChainSubClassRule_ HB_ChainSubClassRule;
  250. struct HB_ChainSubClassSet_
  251. {
  252. HB_UShort ChainSubClassRuleCount;
  253. /* number of ChainSubClassRule
  254. tables */
  255. HB_ChainSubClassRule* ChainSubClassRule;
  256. /* array 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_Coverage Coverage; /* Coverage table */
  266. HB_UShort MaxBacktrackLength;
  267. /* maximal backtrack length */
  268. HB_ClassDefinition BacktrackClassDef;
  269. /* BacktrackClassDef table */
  270. HB_UShort MaxInputLength;
  271. /* maximal input length */
  272. HB_ClassDefinition InputClassDef;
  273. /* InputClassDef table */
  274. HB_UShort MaxLookaheadLength;
  275. /* maximal lookahead length */
  276. HB_ClassDefinition LookaheadClassDef;
  277. /* LookaheadClassDef table */
  278. HB_UShort ChainSubClassSetCount;
  279. /* number of ChainSubClassSet
  280. tables */
  281. HB_ChainSubClassSet* ChainSubClassSet;
  282. /* array of ChainSubClassSet
  283. tables */
  284. };
  285. typedef struct HB_ChainContextSubstFormat2_ HB_ChainContextSubstFormat2;
  286. struct HB_ChainContextSubstFormat3_
  287. {
  288. HB_UShort BacktrackGlyphCount;
  289. /* number of backtrack glyphs */
  290. HB_Coverage* BacktrackCoverage;
  291. /* array of backtrack Coverage
  292. tables */
  293. HB_UShort InputGlyphCount;
  294. /* number of input glyphs */
  295. HB_Coverage* InputCoverage;
  296. /* array of input coverage
  297. tables */
  298. HB_UShort LookaheadGlyphCount;
  299. /* number of lookahead glyphs */
  300. HB_Coverage* LookaheadCoverage;
  301. /* array of lookahead coverage
  302. tables */
  303. HB_UShort SubstCount; /* number of SubstLookupRecords */
  304. HB_SubstLookupRecord* SubstLookupRecord;
  305. /* array of substitution lookups */
  306. };
  307. typedef struct HB_ChainContextSubstFormat3_ HB_ChainContextSubstFormat3;
  308. struct HB_ChainContextSubst_
  309. {
  310. HB_UShort SubstFormat; /* 1, 2, or 3 */
  311. union
  312. {
  313. HB_ChainContextSubstFormat1 ccsf1;
  314. HB_ChainContextSubstFormat2 ccsf2;
  315. HB_ChainContextSubstFormat3 ccsf3;
  316. } ccsf;
  317. };
  318. typedef struct HB_ChainContextSubst_ HB_ChainContextSubst;
  319. #if 0
  320. /* LookupType 7 */
  321. struct HB_ExtensionSubst_
  322. {
  323. HB_UShort SubstFormat; /* always 1 */
  324. HB_UShort LookuptType; /* lookup-type of referenced subtable */
  325. HB_GSUB_SubTable *subtable; /* referenced subtable */
  326. };
  327. typedef struct HB_ExtensionSubst_ HB_ExtensionSubst;
  328. #endif
  329. /* LookupType 8 */
  330. struct HB_ReverseChainContextSubst_
  331. {
  332. HB_UShort SubstFormat; /* always 1 */
  333. HB_Coverage Coverage; /* coverage table for input glyphs */
  334. HB_UShort BacktrackGlyphCount; /* number of backtrack glyphs */
  335. HB_Coverage* BacktrackCoverage; /* array of backtrack Coverage
  336. tables */
  337. HB_UShort LookaheadGlyphCount; /* number of lookahead glyphs */
  338. HB_Coverage* LookaheadCoverage; /* array of lookahead Coverage
  339. tables */
  340. HB_UShort GlyphCount; /* number of Glyph IDs */
  341. HB_UShort* Substitute; /* array of substitute Glyph ID */
  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 */