OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2010 Google, Inc. | 2 * Copyright © 2010 Google, Inc. |
3 * | 3 * |
4 * This is part of HarfBuzz, a text shaping library. | 4 * This is part of HarfBuzz, a text shaping library. |
5 * | 5 * |
6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
10 * all copies of this software. | 10 * all copies of this software. |
(...skipping 11 matching lines...) Expand all Loading... |
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
23 * | 23 * |
24 * Google Author(s): Behdad Esfahbod | 24 * Google Author(s): Behdad Esfahbod |
25 */ | 25 */ |
26 | 26 |
27 #ifndef HB_OT_SHAPE_PRIVATE_HH | 27 #ifndef HB_OT_SHAPE_PRIVATE_HH |
28 #define HB_OT_SHAPE_PRIVATE_HH | 28 #define HB_OT_SHAPE_PRIVATE_HH |
29 | 29 |
30 #include "hb-private.hh" | 30 #include "hb-private.hh" |
31 | 31 |
32 #include "hb-ot-shape.h" | |
33 | |
34 #include "hb-ot-map-private.hh" | 32 #include "hb-ot-map-private.hh" |
35 #include "hb-ot-shape-complex-private.hh" | 33 #include "hb-ot-shape-complex-private.hh" |
36 | 34 |
37 | 35 |
38 | |
39 enum hb_ot_complex_shaper_t; | |
40 | |
41 struct hb_ot_shape_plan_t | 36 struct hb_ot_shape_plan_t |
42 { | 37 { |
43 friend struct hb_ot_shape_planner_t; | |
44 | |
45 hb_ot_map_t map; | 38 hb_ot_map_t map; |
46 hb_ot_complex_shaper_t shaper; | 39 hb_ot_complex_shaper_t shaper; |
47 | 40 |
48 hb_ot_shape_plan_t (void) : map () {} | 41 hb_ot_shape_plan_t (void) : map () {} |
49 ~hb_ot_shape_plan_t (void) { map.finish (); } | 42 ~hb_ot_shape_plan_t (void) { map.finish (); } |
50 | 43 |
51 private: | 44 private: |
52 NO_COPY (hb_ot_shape_plan_t); | 45 NO_COPY (hb_ot_shape_plan_t); |
53 }; | 46 }; |
54 | 47 |
55 struct hb_ot_shape_planner_t | |
56 { | |
57 hb_ot_map_builder_t map; | |
58 hb_ot_complex_shaper_t shaper; | |
59 | |
60 hb_ot_shape_planner_t (void) : map () {} | |
61 ~hb_ot_shape_planner_t (void) { map.finish (); } | |
62 | |
63 inline void compile (hb_face_t *face, | |
64 const hb_segment_properties_t *props, | |
65 struct hb_ot_shape_plan_t &plan) | |
66 { | |
67 plan.shaper = shaper; | |
68 map.compile (face, props, plan.map); | |
69 } | |
70 | |
71 private: | |
72 NO_COPY (hb_ot_shape_planner_t); | |
73 }; | |
74 | 48 |
75 | 49 |
76 struct hb_ot_shape_context_t | 50 HB_INTERNAL hb_bool_t |
77 { | 51 _hb_ot_shape (hb_font_t *font, |
78 /* Input to hb_ot_shape_execute() */ | 52 » hb_buffer_t *buffer, |
79 hb_ot_shape_plan_t *plan; | 53 » const hb_feature_t *features, |
80 hb_font_t *font; | 54 » unsigned int num_features); |
81 hb_face_t *face; | |
82 hb_buffer_t *buffer; | |
83 const hb_feature_t *user_features; | |
84 unsigned int num_user_features; | |
85 | |
86 /* Transient stuff */ | |
87 hb_direction_t target_direction; | |
88 hb_bool_t applied_substitute_complex; | |
89 hb_bool_t applied_position_complex; | |
90 }; | |
91 | 55 |
92 | 56 |
93 static inline hb_bool_t | 57 inline void |
94 is_variation_selector (hb_codepoint_t unicode) | 58 _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *uni
code) |
95 { | 59 { |
96 return unlikely ((unicode >= 0x180B && unicode <= 0x180D) || /* MONGOLIAN FR
EE VARIATION SELECTOR ONE..THREE */ | 60 info->unicode_props0() = ((unsigned int) hb_unicode_general_category (unicode,
info->codepoint)) | |
97 » » (unicode >= 0xFE00 && unicode <= 0xFE0F) || /* VARIATION SE
LECTOR-1..16 */ | 61 » » » (_hb_unicode_is_zero_width (info->codepoint) ? 0x80 :
0); |
98 » » (unicode >= 0xE0100 && unicode <= 0xE01EF)); /* VARIATION SE
LECTOR-17..256 */ | 62 info->unicode_props1() = _hb_unicode_modified_combining_class (unicode, info->
codepoint); |
99 } | 63 } |
100 | 64 |
101 static inline unsigned int | 65 inline hb_unicode_general_category_t |
102 _hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs, | 66 _hb_glyph_info_get_general_category (const hb_glyph_info_t *info) |
103 » » » » hb_codepoint_t unicode) | |
104 { | 67 { |
105 int c = hb_unicode_combining_class (ufuncs, unicode); | 68 return (hb_unicode_general_category_t) (info->unicode_props0() & 0x7F); |
106 | |
107 /* Modify the combining-class to suit Arabic better. See: | |
108 * http://unicode.org/faq/normalization.html#8 | |
109 * http://unicode.org/faq/normalization.html#9 | |
110 */ | |
111 if (unlikely (hb_in_range<int> (c, 27, 33))) | |
112 c = c == 33 ? 27 : c + 1; | |
113 | |
114 return c; | |
115 } | 69 } |
116 | 70 |
117 static inline void | 71 inline unsigned int |
118 hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unic
ode) | 72 _hb_glyph_info_get_modified_combining_class (const hb_glyph_info_t *info) |
119 { | 73 { |
120 info->general_category() = hb_unicode_general_category (unicode, info->codepoi
nt); | 74 return info->unicode_props1(); |
121 info->combining_class() = _hb_unicode_modified_combining_class (unicode, info-
>codepoint); | |
122 } | 75 } |
123 | 76 |
124 HB_INTERNAL void _hb_set_unicode_props (hb_buffer_t *buffer); | 77 inline hb_bool_t |
125 | 78 _hb_glyph_info_is_zero_width (const hb_glyph_info_t *info) |
126 HB_INTERNAL void _hb_ot_shape_normalize (hb_ot_shape_context_t *c); | 79 { |
127 | 80 return !!(info->unicode_props0() & 0x80); |
| 81 } |
128 | 82 |
129 #endif /* HB_OT_SHAPE_PRIVATE_HH */ | 83 #endif /* HB_OT_SHAPE_PRIVATE_HH */ |
OLD | NEW |