2 * Copyright © 2010,2012 Google, Inc.
4 * This is part of HarfBuzz, a text shaping library.
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24 * Google Author(s): Behdad Esfahbod
27 #include "hb-ot-shape-complex-private.hh"
30 /* TODO Add kana, and other small shapers here */
33 /* The default shaper *only* adds additional per-script features.*/
35 static const hb_tag_t hangul_features
[] =
37 HB_TAG('l','j','m','o'),
38 HB_TAG('v','j','m','o'),
39 HB_TAG('t','j','m','o'),
43 static const hb_tag_t tibetan_features
[] =
45 HB_TAG('a','b','v','s'),
46 HB_TAG('b','l','w','s'),
47 HB_TAG('a','b','v','m'),
48 HB_TAG('b','l','w','m'),
53 collect_features_default (hb_ot_shape_planner_t
*plan
)
55 const hb_tag_t
*script_features
= NULL
;
57 switch ((hb_tag_t
) plan
->props
.script
)
59 /* Unicode-1.1 additions */
60 case HB_SCRIPT_HANGUL
:
61 script_features
= hangul_features
;
64 /* Unicode-2.0 additions */
65 case HB_SCRIPT_TIBETAN
:
66 script_features
= tibetan_features
;
70 for (; script_features
&& *script_features
; script_features
++)
71 plan
->map
.add_global_bool_feature (*script_features
);
74 static hb_ot_shape_normalization_mode_t
75 normalization_preference_default (const hb_segment_properties_t
*props
)
77 return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS
;
81 compose_default (const hb_ot_shape_normalize_context_t
*c
,
86 /* Hebrew presentation-form shaping.
87 * https://bugzilla.mozilla.org/show_bug.cgi?id=728866
88 * Hebrew presentation forms with dagesh, for characters 0x05D0..0x05EA;
89 * Note that some letters do not have a dagesh presForm encoded.
91 static const hb_codepoint_t sDageshForms
[0x05EA - 0x05D0 + 1] = {
102 0xFB3A, /* FINAL KAF */
105 0x0000, /* FINAL MEM */
107 0x0000, /* FINAL NUN */
111 0xFB43, /* FINAL PE */
113 0x0000, /* FINAL TSADI */
121 bool found
= c
->unicode
->compose (a
, b
, ab
);
123 if (!found
&& (b
& ~0x7F) == 0x0580) {
124 /* Special-case Hebrew presentation forms that are excluded from
125 * standard normalization, but wanted for old fonts. */
127 case 0x05B4: /* HIRIQ */
128 if (a
== 0x05D9) { /* YOD */
133 case 0x05B7: /* patah */
134 if (a
== 0x05F2) { /* YIDDISH YOD YOD */
137 } else if (a
== 0x05D0) { /* ALEF */
142 case 0x05B8: /* QAMATS */
143 if (a
== 0x05D0) { /* ALEF */
148 case 0x05B9: /* HOLAM */
149 if (a
== 0x05D5) { /* VAV */
154 case 0x05BC: /* DAGESH */
155 if (a
>= 0x05D0 && a
<= 0x05EA) {
156 *ab
= sDageshForms
[a
- 0x05D0];
158 } else if (a
== 0xFB2A) { /* SHIN WITH SHIN DOT */
161 } else if (a
== 0xFB2B) { /* SHIN WITH SIN DOT */
166 case 0x05BF: /* RAFE */
168 case 0x05D1: /* BET */
172 case 0x05DB: /* KAF */
176 case 0x05E4: /* PE */
182 case 0x05C1: /* SHIN DOT */
183 if (a
== 0x05E9) { /* SHIN */
186 } else if (a
== 0xFB49) { /* SHIN WITH DAGESH */
191 case 0x05C2: /* SIN DOT */
192 if (a
== 0x05E9) { /* SHIN */
195 } else if (a
== 0xFB49) { /* SHIN WITH DAGESH */
206 const hb_ot_complex_shaper_t _hb_ot_complex_shaper_default
=
209 collect_features_default
,
210 NULL
, /* override_features */
211 NULL
, /* data_create */
212 NULL
, /* data_destroy */
213 NULL
, /* preprocess_text */
214 normalization_preference_default
,
215 NULL
, /* decompose */
217 NULL
, /* setup_masks */
218 HB_OT_SHAPE_ZERO_WIDTH_MARKS_BY_UNICODE_LATE
,
219 true, /* fallback_position */