Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-unicode.c

Issue 9223010: Update harfbuzz-ng to 1a5a91dc0d8bf4b72a2f22dc6300b06ad7000b79. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't use -M option for 'git diff' to patch correctly Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-unicode.h ('k') | third_party/harfbuzz-ng/src/hb-unicode.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2009 Red Hat, Inc.
3 *
4 * This is part of HarfBuzz, a text shaping library.
5 *
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.
11 *
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
16 * DAMAGE.
17 *
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.
23 *
24 * Red Hat Author(s): Behdad Esfahbod
25 */
26
27 #include "hb-private.h"
28
29 #include "hb-unicode-private.h"
30
31 HB_BEGIN_DECLS
32
33
34 /*
35 * hb_unicode_funcs_t
36 */
37
38 static hb_codepoint_t hb_unicode_get_mirroring_nil (hb_codepoint_t unicode) { re turn unicode; }
39 static hb_category_t hb_unicode_get_general_category_nil (hb_codepoint_t unicode HB_UNUSED) { return HB_CATEGORY_OTHER_LETTER; }
40 static hb_script_t hb_unicode_get_script_nil (hb_codepoint_t unicode HB_UNUSED) { return HB_SCRIPT_UNKNOWN; }
41 static unsigned int hb_unicode_get_combining_class_nil (hb_codepoint_t unicode H B_UNUSED) { return 0; }
42 static unsigned int hb_unicode_get_eastasian_width_nil (hb_codepoint_t unicode H B_UNUSED) { return 1; }
43
44 hb_unicode_funcs_t _hb_unicode_funcs_nil = {
45 HB_REFERENCE_COUNT_INVALID, /* ref_count */
46 TRUE, /* immutable */
47 {
48 hb_unicode_get_general_category_nil,
49 hb_unicode_get_combining_class_nil,
50 hb_unicode_get_mirroring_nil,
51 hb_unicode_get_script_nil,
52 hb_unicode_get_eastasian_width_nil
53 }
54 };
55
56 hb_unicode_funcs_t *
57 hb_unicode_funcs_create (void)
58 {
59 hb_unicode_funcs_t *ufuncs;
60
61 if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs))
62 return &_hb_unicode_funcs_nil;
63
64 ufuncs->v = _hb_unicode_funcs_nil.v;
65
66 return ufuncs;
67 }
68
69 hb_unicode_funcs_t *
70 hb_unicode_funcs_reference (hb_unicode_funcs_t *ufuncs)
71 {
72 HB_OBJECT_DO_REFERENCE (ufuncs);
73 }
74
75 unsigned int
76 hb_unicode_funcs_get_reference_count (hb_unicode_funcs_t *ufuncs)
77 {
78 HB_OBJECT_DO_GET_REFERENCE_COUNT (ufuncs);
79 }
80
81 void
82 hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
83 {
84 HB_OBJECT_DO_DESTROY (ufuncs);
85
86 free (ufuncs);
87 }
88
89 hb_unicode_funcs_t *
90 hb_unicode_funcs_copy (hb_unicode_funcs_t *other_ufuncs)
91 {
92 hb_unicode_funcs_t *ufuncs;
93
94 if (!HB_OBJECT_DO_CREATE (hb_unicode_funcs_t, ufuncs))
95 return &_hb_unicode_funcs_nil;
96
97 ufuncs->v = other_ufuncs->v;
98
99 return ufuncs;
100 }
101
102 void
103 hb_unicode_funcs_make_immutable (hb_unicode_funcs_t *ufuncs)
104 {
105 if (HB_OBJECT_IS_INERT (ufuncs))
106 return;
107
108 ufuncs->immutable = TRUE;
109 }
110
111 hb_bool_t
112 hb_unicode_funcs_is_immutable (hb_unicode_funcs_t *ufuncs)
113 {
114 return ufuncs->immutable;
115 }
116
117
118 void
119 hb_unicode_funcs_set_mirroring_func (hb_unicode_funcs_t *ufuncs,
120 hb_unicode_get_mirroring_func_t mirroring_f unc)
121 {
122 if (ufuncs->immutable)
123 return;
124
125 ufuncs->v.get_mirroring = mirroring_func ? mirroring_func : hb_unicode_get_mir roring_nil;
126 }
127
128 void
129 hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,
130 hb_unicode_get_general_category_func _t general_category_func)
131 {
132 if (ufuncs->immutable)
133 return;
134
135 ufuncs->v.get_general_category = general_category_func ? general_category_func : hb_unicode_get_general_category_nil;
136 }
137
138 void
139 hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs,
140 hb_unicode_get_script_func_t script_func)
141 {
142 if (ufuncs->immutable)
143 return;
144
145 ufuncs->v.get_script = script_func ? script_func : hb_unicode_get_script_nil;
146 }
147
148 void
149 hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
150 hb_unicode_get_combining_class_func_t combining_class_func)
151 {
152 if (ufuncs->immutable)
153 return;
154
155 ufuncs->v.get_combining_class = combining_class_func ? combining_class_func : hb_unicode_get_combining_class_nil;
156 }
157
158 void
159 hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
160 hb_unicode_get_eastasian_width_func_t eastasian_width_func)
161 {
162 if (ufuncs->immutable)
163 return;
164
165 ufuncs->v.get_eastasian_width = eastasian_width_func ? eastasian_width_func : hb_unicode_get_eastasian_width_nil;
166 }
167
168
169 hb_unicode_get_mirroring_func_t
170 hb_unicode_funcs_get_mirroring_func (hb_unicode_funcs_t *ufuncs)
171 {
172 return ufuncs->v.get_mirroring;
173 }
174
175 hb_unicode_get_general_category_func_t
176 hb_unicode_funcs_get_general_category_func (hb_unicode_funcs_t *ufuncs)
177 {
178 return ufuncs->v.get_general_category;
179 }
180
181 hb_unicode_get_script_func_t
182 hb_unicode_funcs_get_script_func (hb_unicode_funcs_t *ufuncs)
183 {
184 return ufuncs->v.get_script;
185 }
186
187 hb_unicode_get_combining_class_func_t
188 hb_unicode_funcs_get_combining_class_func (hb_unicode_funcs_t *ufuncs)
189 {
190 return ufuncs->v.get_combining_class;
191 }
192
193 hb_unicode_get_eastasian_width_func_t
194 hb_unicode_funcs_get_eastasian_width_func (hb_unicode_funcs_t *ufuncs)
195 {
196 return ufuncs->v.get_eastasian_width;
197 }
198
199
200
201 hb_codepoint_t
202 hb_unicode_get_mirroring (hb_unicode_funcs_t *ufuncs,
203 hb_codepoint_t unicode)
204 {
205 return ufuncs->v.get_mirroring (unicode);
206 }
207
208 hb_category_t
209 hb_unicode_get_general_category (hb_unicode_funcs_t *ufuncs,
210 hb_codepoint_t unicode)
211 {
212 return ufuncs->v.get_general_category (unicode);
213 }
214
215 hb_script_t
216 hb_unicode_get_script (hb_unicode_funcs_t *ufuncs,
217 hb_codepoint_t unicode)
218 {
219 return ufuncs->v.get_script (unicode);
220 }
221
222 unsigned int
223 hb_unicode_get_combining_class (hb_unicode_funcs_t *ufuncs,
224 hb_codepoint_t unicode)
225 {
226 return ufuncs->v.get_combining_class (unicode);
227 }
228
229 unsigned int
230 hb_unicode_get_eastasian_width (hb_unicode_funcs_t *ufuncs,
231 hb_codepoint_t unicode)
232 {
233 return ufuncs->v.get_eastasian_width (unicode);
234 }
235
236
237
238 #define LTR HB_DIRECTION_LTR
239 #define RTL HB_DIRECTION_RTL
240 const hb_direction_t horiz_dir[] =
241 {
242 LTR, /* Zyyy */
243 LTR, /* Qaai */
244 RTL, /* Arab */
245 LTR, /* Armn */
246 LTR, /* Beng */
247 LTR, /* Bopo */
248 LTR, /* Cher */
249 LTR, /* Qaac */
250 LTR, /* Cyrl (Cyrs) */
251 LTR, /* Dsrt */
252 LTR, /* Deva */
253 LTR, /* Ethi */
254 LTR, /* Geor (Geon, Geoa) */
255 LTR, /* Goth */
256 LTR, /* Grek */
257 LTR, /* Gujr */
258 LTR, /* Guru */
259 LTR, /* Hani */
260 LTR, /* Hang */
261 RTL, /* Hebr */
262 LTR, /* Hira */
263 LTR, /* Knda */
264 LTR, /* Kana */
265 LTR, /* Khmr */
266 LTR, /* Laoo */
267 LTR, /* Latn (Latf, Latg) */
268 LTR, /* Mlym */
269 LTR, /* Mong */
270 LTR, /* Mymr */
271 LTR, /* Ogam */
272 LTR, /* Ital */
273 LTR, /* Orya */
274 LTR, /* Runr */
275 LTR, /* Sinh */
276 RTL, /* Syrc (Syrj, Syrn, Syre) */
277 LTR, /* Taml */
278 LTR, /* Telu */
279 RTL, /* Thaa */
280 LTR, /* Thai */
281 LTR, /* Tibt */
282 LTR, /* Cans */
283 LTR, /* Yiii */
284 LTR, /* Tglg */
285 LTR, /* Hano */
286 LTR, /* Buhd */
287 LTR, /* Tagb */
288
289 /* Unicode-4.0 additions */
290 LTR, /* Brai */
291 RTL, /* Cprt */
292 LTR, /* Limb */
293 LTR, /* Osma */
294 LTR, /* Shaw */
295 LTR, /* Linb */
296 LTR, /* Tale */
297 LTR, /* Ugar */
298
299 /* Unicode-4.1 additions */
300 LTR, /* Talu */
301 LTR, /* Bugi */
302 LTR, /* Glag */
303 LTR, /* Tfng */
304 LTR, /* Sylo */
305 LTR, /* Xpeo */
306 LTR, /* Khar */
307
308 /* Unicode-5.0 additions */
309 LTR, /* Zzzz */
310 LTR, /* Bali */
311 LTR, /* Xsux */
312 RTL, /* Phnx */
313 LTR, /* Phag */
314 RTL, /* Nkoo */
315
316 /* Unicode-5.1 additions */
317 LTR, /* Kali */
318 LTR, /* Lepc */
319 LTR, /* Rjng */
320 LTR, /* Sund */
321 LTR, /* Saur */
322 LTR, /* Cham */
323 LTR, /* Olck */
324 LTR, /* Vaii */
325 LTR, /* Cari */
326 LTR, /* Lyci */
327 LTR, /* Lydi */
328
329 /* Unicode-5.2 additions */
330 RTL, /* Avst */
331 LTR, /* Bamu */
332 LTR, /* Egyp */
333 RTL, /* Armi */
334 RTL, /* Phli */
335 RTL, /* Prti */
336 LTR, /* Java */
337 LTR, /* Kthi */
338 LTR, /* Lisu */
339 LTR, /* Mtei */
340 RTL, /* Sarb */
341 RTL, /* Orkh */
342 RTL, /* Samr */
343 LTR, /* Lana */
344 LTR, /* Tavt */
345
346 /* Unicode-6.0 additions */
347 LTR, /* Batk */
348 LTR, /* Brah */
349 RTL /* Mand */
350 };
351 #undef LTR
352 #undef RTL
353
354 hb_direction_t
355 _hb_script_get_horizontal_direction (hb_script_t script)
356 {
357 if (unlikely ((unsigned int) script >= ARRAY_LENGTH (horiz_dir)))
358 return HB_DIRECTION_LTR;
359
360 return horiz_dir[script];
361 }
362
363
364 HB_END_DECLS
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-unicode.h ('k') | third_party/harfbuzz-ng/src/hb-unicode.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698