summaryrefslogtreecommitdiff
path: root/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc')
-rw-r--r--Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc67
1 files changed, 39 insertions, 28 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc
index aba7cf44d3f..61f9c35a110 100644
--- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc
+++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-coretext.cc
@@ -168,6 +168,10 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
if (CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSText")) ||
CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSDisplay")))
{
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
+# define kCTFontUIFontSystem kCTFontSystemFontType
+# define kCTFontUIFontEmphasizedSystem kCTFontEmphasizedSystemFontType
+#endif
CTFontUIFontType font_type = kCTFontUIFontSystem;
if (CFStringHasSuffix (cg_postscript_name, CFSTR ("-Bold")))
font_type = kCTFontUIFontEmphasizedSystem;
@@ -206,7 +210,18 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
return ct_font;
}
- CFURLRef original_url = (CFURLRef)CTFontCopyAttribute(ct_font, kCTFontURLAttribute);
+ CFURLRef original_url = nullptr;
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+ ATSFontRef atsFont;
+ FSRef fsref;
+ OSStatus status;
+ atsFont = CTFontGetPlatformFont (ct_font, NULL);
+ status = ATSFontGetFileReference (atsFont, &fsref);
+ if (status == noErr)
+ original_url = CFURLCreateFromFSRef (NULL, &fsref);
+#else
+ original_url = (CFURLRef) CTFontCopyAttribute (ct_font, kCTFontURLAttribute);
+#endif
/* Create font copy with cascade list that has LastResort first; this speeds up CoreText
* font fallback which we don't need anyway. */
@@ -225,7 +240,15 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
* system locations that we cannot access from the sandboxed renderer
* process in Blink. This can be detected by the new file URL location
* that the newly found font points to. */
- CFURLRef new_url = (CFURLRef) CTFontCopyAttribute (new_ct_font, kCTFontURLAttribute);
+ CFURLRef new_url = nullptr;
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+ atsFont = CTFontGetPlatformFont (new_ct_font, NULL);
+ status = ATSFontGetFileReference (atsFont, &fsref);
+ if (status == noErr)
+ new_url = CFURLCreateFromFSRef (NULL, &fsref);
+#else
+ new_url = (CFURLRef) CTFontCopyAttribute (new_ct_font, kCTFontURLAttribute);
+#endif
// Keep reconfigured font if URL cannot be retrieved (seems to be the case
// on Mac OS 10.12 Sierra), speculative fix for crbug.com/625606
if (!original_url || !new_url || CFEqual (original_url, new_url)) {
@@ -618,8 +641,8 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
buffer->merge_clusters (i - 1, i + 1);
}
- hb_auto_array_t<feature_record_t> feature_records;
- hb_auto_array_t<range_record_t> range_records;
+ hb_auto_t<hb_vector_t<feature_record_t> > feature_records;
+ hb_auto_t<hb_vector_t<range_record_t> > range_records;
/*
* Set up features.
@@ -628,7 +651,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
if (num_features)
{
/* Sort features by start/end events. */
- hb_auto_array_t<feature_event_t> feature_events;
+ hb_auto_t<hb_vector_t<feature_event_t> > feature_events;
for (unsigned int i = 0; i < num_features; i++)
{
const feature_mapping_t * mapping = (const feature_mapping_t *) bsearch (&features[i].tag,
@@ -647,15 +670,11 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
feature_event_t *event;
event = feature_events.push ();
- if (unlikely (!event))
- goto fail_features;
event->index = features[i].start;
event->start = true;
event->feature = feature;
event = feature_events.push ();
- if (unlikely (!event))
- goto fail_features;
event->index = features[i].end;
event->start = false;
event->feature = feature;
@@ -669,15 +688,13 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
feature.order = num_features + 1;
feature_event_t *event = feature_events.push ();
- if (unlikely (!event))
- goto fail_features;
event->index = 0; /* This value does magic. */
event->start = false;
event->feature = feature;
}
/* Scan events and save features for each range. */
- hb_auto_array_t<active_feature_t> active_features;
+ hb_auto_t<hb_vector_t<active_feature_t> > active_features;
unsigned int last_index = 0;
for (unsigned int i = 0; i < feature_events.len; i++)
{
@@ -687,8 +704,6 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
{
/* Save a snapshot of active features and the range. */
range_record_t *range = range_records.push ();
- if (unlikely (!range))
- goto fail_features;
if (active_features.len)
{
@@ -746,23 +761,16 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
last_index = event->index;
}
- if (event->start) {
- active_feature_t *feature = active_features.push ();
- if (unlikely (!feature))
- goto fail_features;
- *feature = event->feature;
+ if (event->start)
+ {
+ active_features.push (event->feature);
} else {
active_feature_t *feature = active_features.find (&event->feature);
if (feature)
- active_features.remove (feature - active_features.array);
+ active_features.remove (feature - active_features.arrayZ);
}
}
}
- else
- {
- fail_features:
- num_features = 0;
- }
unsigned int scratch_size;
hb_buffer_t::scratch_buffer_t *scratch = buffer->get_scratch_buffer (&scratch_size);
@@ -944,6 +952,9 @@ resize_and_retry:
int level = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1;
CFNumberRef level_number = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &level);
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+ extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel;
+#endif
CFDictionaryRef options = CFDictionaryCreate (kCFAllocatorDefault,
(const void **) &kCTTypesetterOptionForcedEmbeddingLevel,
(const void **) &level_number,
@@ -979,7 +990,7 @@ resize_and_retry:
/* For right-to-left runs, CoreText returns the glyphs positioned such that
* any trailing whitespace is to the left of (0,0). Adjust coordinate system
* to fix for that. Test with any RTL string with trailing spaces.
- * https://code.google.com/p/chromium/issues/detail?id=469028
+ * https://crbug.com/469028
*/
if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
{
@@ -1032,7 +1043,7 @@ resize_and_retry:
* However, even that wouldn't work if we were passed in the CGFont to
* construct a hb_face to begin with.
*
- * See: http://github.com/harfbuzz/harfbuzz/pull/36
+ * See: https://github.com/harfbuzz/harfbuzz/pull/36
*
* Also see: https://bugs.chromium.org/p/chromium/issues/detail?id=597098
*/
@@ -1222,7 +1233,7 @@ resize_and_retry:
* directions. As such, disable the assert... It wouldn't crash, but
* cursoring will be off...
*
- * http://crbug.com/419769
+ * https://crbug.com/419769
*/
if (0)
{