OLD | NEW |
1 /* | 1 /* |
2 * Copyright © 2009 Red Hat, Inc. | 2 * Copyright © 2009 Red Hat, 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 13 matching lines...) Expand all Loading... |
24 * Red Hat Author(s): Behdad Esfahbod | 24 * Red Hat Author(s): Behdad Esfahbod |
25 */ | 25 */ |
26 | 26 |
27 #include "hb-private.hh" | 27 #include "hb-private.hh" |
28 | 28 |
29 #include "hb-shape.h" | 29 #include "hb-shape.h" |
30 | 30 |
31 #include "hb-buffer-private.hh" | 31 #include "hb-buffer-private.hh" |
32 | 32 |
33 #ifdef HAVE_GRAPHITE | 33 #ifdef HAVE_GRAPHITE |
34 #include "hb-graphite2.h" | 34 #include "hb-graphite2-private.hh" |
35 #endif | 35 #endif |
36 #ifdef HAVE_UNISCRIBE | 36 #ifdef HAVE_UNISCRIBE |
37 # include "hb-uniscribe.h" | 37 # include "hb-uniscribe-private.hh" |
38 #endif | 38 #endif |
39 #ifdef HAVE_OT | 39 #ifdef HAVE_OT |
40 # include "hb-ot-shape.h" | 40 # include "hb-ot-shape-private.hh" |
41 #endif | 41 #endif |
42 #include "hb-fallback-shape-private.hh" | 42 #include "hb-fallback-shape-private.hh" |
43 | 43 |
44 typedef hb_bool_t (*hb_shape_func_t) (hb_font_t *font, | 44 typedef hb_bool_t (*hb_shape_func_t) (hb_font_t *font, |
45 hb_buffer_t *buffer, | 45 hb_buffer_t *buffer, |
46 const hb_feature_t *features, | 46 const hb_feature_t *features, |
47 » » » » unsigned int num_features, | 47 » » » » unsigned int num_features); |
48 » » » » const char * const *shaper_options); | |
49 | 48 |
50 #define HB_SHAPER_IMPLEMENT(name) {#name, hb_##name##_shape} | 49 #define HB_SHAPER_IMPLEMENT(name) {#name, _hb_##name##_shape} |
51 static struct hb_shaper_pair_t { | 50 static struct hb_shaper_pair_t { |
52 char name[16]; | 51 char name[16]; |
53 hb_shape_func_t func; | 52 hb_shape_func_t func; |
54 } shapers[] = { | 53 } shapers[] = { |
55 /* v--- Add new shapers in the right place here */ | 54 /* v--- Add new shapers in the right place here */ |
56 #ifdef HAVE_GRAPHITE | 55 #ifdef HAVE_GRAPHITE |
57 HB_SHAPER_IMPLEMENT (graphite), | 56 HB_SHAPER_IMPLEMENT (graphite2), |
58 #endif | 57 #endif |
59 #ifdef HAVE_UNISCRIBE | 58 #ifdef HAVE_UNISCRIBE |
60 HB_SHAPER_IMPLEMENT (uniscribe), | 59 HB_SHAPER_IMPLEMENT (uniscribe), |
61 #endif | 60 #endif |
62 #ifdef HAVE_OT | 61 #ifdef HAVE_OT |
63 HB_SHAPER_IMPLEMENT (ot), | 62 HB_SHAPER_IMPLEMENT (ot), |
64 #endif | 63 #endif |
65 HB_SHAPER_IMPLEMENT (fallback) /* should be last */ | 64 HB_SHAPER_IMPLEMENT (fallback) /* should be last */ |
66 }; | 65 }; |
67 #undef HB_SHAPER_IMPLEMENT | 66 #undef HB_SHAPER_IMPLEMENT |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 hb_shape_list_shapers (void) | 112 hb_shape_list_shapers (void) |
114 { | 113 { |
115 return static_shaper_list.shaper_list; | 114 return static_shaper_list.shaper_list; |
116 } | 115 } |
117 | 116 |
118 hb_bool_t | 117 hb_bool_t |
119 hb_shape_full (hb_font_t *font, | 118 hb_shape_full (hb_font_t *font, |
120 hb_buffer_t *buffer, | 119 hb_buffer_t *buffer, |
121 const hb_feature_t *features, | 120 const hb_feature_t *features, |
122 unsigned int num_features, | 121 unsigned int num_features, |
123 const char * const *shaper_options, | |
124 const char * const *shaper_list) | 122 const char * const *shaper_list) |
125 { | 123 { |
| 124 hb_font_make_immutable (font); /* So we can safely cache stuff on it */ |
| 125 |
126 if (likely (!shaper_list)) { | 126 if (likely (!shaper_list)) { |
127 for (unsigned int i = 0; i < ARRAY_LENGTH (shapers); i++) | 127 for (unsigned int i = 0; i < ARRAY_LENGTH (shapers); i++) |
128 if (likely (shapers[i].func (font, buffer, | 128 if (likely (shapers[i].func (font, buffer, features, num_features))) |
129 » » » » features, num_features, | |
130 » » » » shaper_options))) | |
131 return TRUE; | 129 return TRUE; |
132 } else { | 130 } else { |
133 while (*shaper_list) { | 131 while (*shaper_list) { |
134 for (unsigned int i = 0; i < ARRAY_LENGTH (shapers); i++) | 132 for (unsigned int i = 0; i < ARRAY_LENGTH (shapers); i++) |
135 if (0 == strcmp (*shaper_list, shapers[i].name)) { | 133 if (0 == strcmp (*shaper_list, shapers[i].name)) { |
136 » if (likely (shapers[i].func (font, buffer, | 134 » if (likely (shapers[i].func (font, buffer, features, num_features))) |
137 » » » » features, num_features, | |
138 » » » » shaper_options))) | |
139 return TRUE; | 135 return TRUE; |
140 break; | 136 break; |
141 } | 137 } |
142 shaper_list++; | 138 shaper_list++; |
143 } | 139 } |
144 } | 140 } |
145 return FALSE; | 141 return FALSE; |
146 } | 142 } |
147 | 143 |
148 void | 144 void |
149 hb_shape (hb_font_t *font, | 145 hb_shape (hb_font_t *font, |
150 hb_buffer_t *buffer, | 146 hb_buffer_t *buffer, |
151 const hb_feature_t *features, | 147 const hb_feature_t *features, |
152 unsigned int num_features) | 148 unsigned int num_features) |
153 { | 149 { |
154 hb_shape_full (font, buffer, features, num_features, NULL, NULL); | 150 hb_shape_full (font, buffer, features, num_features, NULL); |
155 } | 151 } |
OLD | NEW |