| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 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. |
| 11 * | 11 * |
| 12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR | 12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
| 13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES | 13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
| 14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN | 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 | 15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 16 * DAMAGE. | 16 * DAMAGE. |
| 17 * | 17 * |
| 18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, | 18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
| 19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | 19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
| 20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS | 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 | 21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
| 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.h" | 30 #include "hb-private.hh" |
| 31 | 31 |
| 32 #include "hb-ot-shape.h" | 32 #include "hb-ot-shape.h" |
| 33 | 33 |
| 34 #include "hb-ot-map-private.hh" | 34 #include "hb-ot-map-private.hh" |
| 35 | 35 #include "hb-ot-shape-complex-private.hh" |
| 36 HB_BEGIN_DECLS | |
| 37 | 36 |
| 38 | 37 |
| 39 /* buffer var allocations */ | |
| 40 #define general_category() var1.u8[0] /* unicode general_category (hb_category_t
) */ | |
| 41 #define combining_class() var1.u8[1] /* unicode combining_class (uint8_t) */ | |
| 42 | 38 |
| 39 enum hb_ot_complex_shaper_t; |
| 43 | 40 |
| 44 enum hb_ot_complex_shaper_t { | 41 struct hb_ot_shape_plan_t |
| 45 hb_ot_complex_shaper_none, | 42 { |
| 46 hb_ot_complex_shaper_arabic | 43 friend struct hb_ot_shape_planner_t; |
| 44 |
| 45 hb_ot_map_t map; |
| 46 hb_ot_complex_shaper_t shaper; |
| 47 |
| 48 hb_ot_shape_plan_t (void) : map () {} |
| 49 ~hb_ot_shape_plan_t (void) { map.finish (); } |
| 50 |
| 51 private: |
| 52 NO_COPY (hb_ot_shape_plan_t); |
| 53 }; |
| 54 |
| 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); |
| 47 }; | 73 }; |
| 48 | 74 |
| 49 | 75 |
| 50 struct hb_ot_shape_plan_t | |
| 51 { | |
| 52 hb_ot_map_t map; | |
| 53 hb_ot_complex_shaper_t shaper; | |
| 54 }; | |
| 55 | |
| 56 | |
| 57 struct hb_ot_shape_context_t | 76 struct hb_ot_shape_context_t |
| 58 { | 77 { |
| 59 /* Input to hb_ot_shape_execute() */ | 78 /* Input to hb_ot_shape_execute() */ |
| 60 hb_ot_shape_plan_t *plan; | 79 hb_ot_shape_plan_t *plan; |
| 61 hb_font_t *font; | 80 hb_font_t *font; |
| 62 hb_face_t *face; | 81 hb_face_t *face; |
| 63 hb_buffer_t *buffer; | 82 hb_buffer_t *buffer; |
| 64 const hb_feature_t *user_features; | 83 const hb_feature_t *user_features; |
| 65 unsigned int num_user_features; | 84 unsigned int num_user_features; |
| 66 | 85 |
| 67 /* Transient stuff */ | 86 /* Transient stuff */ |
| 68 hb_direction_t target_direction; | 87 hb_direction_t target_direction; |
| 69 hb_bool_t applied_substitute_complex; | 88 hb_bool_t applied_substitute_complex; |
| 70 hb_bool_t applied_position_complex; | 89 hb_bool_t applied_position_complex; |
| 71 }; | 90 }; |
| 72 | 91 |
| 73 | 92 |
| 74 HB_END_DECLS | 93 static inline hb_bool_t |
| 94 is_variation_selector (hb_codepoint_t unicode) |
| 95 { |
| 96 return unlikely ((unicode >= 0x180B && unicode <= 0x180D) || /* MONGOLIAN FR
EE VARIATION SELECTOR ONE..THREE */ |
| 97 » » (unicode >= 0xFE00 && unicode <= 0xFE0F) || /* VARIATION SE
LECTOR-1..16 */ |
| 98 » » (unicode >= 0xE0100 && unicode <= 0xE01EF)); /* VARIATION SE
LECTOR-17..256 */ |
| 99 } |
| 100 |
| 101 static inline unsigned int |
| 102 _hb_unicode_modified_combining_class (hb_unicode_funcs_t *ufuncs, |
| 103 » » » » hb_codepoint_t unicode) |
| 104 { |
| 105 int c = hb_unicode_combining_class (ufuncs, unicode); |
| 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 } |
| 116 |
| 117 static inline void |
| 118 hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_unicode_funcs_t *unic
ode) |
| 119 { |
| 120 info->general_category() = hb_unicode_general_category (unicode, info->codepoi
nt); |
| 121 info->combining_class() = _hb_unicode_modified_combining_class (unicode, info-
>codepoint); |
| 122 } |
| 123 |
| 124 HB_INTERNAL void _hb_set_unicode_props (hb_buffer_t *buffer); |
| 125 |
| 126 HB_INTERNAL void _hb_ot_shape_normalize (hb_ot_shape_context_t *c); |
| 127 |
| 75 | 128 |
| 76 #endif /* HB_OT_SHAPE_PRIVATE_HH */ | 129 #endif /* HB_OT_SHAPE_PRIVATE_HH */ |
| OLD | NEW |