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

Side by Side Diff: third_party/harfbuzz-ng/src/hb-font.cc

Issue 10510004: Roll harfbuzz-ng 3b8fd9c48f4bde368bf2d465c148b9743a9216ee (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-font.h ('k') | third_party/harfbuzz-ng/src/hb-font-private.hh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 26
27 #include "hb-private.hh" 27 #include "hb-private.hh"
28 28
29 #include "hb-ot-layout-private.hh" 29 #include "hb-ot-layout-private.hh"
30 30
31 #include "hb-font-private.hh" 31 #include "hb-font-private.hh"
32 #include "hb-blob.h" 32 #include "hb-blob.h"
33 #include "hb-open-file-private.hh" 33 #include "hb-open-file-private.hh"
34 #include "hb-ot-head-table.hh" 34 #include "hb-ot-head-table.hh"
35 35
36 #include "hb-cache-private.hh"
37
36 #include <string.h> 38 #include <string.h>
37 39
38 40
39 41
40 /* 42 /*
41 * hb_font_funcs_t 43 * hb_font_funcs_t
42 */ 44 */
43 45
44 static hb_bool_t 46 static hb_bool_t
45 hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED, 47 hb_font_get_glyph_nil (hb_font_t *font,
46 void *font_data HB_UNUSED, 48 void *font_data HB_UNUSED,
47 hb_codepoint_t unicode, 49 hb_codepoint_t unicode,
48 hb_codepoint_t variation_selector, 50 hb_codepoint_t variation_selector,
49 hb_codepoint_t *glyph, 51 hb_codepoint_t *glyph,
50 void *user_data HB_UNUSED) 52 void *user_data HB_UNUSED)
51 { 53 {
52 if (font->parent) 54 if (font->parent)
53 return hb_font_get_glyph (font->parent, unicode, variation_selector, glyph); 55 return hb_font_get_glyph (font->parent, unicode, variation_selector, glyph);
54 56
55 *glyph = 0; 57 *glyph = 0;
56 return FALSE; 58 return FALSE;
57 } 59 }
58 60
59 static hb_position_t 61 static hb_position_t
60 hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED, 62 hb_font_get_glyph_h_advance_nil (hb_font_t *font,
61 void *font_data HB_UNUSED, 63 void *font_data HB_UNUSED,
62 hb_codepoint_t glyph, 64 hb_codepoint_t glyph,
63 void *user_data HB_UNUSED) 65 void *user_data HB_UNUSED)
64 { 66 {
65 if (font->parent) 67 if (font->parent)
66 return font->parent_scale_x_distance (hb_font_get_glyph_h_advance (font->par ent, glyph)); 68 return font->parent_scale_x_distance (hb_font_get_glyph_h_advance (font->par ent, glyph));
67 69
68 return font->x_scale; 70 return font->x_scale;
69 } 71 }
70 72
71 static hb_position_t 73 static hb_position_t
72 hb_font_get_glyph_v_advance_nil (hb_font_t *font HB_UNUSED, 74 hb_font_get_glyph_v_advance_nil (hb_font_t *font,
73 void *font_data HB_UNUSED, 75 void *font_data HB_UNUSED,
74 hb_codepoint_t glyph, 76 hb_codepoint_t glyph,
75 void *user_data HB_UNUSED) 77 void *user_data HB_UNUSED)
76 { 78 {
77 if (font->parent) 79 if (font->parent)
78 return font->parent_scale_y_distance (hb_font_get_glyph_v_advance (font->par ent, glyph)); 80 return font->parent_scale_y_distance (hb_font_get_glyph_v_advance (font->par ent, glyph));
79 81
80 return font->y_scale; 82 return font->y_scale;
81 } 83 }
82 84
83 static hb_bool_t 85 static hb_bool_t
84 hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED, 86 hb_font_get_glyph_h_origin_nil (hb_font_t *font,
85 void *font_data HB_UNUSED, 87 void *font_data HB_UNUSED,
86 hb_codepoint_t glyph, 88 hb_codepoint_t glyph,
87 hb_position_t *x, 89 hb_position_t *x,
88 hb_position_t *y, 90 hb_position_t *y,
89 void *user_data HB_UNUSED) 91 void *user_data HB_UNUSED)
90 { 92 {
91 if (font->parent) { 93 if (font->parent) {
92 hb_bool_t ret = hb_font_get_glyph_h_origin (font->parent, 94 hb_bool_t ret = hb_font_get_glyph_h_origin (font->parent, glyph, x, y);
93 » » » » » » glyph,
94 » » » » » » x, y);
95 if (ret) 95 if (ret)
96 font->parent_scale_position (x, y); 96 font->parent_scale_position (x, y);
97 return ret; 97 return ret;
98 } 98 }
99 99
100 *x = *y = 0; 100 *x = *y = 0;
101 return FALSE; 101 return FALSE;
102 } 102 }
103 103
104 static hb_bool_t 104 static hb_bool_t
105 hb_font_get_glyph_v_origin_nil (hb_font_t *font HB_UNUSED, 105 hb_font_get_glyph_v_origin_nil (hb_font_t *font,
106 void *font_data HB_UNUSED, 106 void *font_data HB_UNUSED,
107 hb_codepoint_t glyph, 107 hb_codepoint_t glyph,
108 hb_position_t *x, 108 hb_position_t *x,
109 hb_position_t *y, 109 hb_position_t *y,
110 void *user_data HB_UNUSED) 110 void *user_data HB_UNUSED)
111 { 111 {
112 if (font->parent) { 112 if (font->parent) {
113 hb_bool_t ret = hb_font_get_glyph_v_origin (font->parent, 113 hb_bool_t ret = hb_font_get_glyph_v_origin (font->parent, glyph, x, y);
114 » » » » » » glyph,
115 » » » » » » x, y);
116 if (ret) 114 if (ret)
117 font->parent_scale_position (x, y); 115 font->parent_scale_position (x, y);
118 return ret; 116 return ret;
119 } 117 }
120 118
121 *x = *y = 0; 119 *x = *y = 0;
122 return FALSE; 120 return FALSE;
123 } 121 }
124 122
125 static hb_position_t 123 static hb_position_t
126 hb_font_get_glyph_h_kerning_nil (hb_font_t *font HB_UNUSED, 124 hb_font_get_glyph_h_kerning_nil (hb_font_t *font,
127 void *font_data HB_UNUSED, 125 void *font_data HB_UNUSED,
128 hb_codepoint_t left_glyph, 126 hb_codepoint_t left_glyph,
129 hb_codepoint_t right_glyph, 127 hb_codepoint_t right_glyph,
130 void *user_data HB_UNUSED) 128 void *user_data HB_UNUSED)
131 { 129 {
132 if (font->parent) 130 if (font->parent)
133 return font->parent_scale_x_distance (hb_font_get_glyph_h_kerning (font->par ent, left_glyph, right_glyph)); 131 return font->parent_scale_x_distance (hb_font_get_glyph_h_kerning (font->par ent, left_glyph, right_glyph));
134 132
135 return 0; 133 return 0;
136 } 134 }
137 135
138 static hb_position_t 136 static hb_position_t
139 hb_font_get_glyph_v_kerning_nil (hb_font_t *font HB_UNUSED, 137 hb_font_get_glyph_v_kerning_nil (hb_font_t *font,
140 void *font_data HB_UNUSED, 138 void *font_data HB_UNUSED,
141 hb_codepoint_t top_glyph, 139 hb_codepoint_t top_glyph,
142 hb_codepoint_t bottom_glyph, 140 hb_codepoint_t bottom_glyph,
143 void *user_data HB_UNUSED) 141 void *user_data HB_UNUSED)
144 { 142 {
145 if (font->parent) 143 if (font->parent)
146 return font->parent_scale_y_distance (hb_font_get_glyph_v_kerning (font->par ent, top_glyph, bottom_glyph)); 144 return font->parent_scale_y_distance (hb_font_get_glyph_v_kerning (font->par ent, top_glyph, bottom_glyph));
147 145
148 return 0; 146 return 0;
149 } 147 }
150 148
151 static hb_bool_t 149 static hb_bool_t
152 hb_font_get_glyph_extents_nil (hb_font_t *font HB_UNUSED, 150 hb_font_get_glyph_extents_nil (hb_font_t *font,
153 void *font_data HB_UNUSED, 151 void *font_data HB_UNUSED,
154 hb_codepoint_t glyph, 152 hb_codepoint_t glyph,
155 hb_glyph_extents_t *extents, 153 hb_glyph_extents_t *extents,
156 void *user_data HB_UNUSED) 154 void *user_data HB_UNUSED)
157 { 155 {
158 if (font->parent) { 156 if (font->parent) {
159 hb_bool_t ret = hb_font_get_glyph_extents (font->parent, 157 hb_bool_t ret = hb_font_get_glyph_extents (font->parent,
160 glyph, 158 glyph,
161 extents); 159 extents);
162 if (ret) { 160 if (ret) {
163 font->parent_scale_position (&extents->x_bearing, &extents->y_bearing); 161 font->parent_scale_position (&extents->x_bearing, &extents->y_bearing);
164 font->parent_scale_distance (&extents->width, &extents->height); 162 font->parent_scale_distance (&extents->width, &extents->height);
165 } 163 }
166 return ret; 164 return ret;
167 } 165 }
168 166
169 memset (extents, 0, sizeof (*extents)); 167 memset (extents, 0, sizeof (*extents));
170 return FALSE; 168 return FALSE;
171 } 169 }
172 170
173 static hb_bool_t 171 static hb_bool_t
174 hb_font_get_glyph_contour_point_nil (hb_font_t *font HB_UNUSED, 172 hb_font_get_glyph_contour_point_nil (hb_font_t *font,
175 void *font_data HB_UNUSED, 173 void *font_data HB_UNUSED,
176 hb_codepoint_t glyph, 174 hb_codepoint_t glyph,
177 unsigned int point_index, 175 unsigned int point_index,
178 hb_position_t *x, 176 hb_position_t *x,
179 hb_position_t *y, 177 hb_position_t *y,
180 void *user_data HB_UNUSED) 178 void *user_data HB_UNUSED)
181 { 179 {
182 if (font->parent) { 180 if (font->parent) {
183 hb_bool_t ret = hb_font_get_glyph_contour_point (font->parent, 181 hb_bool_t ret = hb_font_get_glyph_contour_point (font->parent, glyph, point_ index, x, y);
184 » » » » » » glyph, point_index,
185 » » » » » » x, y);
186 if (ret) 182 if (ret)
187 font->parent_scale_position (x, y); 183 font->parent_scale_position (x, y);
188 return ret; 184 return ret;
189 } 185 }
190 186
191 *x = *y = 0; 187 *x = *y = 0;
192 return FALSE; 188 return FALSE;
193 } 189 }
194 190
191 static hb_bool_t
192 hb_font_get_glyph_name_nil (hb_font_t *font,
193 void *font_data HB_UNUSED,
194 hb_codepoint_t glyph,
195 char *name, unsigned int size,
196 void *user_data HB_UNUSED)
197 {
198 if (font->parent)
199 return hb_font_get_glyph_name (font->parent, glyph, name, size);
200
201 snprintf (name, size, "gid%u", glyph);
202 return FALSE;
203 }
204
205 static hb_bool_t
206 hb_font_get_glyph_from_name_nil (hb_font_t *font,
207 void *font_data HB_UNUSED,
208 const char *name, int len, /* -1 means nul-term inated */
209 hb_codepoint_t *glyph,
210 void *user_data HB_UNUSED)
211 {
212 if (font->parent)
213 return hb_font_get_glyph_from_name (font->parent, name, len, glyph);
214
215 *glyph = 0;
216 return FALSE;
217 }
218
195 219
196 static hb_font_funcs_t _hb_font_funcs_nil = { 220 static hb_font_funcs_t _hb_font_funcs_nil = {
197 HB_OBJECT_HEADER_STATIC, 221 HB_OBJECT_HEADER_STATIC,
198 222
199 TRUE, /* immutable */ 223 TRUE, /* immutable */
200 224
201 { 225 {
202 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil, 226 #define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_nil,
203 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS 227 HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
204 #undef HB_FONT_FUNC_IMPLEMENT 228 #undef HB_FONT_FUNC_IMPLEMENT
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 hb_codepoint_t glyph, unsigned int point_index, 420 hb_codepoint_t glyph, unsigned int point_index,
397 hb_position_t *x, hb_position_t *y) 421 hb_position_t *x, hb_position_t *y)
398 { 422 {
399 *x = *y = 0; 423 *x = *y = 0;
400 return font->klass->get.glyph_contour_point (font, font->user_data, 424 return font->klass->get.glyph_contour_point (font, font->user_data,
401 glyph, point_index, 425 glyph, point_index,
402 x, y, 426 x, y,
403 font->klass->user_data.glyph_cont our_point); 427 font->klass->user_data.glyph_cont our_point);
404 } 428 }
405 429
430 hb_bool_t
431 hb_font_get_glyph_name (hb_font_t *font,
432 hb_codepoint_t glyph,
433 char *name, unsigned int size)
434 {
435 return font->klass->get.glyph_name (font, font->user_data,
436 glyph,
437 name, size,
438 font->klass->user_data.glyph_name);
439 }
440
441 hb_bool_t
442 hb_font_get_glyph_from_name (hb_font_t *font,
443 const char *name, int len, /* -1 means nul-terminat ed */
444 hb_codepoint_t *glyph)
445 {
446 return font->klass->get.glyph_from_name (font, font->user_data,
447 name, len,
448 glyph,
449 font->klass->user_data.glyph_from_nam e);
450 }
451
406 452
407 /* A bit higher-level, and with fallback */ 453 /* A bit higher-level, and with fallback */
408 454
409 void 455 void
410 hb_font_get_glyph_advance_for_direction (hb_font_t *font, 456 hb_font_get_glyph_advance_for_direction (hb_font_t *font,
411 hb_codepoint_t glyph, 457 hb_codepoint_t glyph,
412 hb_direction_t direction, 458 hb_direction_t direction,
413 hb_position_t *x, hb_position_t *y) 459 hb_position_t *x, hb_position_t *y)
414 { 460 {
415 if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { 461 if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 return hb_face_reference_table (face, HB_TAG_NONE); 768 return hb_face_reference_table (face, HB_TAG_NONE);
723 } 769 }
724 770
725 void 771 void
726 hb_face_set_index (hb_face_t *face, 772 hb_face_set_index (hb_face_t *face,
727 unsigned int index) 773 unsigned int index)
728 { 774 {
729 if (hb_object_is_inert (face)) 775 if (hb_object_is_inert (face))
730 return; 776 return;
731 777
732 face->index = 0; 778 face->index = index;
733 } 779 }
734 780
735 unsigned int 781 unsigned int
736 hb_face_get_index (hb_face_t *face) 782 hb_face_get_index (hb_face_t *face)
737 { 783 {
738 return face->index; 784 return face->index;
739 } 785 }
740 786
741 void 787 void
742 hb_face_set_upem (hb_face_t *face, 788 hb_face_set_upem (hb_face_t *face,
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 void 1025 void
980 hb_font_get_ppem (hb_font_t *font, 1026 hb_font_get_ppem (hb_font_t *font,
981 unsigned int *x_ppem, 1027 unsigned int *x_ppem,
982 unsigned int *y_ppem) 1028 unsigned int *y_ppem)
983 { 1029 {
984 if (x_ppem) *x_ppem = font->x_ppem; 1030 if (x_ppem) *x_ppem = font->x_ppem;
985 if (y_ppem) *y_ppem = font->y_ppem; 1031 if (y_ppem) *y_ppem = font->y_ppem;
986 } 1032 }
987 1033
988 1034
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-font.h ('k') | third_party/harfbuzz-ng/src/hb-font-private.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698