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

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

Issue 1580513002: Roll HarfBuzz to 1.1.3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix Created 4 years, 11 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-coretext.h ('k') | third_party/harfbuzz-ng/src/hb-face.h » ('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 © 2012,2013 Mozilla Foundation. 2 * Copyright © 2012,2013 Mozilla Foundation.
3 * Copyright © 2012,2013 Google, Inc. 3 * Copyright © 2012,2013 Google, Inc.
4 * 4 *
5 * This is part of HarfBuzz, a text shaping library. 5 * This is part of HarfBuzz, a text shaping library.
6 * 6 *
7 * Permission is hereby granted, without written agreement and without 7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this 8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the 9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in 10 * above copyright notice and the following two paragraphs appear in
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 font_size = -font_size; 169 font_size = -font_size;
170 data->x_mult = (CGFloat) font->x_scale / font_size; 170 data->x_mult = (CGFloat) font->x_scale / font_size;
171 data->y_mult = (CGFloat) font->y_scale / font_size; 171 data->y_mult = (CGFloat) font->y_scale / font_size;
172 data->ct_font = CTFontCreateWithGraphicsFont (face_data, font_size, NULL, NULL ); 172 data->ct_font = CTFontCreateWithGraphicsFont (face_data, font_size, NULL, NULL );
173 if (unlikely (!data->ct_font)) { 173 if (unlikely (!data->ct_font)) {
174 DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed"); 174 DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed");
175 free (data); 175 free (data);
176 return NULL; 176 return NULL;
177 } 177 }
178 178
179 /* Create font copy with cascade list that has LastResort first; this speeds u p CoreText
180 * font fallback which we don't need anyway. */
181 {
182 // TODO Handle allocation failures?
183 CTFontDescriptorRef last_resort = CTFontDescriptorCreateWithNameAndSize(CFST R("LastResort"), 0);
184 CFArrayRef cascade_list = CFArrayCreate (kCFAllocatorDefault,
185 (const void **) &last_resort,
186 1,
187 &kCFTypeArrayCallBacks);
188 CFRelease (last_resort);
189 CFDictionaryRef attributes = CFDictionaryCreate (kCFAllocatorDefault,
190 (const void **) &kCTFontCas cadeListAttribute,
191 (const void **) &cascade_li st,
192 1,
193 &kCFTypeDictionaryKeyCallBa cks,
194 &kCFTypeDictionaryValueCall Backs);
195 CFRelease (cascade_list);
196
197 CTFontDescriptorRef new_font_desc = CTFontDescriptorCreateWithAttributes (at tributes);
198 CFRelease (attributes);
199
200 CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (data->ct_font, 0.0, NULL, new_font_desc);
201 if (new_ct_font)
202 {
203 CFRelease (data->ct_font);
204 data->ct_font = new_ct_font;
205 }
206 else
207 DEBUG_MSG (CORETEXT, font, "Font copy with empty cascade list failed");
208 }
209
210 if (unlikely (!data->ct_font)) {
211 DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed");
212 free (data);
213 return NULL;
214 }
215
179 return data; 216 return data;
180 } 217 }
181 218
182 void 219 void
183 _hb_coretext_shaper_font_data_destroy (hb_coretext_shaper_font_data_t *data) 220 _hb_coretext_shaper_font_data_destroy (hb_coretext_shaper_font_data_t *data)
184 { 221 {
185 CFRelease (data->ct_font); 222 CFRelease (data->ct_font);
186 free (data); 223 free (data);
187 } 224 }
188 225
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 * 877 *
841 * Finally, we compare PS names, which I don't think are unique... 878 * Finally, we compare PS names, which I don't think are unique...
842 * 879 *
843 * Looks like if we really want to be sure here we have to modify the 880 * Looks like if we really want to be sure here we have to modify the
844 * font to change the name table, similar to what we do in the uniscribe 881 * font to change the name table, similar to what we do in the uniscribe
845 * backend. 882 * backend.
846 * 883 *
847 * However, even that wouldn't work if we were passed in the CGFont to 884 * However, even that wouldn't work if we were passed in the CGFont to
848 * begin with. 885 * begin with.
849 * 886 *
850 » * Webkit uses a slightly different approach: it installs LastResort 887 » * We might switch to checking PS name against "LastResort". That would
851 » * as fallback chain, and then checks PS name of used font against 888 » * be safe for all fonts except for those named "Last Resort". Might be
852 » * LastResort. That one is safe for any font except for LastResort, 889 » * better than what we have right now.
853 » * as opposed to ours, which can fail if we are using any uninstalled
854 » * font that has the same name as an installed font.
855 * 890 *
856 * See: http://github.com/behdad/harfbuzz/pull/36 891 * See: http://github.com/behdad/harfbuzz/pull/36
857 */ 892 */
858 bool matched = false; 893 bool matched = false;
859 for (unsigned int i = 0; i < range_records.len; i++) 894 for (unsigned int i = 0; i < range_records.len; i++)
860 if (range_records[i].font && CFEqual (run_ct_font, range_records[i].fo nt)) 895 if (range_records[i].font && CFEqual (run_ct_font, range_records[i].fo nt))
861 { 896 {
862 matched = true; 897 matched = true;
863 break; 898 break;
864 } 899 }
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 1240
1206 hb_bool_t 1241 hb_bool_t
1207 _hb_coretext_aat_shape (hb_shape_plan_t *shape_plan, 1242 _hb_coretext_aat_shape (hb_shape_plan_t *shape_plan,
1208 hb_font_t *font, 1243 hb_font_t *font,
1209 hb_buffer_t *buffer, 1244 hb_buffer_t *buffer,
1210 const hb_feature_t *features, 1245 const hb_feature_t *features,
1211 unsigned int num_features) 1246 unsigned int num_features)
1212 { 1247 {
1213 return _hb_coretext_shape (shape_plan, font, buffer, features, num_features); 1248 return _hb_coretext_shape (shape_plan, font, buffer, features, num_features);
1214 } 1249 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-coretext.h ('k') | third_party/harfbuzz-ng/src/hb-face.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698