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

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

Issue 2114883002: Cherry pick CoreText Helvetica collision fix into HarfBuzz (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/README.chromium ('k') | no next file » | 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 139
140 static CTFontRef 140 static CTFontRef
141 create_ct_font (CGFontRef cg_font, CGFloat font_size) 141 create_ct_font (CGFontRef cg_font, CGFloat font_size)
142 { 142 {
143 CTFontRef ct_font = CTFontCreateWithGraphicsFont (cg_font, font_size, NULL, NU LL); 143 CTFontRef ct_font = CTFontCreateWithGraphicsFont (cg_font, font_size, NULL, NU LL);
144 if (unlikely (!ct_font)) { 144 if (unlikely (!ct_font)) {
145 DEBUG_MSG (CORETEXT, cg_font, "Font CTFontCreateWithGraphicsFont() failed"); 145 DEBUG_MSG (CORETEXT, cg_font, "Font CTFontCreateWithGraphicsFont() failed");
146 return NULL; 146 return NULL;
147 } 147 }
148 CFURLRef original_url = (CFURLRef)CTFontCopyAttribute(ct_font, kCTFontURLAttri bute);
148 149
149 /* Create font copy with cascade list that has LastResort first; this speeds u p CoreText 150 /* Create font copy with cascade list that has LastResort first; this speeds u p CoreText
150 * font fallback which we don't need anyway. */ 151 * font fallback which we don't need anyway. */
151 { 152 {
152 CTFontDescriptorRef last_resort_font_desc = get_last_resort_font_desc (); 153 CTFontDescriptorRef last_resort_font_desc = get_last_resort_font_desc ();
153 CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (ct_font, 0.0, NULL, last_resort_font_desc); 154 CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (ct_font, 0.0, NULL, last_resort_font_desc);
154 CFRelease (last_resort_font_desc); 155 CFRelease (last_resort_font_desc);
155 if (new_ct_font) 156 if (new_ct_font)
156 { 157 {
157 CFRelease (ct_font); 158 // The CTFontCreateCopyWithAttributes call fails to stay on the same font
158 ct_font = new_ct_font; 159 // when reconfiguring the cascade list and may switch to a different font
160 // when there are fonts that go by the same name, since the descriptor is
161 // just name and size.
162
163 // Avoid reconfiguring the cascade lists if the new font is outside the
164 // system locations that we cannot access from the sandboxed renderer
165 // process in Blink. This can be detected by the new file URL location
166 // that the newly found font points to.
167 CFURLRef new_url = (CFURLRef)CTFontCopyAttribute(new_ct_font, kCTFontURLAt tribute);
168 if (CFEqual(original_url, new_url)) {
169 CFRelease (ct_font);
170 ct_font = new_ct_font;
171 } else {
172 CFRelease(new_ct_font);
173 DEBUG_MSG (CORETEXT, ct_font, "Discarding reconfigured CTFont, location changed.");
174 }
175 CFRelease(new_url);
159 } 176 }
160 else 177 else
161 DEBUG_MSG (CORETEXT, ct_font, "Font copy with empty cascade list failed"); 178 DEBUG_MSG (CORETEXT, ct_font, "Font copy with empty cascade list failed");
162 } 179 }
163 180
164 return ct_font; 181 CFRelease(original_url);
182 return ct_font;
165 } 183 }
166 184
167 struct hb_coretext_shaper_face_data_t { 185 struct hb_coretext_shaper_face_data_t {
168 CGFontRef cg_font; 186 CGFontRef cg_font;
169 CTFontRef ct_font; 187 CTFontRef ct_font;
170 }; 188 };
171 189
172 hb_coretext_shaper_face_data_t * 190 hb_coretext_shaper_face_data_t *
173 _hb_coretext_shaper_face_data_create (hb_face_t *face) 191 _hb_coretext_shaper_face_data_create (hb_face_t *face)
174 { 192 {
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 1277
1260 hb_bool_t 1278 hb_bool_t
1261 _hb_coretext_aat_shape (hb_shape_plan_t *shape_plan, 1279 _hb_coretext_aat_shape (hb_shape_plan_t *shape_plan,
1262 hb_font_t *font, 1280 hb_font_t *font,
1263 hb_buffer_t *buffer, 1281 hb_buffer_t *buffer,
1264 const hb_feature_t *features, 1282 const hb_feature_t *features,
1265 unsigned int num_features) 1283 unsigned int num_features)
1266 { 1284 {
1267 return _hb_coretext_shape (shape_plan, font, buffer, features, num_features); 1285 return _hb_coretext_shape (shape_plan, font, buffer, features, num_features);
1268 } 1286 }
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698