OLD | NEW |
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 CFURLRef original_url = (CFURLRef)CTFontCopyAttribute(ct_font, kCTFontURLAttri
bute); | 148 CFURLRef original_url = (CFURLRef)CTFontCopyAttribute(ct_font, kCTFontURLAttri
bute); |
149 | 149 |
150 /* 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 |
151 * font fallback which we don't need anyway. */ | 151 * font fallback which we don't need anyway. */ |
152 { | 152 { |
153 CTFontDescriptorRef last_resort_font_desc = get_last_resort_font_desc (); | 153 CTFontDescriptorRef last_resort_font_desc = get_last_resort_font_desc (); |
154 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); |
155 CFRelease (last_resort_font_desc); | 155 CFRelease (last_resort_font_desc); |
156 if (new_ct_font) | 156 if (new_ct_font) |
157 { | 157 { |
158 // The CTFontCreateCopyWithAttributes call fails to stay on the same font | 158 /* The CTFontCreateCopyWithAttributes call fails to stay on the same font |
159 // when reconfiguring the cascade list and may switch to a different 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 | 160 * when there are fonts that go by the same name, since the descriptor is |
161 // just name and size. | 161 * just name and size. |
162 | 162 * |
163 // Avoid reconfiguring the cascade lists if the new font is outside the | 163 * Avoid reconfiguring the cascade lists if the new font is outside the |
164 // system locations that we cannot access from the sandboxed renderer | 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 | 165 * process in Blink. This can be detected by the new file URL location |
166 // that the newly found font points to. | 166 * that the newly found font points to. */ |
167 CFURLRef new_url = (CFURLRef)CTFontCopyAttribute(new_ct_font, kCTFontURLAt
tribute); | 167 CFURLRef new_url = (CFURLRef) CTFontCopyAttribute (new_ct_font, kCTFontURL
Attribute); |
168 // Keep reconfigured font if URL cannot be retrieved (seems to be the case | 168 // Keep reconfigured font if URL cannot be retrieved (seems to be the case |
169 // on Mac OS 10.12 Sierra), speculative fix for crbug.com/625606 | 169 // on Mac OS 10.12 Sierra), speculative fix for crbug.com/625606 |
170 if (!original_url || !new_url || CFEqual(original_url, new_url)) { | 170 if (!original_url || !new_url || CFEqual (original_url, new_url)) { |
171 CFRelease (ct_font); | 171 CFRelease (ct_font); |
172 ct_font = new_ct_font; | 172 ct_font = new_ct_font; |
173 } else { | 173 } else { |
174 CFRelease(new_ct_font); | 174 CFRelease (new_ct_font); |
175 DEBUG_MSG (CORETEXT, ct_font, "Discarding reconfigured CTFont, location
changed."); | 175 DEBUG_MSG (CORETEXT, ct_font, "Discarding reconfigured CTFont, location
changed."); |
176 } | 176 } |
177 if (new_url) | 177 if (new_url) |
178 CFRelease(new_url); | 178 CFRelease (new_url); |
179 } | 179 } |
180 else | 180 else |
181 DEBUG_MSG (CORETEXT, ct_font, "Font copy with empty cascade list failed"); | 181 DEBUG_MSG (CORETEXT, ct_font, "Font copy with empty cascade list failed"); |
182 } | 182 } |
183 | 183 |
184 if (original_url) | 184 if (original_url) |
185 CFRelease(original_url); | 185 CFRelease (original_url); |
186 return ct_font; | 186 return ct_font; |
187 } | 187 } |
188 | 188 |
189 struct hb_coretext_shaper_face_data_t { | 189 struct hb_coretext_shaper_face_data_t { |
190 CGFontRef cg_font; | 190 CGFontRef cg_font; |
191 CTFontRef ct_font; | 191 CTFontRef ct_font; |
192 }; | 192 }; |
193 | 193 |
194 hb_coretext_shaper_face_data_t * | 194 hb_coretext_shaper_face_data_t * |
195 _hb_coretext_shaper_face_data_create (hb_face_t *face) | 195 _hb_coretext_shaper_face_data_create (hb_face_t *face) |
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 | 1281 |
1282 hb_bool_t | 1282 hb_bool_t |
1283 _hb_coretext_aat_shape (hb_shape_plan_t *shape_plan, | 1283 _hb_coretext_aat_shape (hb_shape_plan_t *shape_plan, |
1284 hb_font_t *font, | 1284 hb_font_t *font, |
1285 hb_buffer_t *buffer, | 1285 hb_buffer_t *buffer, |
1286 const hb_feature_t *features, | 1286 const hb_feature_t *features, |
1287 unsigned int num_features) | 1287 unsigned int num_features) |
1288 { | 1288 { |
1289 return _hb_coretext_shape (shape_plan, font, buffer, features, num_features); | 1289 return _hb_coretext_shape (shape_plan, font, buffer, features, num_features); |
1290 } | 1290 } |
OLD | NEW |