Commit 7a95ad35 authored by Dominik Röttsches's avatar Dominik Röttsches Committed by Commit Bot

CoreText COLR/CPAL fallback to FreeType

Fallback to FreeType on Mac OS < 10.13 as there is no support for
COLR/CPAL layered fonts in CoreText before this version.

Bug: 882844
Change-Id: I80ed16d1e6e23ee36dd5ad179e7712a53381e7c4
Reviewed-on: https://chromium-review.googlesource.com/1235995
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592857}
parent 35f20f78
...@@ -659,8 +659,8 @@ jumbo_component("platform") { ...@@ -659,8 +659,8 @@ jumbo_component("platform") {
"fonts/linux/font_cache_linux.cc", "fonts/linux/font_cache_linux.cc",
"fonts/linux/font_unique_name_lookup_linux.cc", "fonts/linux/font_unique_name_lookup_linux.cc",
"fonts/linux/font_unique_name_lookup_linux.h", "fonts/linux/font_unique_name_lookup_linux.h",
"fonts/mac/core_text_variations_support.cc", "fonts/mac/core_text_font_format_support.cc",
"fonts/mac/core_text_variations_support.h", "fonts/mac/core_text_font_format_support.h",
"fonts/mac/font_cache_mac.mm", "fonts/mac/font_cache_mac.mm",
"fonts/mac/font_family_matcher_mac.h", "fonts/mac/font_family_matcher_mac.h",
"fonts/mac/font_family_matcher_mac.mm", "fonts/mac/font_family_matcher_mac.mm",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "third_party/blink/renderer/platform/fonts/mac/core_text_variations_support.h" #include "third_party/blink/renderer/platform/fonts/mac/core_text_font_format_support.h"
#include <CoreText/CoreText.h> #include <CoreText/CoreText.h>
...@@ -12,9 +12,18 @@ namespace blink { ...@@ -12,9 +12,18 @@ namespace blink {
// to have access to this value when building against the 10.10 SDK in our // to have access to this value when building against the 10.10 SDK in our
// standard Chrome build configuration. // standard Chrome build configuration.
static const long kBlinkLocalCTVersionNumber10_12 = 0x00090000; static const long kBlinkLocalCTVersionNumber10_12 = 0x00090000;
static const long kBlinkLocalCTVersionNumber10_13 = 0x000A0000;
bool CoreTextVersionSupportsVariations() { bool CoreTextVersionSupportsVariations() {
return &CTGetCoreTextVersion && return &CTGetCoreTextVersion &&
CTGetCoreTextVersion() >= kBlinkLocalCTVersionNumber10_12; CTGetCoreTextVersion() >= kBlinkLocalCTVersionNumber10_12;
} }
// CoreText versions below 10.13 display COLR cpal as black/foreground-color
// glyphs and do not interpret color glyph layers correctly.
bool CoreTextVersionSupportsColrCpal() {
return &CTGetCoreTextVersion &&
CTGetCoreTextVersion() >= kBlinkLocalCTVersionNumber10_13;
} }
} // namespace blink
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_MAC_CORE_TEXT_VARIATIONS_SUPPORT_H_ #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_MAC_CORE_TEXT_FONT_FORMAT_SUPPORT_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_MAC_CORE_TEXT_VARIATIONS_SUPPORT_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_MAC_CORE_TEXT_FONT_FORMAT_SUPPORT_H_
namespace blink { namespace blink {
bool CoreTextVersionSupportsVariations(); bool CoreTextVersionSupportsVariations();
} bool CoreTextVersionSupportsColrCpal();
} // namespace blink
#endif #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_MAC_CORE_TEXT_FONT_FORMAT_SUPPORT_H_
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#endif #endif
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
#include "third_party/blink/renderer/platform/fonts/mac/core_text_variations_support.h" #include "third_party/blink/renderer/platform/fonts/mac/core_text_font_format_support.h"
#endif #endif
namespace blink { namespace blink {
...@@ -129,6 +129,10 @@ sk_sp<SkFontMgr> WebFontTypefaceFactory::FontManagerForColrCpal() { ...@@ -129,6 +129,10 @@ sk_sp<SkFontMgr> WebFontTypefaceFactory::FontManagerForColrCpal() {
#if defined(OS_WIN) #if defined(OS_WIN)
if (!blink::DWriteRasterizerSupport::IsDWriteFactory2Available()) if (!blink::DWriteRasterizerSupport::IsDWriteFactory2Available())
return FreeTypeFontManager(); return FreeTypeFontManager();
#endif
#if defined(OS_MACOSX)
if (!CoreTextVersionSupportsColrCpal())
return FreeTypeFontManager();
#endif #endif
// TODO(https://crbug.com/882844): Check Mac OS version and use the FreeType // TODO(https://crbug.com/882844): Check Mac OS version and use the FreeType
// font manager accordingly. // font manager accordingly.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment