hb-ot-shape-complex-indic-private.hh revision 6e613f3365bf4e9fd778758c53e7de00c64beca1
13ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod/*
23ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * Copyright © 2012  Google, Inc.
33ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod *
43ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod *  This is part of HarfBuzz, a text shaping library.
53ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod *
63ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * Permission is hereby granted, without written agreement and without
73ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * license or royalty fees, to use, copy, modify, and distribute this
83ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * software and its documentation for any purpose, provided that the
93ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * above copyright notice and the following two paragraphs appear in
103ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * all copies of this software.
113ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod *
123ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
133ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
143ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
153ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
163ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * DAMAGE.
173ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod *
183ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
193ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
203ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
213ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
223ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
233ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod *
243ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * Google Author(s): Behdad Esfahbod
253ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod */
263ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
273ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod#ifndef HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH
283ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod#define HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH
293ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
303ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod#include "hb-private.hh"
313ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
323ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
333ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod#include "hb-ot-shape-complex-private.hh"
343eb6f81fd3f1e56679eec10d08f5e2303121753fBehdad Esfahbod#include "hb-ot-shape-private.hh" /* XXX Remove */
353ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
363ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
37dba186711e3f5e723f917b7104e849c4c525d3b8Behdad Esfahbod#define INDIC_TABLE_ELEMENT_TYPE uint16_t
383ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
393ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod/* Cateories used in the OpenType spec:
403ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx
413ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod */
423ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod/* Note: This enum is duplicated in the -machine.rl source file.
433ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * Not sure how to avoid duplication. */
443ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbodenum indic_category_t {
453ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  OT_X = 0,
46c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_C = 1,
47c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_V = 2,
48c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_N = 3,
49c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_H = 4,
50c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_ZWNJ = 5,
51c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_ZWJ = 6,
52c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_M = 7,
53c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_SM = 8,
54c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_VD = 9,
55c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_A = 10,
56c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_NBSP = 11,
57c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_DOTTEDCIRCLE = 12,
58c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_RS = 13, /* Register Shifter, used in Khmer OT spec. */
59c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_Coeng = 14, /* Khmer-style Virama. */
60c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_Repha = 15, /* Atomically-encoded logical or visual repha. */
61c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_Ra = 16,
62c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_CM = 17,  /* Consonant-Medial. */
63c16012e9019ec59c2200a3cc29b8a37ea70eda70Behdad Esfahbod  OT_Avag = 18, /* Avagraha. */
646e613f3365bf4e9fd778758c53e7de00c64beca1Behdad Esfahbod  OT_CM2 = 31 /* Consonant-Medial, second slot. */
653ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod};
663ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
673ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod/* Visual positions in a syllable from left to right. */
683ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbodenum indic_position_t {
6981202bd860e4034c18d9f80c5a4f33d9f48463a3Behdad Esfahbod  POS_START,
7081202bd860e4034c18d9f80c5a4f33d9f48463a3Behdad Esfahbod
713d25079f8d6be81b9b4b91d3a97016b8a572f571Behdad Esfahbod  POS_RA_TO_BECOME_REPH,
726a091df9b403b147ef78f3974610dedf4ce1e08aBehdad Esfahbod  POS_PRE_M,
73dbccf87eef0d26838fa4bb3ae26410f6c4818836Behdad Esfahbod  POS_PRE_C,
74be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod
75dbccf87eef0d26838fa4bb3ae26410f6c4818836Behdad Esfahbod  POS_BASE_C,
76be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod  POS_AFTER_MAIN,
77be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod
78dbccf87eef0d26838fa4bb3ae26410f6c4818836Behdad Esfahbod  POS_ABOVE_C,
79be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod
80be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod  POS_BEFORE_SUB,
81dbccf87eef0d26838fa4bb3ae26410f6c4818836Behdad Esfahbod  POS_BELOW_C,
82be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod  POS_AFTER_SUB,
83be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod
84be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod  POS_BEFORE_POST,
85dbccf87eef0d26838fa4bb3ae26410f6c4818836Behdad Esfahbod  POS_POST_C,
86be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod  POS_AFTER_POST,
87be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod
8855f70ebfb95083f515d9b0044a2a65ab11484bb5Behdad Esfahbod  POS_FINAL_C,
89be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod  POS_SMVD,
9081202bd860e4034c18d9f80c5a4f33d9f48463a3Behdad Esfahbod
91be8b9f5f715f6fb36b98bd33c3303f79cc068f8aBehdad Esfahbod  POS_END
923ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod};
933ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
94c5306b6861cfaa50af40e8ceb058791fa06d7981Behdad Esfahbod/* Categories used in IndicSyllabicCategory.txt from UCD. */
953ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbodenum indic_syllabic_category_t {
963ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_OTHER			= OT_X,
973ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
983c7b3641cfb00f2c4dcc0768b9854e4f4410d15fBehdad Esfahbod  INDIC_SYLLABIC_CATEGORY_AVAGRAHA		= OT_Avag,
993ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_BINDU			= OT_SM,
1003ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_CONSONANT		= OT_C,
1013ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_CONSONANT_DEAD	= OT_C,
1029e1f80ab3eea4a74cdaa6a390e4925a479ece1c5Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_CONSONANT_FINAL	= OT_CM,
1033ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_CONSONANT_HEAD_LETTER	= OT_C,
1049cac1338c4bc3e9034cbfa104291ed0329debefeBehdad Esfahbod  INDIC_SYLLABIC_CATEGORY_CONSONANT_MEDIAL	= OT_CM,
1053ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_CONSONANT_PLACEHOLDER	= OT_NBSP,
1063756efaf4e14ec3b5b1def700a1b5985f162372bBehdad Esfahbod  INDIC_SYLLABIC_CATEGORY_CONSONANT_SUBJOINED	= OT_CM,
107db8981f1e0e8625714568c6d0f11f0b317b11d0aBehdad Esfahbod  INDIC_SYLLABIC_CATEGORY_CONSONANT_REPHA	= OT_Repha,
1083ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_MODIFYING_LETTER	= OT_X,
1093ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_NUKTA			= OT_N,
1107d09c98a1fff97127e48eae48d380dc9fcff288eBehdad Esfahbod  INDIC_SYLLABIC_CATEGORY_REGISTER_SHIFTER	= OT_RS,
1113ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_TONE_LETTER		= OT_X,
112d187099cbab8e75f870a2bc9c23b6a1cf226905eBehdad Esfahbod  INDIC_SYLLABIC_CATEGORY_TONE_MARK		= OT_N,
1133ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_VIRAMA		= OT_H,
1143ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_VISARGA		= OT_SM,
1153ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_VOWEL			= OT_V,
1163ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT	= OT_M,
1173ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_SYLLABIC_CATEGORY_VOWEL_INDEPENDENT	= OT_V
1183ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod};
1193ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
1203ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod/* Categories used in IndicSMatraCategory.txt from UCD */
1213ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbodenum indic_matra_category_t {
1222ec934c6c25423e7af20d909a9c698a149808ea9Behdad Esfahbod  INDIC_MATRA_CATEGORY_NOT_APPLICABLE		= POS_END,
1233ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
1248bb32458f95f13f66688e0811cc91f1bfffb867dBehdad Esfahbod  INDIC_MATRA_CATEGORY_LEFT			= POS_PRE_C,
1258bb32458f95f13f66688e0811cc91f1bfffb867dBehdad Esfahbod  INDIC_MATRA_CATEGORY_TOP			= POS_ABOVE_C,
1268bb32458f95f13f66688e0811cc91f1bfffb867dBehdad Esfahbod  INDIC_MATRA_CATEGORY_BOTTOM			= POS_BELOW_C,
1278bb32458f95f13f66688e0811cc91f1bfffb867dBehdad Esfahbod  INDIC_MATRA_CATEGORY_RIGHT			= POS_POST_C,
1283ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
129f83aaa3133de5d807be267a100d6a200e8db9017Behdad Esfahbod  /* These should resolve to the position of the last part of the split sequence. */
130f83aaa3133de5d807be267a100d6a200e8db9017Behdad Esfahbod  INDIC_MATRA_CATEGORY_BOTTOM_AND_RIGHT		= INDIC_MATRA_CATEGORY_RIGHT,
131f83aaa3133de5d807be267a100d6a200e8db9017Behdad Esfahbod  INDIC_MATRA_CATEGORY_LEFT_AND_RIGHT		= INDIC_MATRA_CATEGORY_RIGHT,
132f83aaa3133de5d807be267a100d6a200e8db9017Behdad Esfahbod  INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM		= INDIC_MATRA_CATEGORY_BOTTOM,
133f83aaa3133de5d807be267a100d6a200e8db9017Behdad Esfahbod  INDIC_MATRA_CATEGORY_TOP_AND_BOTTOM_AND_RIGHT	= INDIC_MATRA_CATEGORY_RIGHT,
134f83aaa3133de5d807be267a100d6a200e8db9017Behdad Esfahbod  INDIC_MATRA_CATEGORY_TOP_AND_LEFT		= INDIC_MATRA_CATEGORY_TOP,
135f83aaa3133de5d807be267a100d6a200e8db9017Behdad Esfahbod  INDIC_MATRA_CATEGORY_TOP_AND_LEFT_AND_RIGHT	= INDIC_MATRA_CATEGORY_RIGHT,
136f83aaa3133de5d807be267a100d6a200e8db9017Behdad Esfahbod  INDIC_MATRA_CATEGORY_TOP_AND_RIGHT		= INDIC_MATRA_CATEGORY_RIGHT,
1373ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
1383ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  INDIC_MATRA_CATEGORY_INVISIBLE		= INDIC_MATRA_CATEGORY_NOT_APPLICABLE,
139e67072bb179a5c17db04075de74215597fb43c82Behdad Esfahbod  INDIC_MATRA_CATEGORY_OVERSTRUCK		= POS_AFTER_MAIN,
140e67072bb179a5c17db04075de74215597fb43c82Behdad Esfahbod  INDIC_MATRA_CATEGORY_VISUAL_ORDER_LEFT	= POS_PRE_M
1413ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod};
1423ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
1433ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod/* Note: We use ASSERT_STATIC_EXPR_ZERO() instead of ASSERT_STATIC_EXPR() and the comma operation
1443ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod * because gcc fails to optimize the latter and fills the table in at runtime. */
1453ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod#define INDIC_COMBINE_CATEGORIES(S,M) \
1463ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod  (ASSERT_STATIC_EXPR_ZERO (M == INDIC_MATRA_CATEGORY_NOT_APPLICABLE || (S == INDIC_SYLLABIC_CATEGORY_VIRAMA || S == INDIC_SYLLABIC_CATEGORY_VOWEL_DEPENDENT)) + \
147dba186711e3f5e723f917b7104e849c4c525d3b8Behdad Esfahbod   ASSERT_STATIC_EXPR_ZERO (S < 255 && M < 255) + \
148dba186711e3f5e723f917b7104e849c4c525d3b8Behdad Esfahbod   ((M << 8) | S))
1493ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
1503a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad EsfahbodHB_INTERNAL INDIC_TABLE_ELEMENT_TYPE
1513a83d33ec0b1be6f5992816ff5ebb0f43c8dff00Behdad Esfahbodhb_indic_get_categories (hb_codepoint_t u);
1523ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod
1533ed4634ec349fa9e943ad23718c04be4dd4bba62Behdad Esfahbod#endif /* HB_OT_SHAPE_COMPLEX_INDIC_PRIVATE_HH */
154