summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/platform/fonts
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-03-11 11:32:04 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-03-18 13:40:17 +0000
commit31ccca0778db85c159634478b4ec7997f6704860 (patch)
tree3d33fc3afd9d5ec95541e1bbe074a9cf8da12a0e /chromium/third_party/blink/renderer/platform/fonts
parent248b70b82a40964d5594eb04feca0fa36716185d (diff)
downloadqtwebengine-chromium-31ccca0778db85c159634478b4ec7997f6704860.tar.gz
BASELINE: Update Chromium to 80.0.3987.136
Change-Id: I98e1649aafae85ba3a83e67af00bb27ef301db7b Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/fonts')
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/font.cc7
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/font.h9
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/font_cache.cc2
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/font_cache.h16
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc8
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/font_fallback_iterator.h18
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/font_fallback_list.cc16
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/font_matching_metrics.cc69
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/font_matching_metrics.h76
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/font_selector.h10
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/linux/font_cache_linux.cc44
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/linux/font_unique_name_lookup_linux.cc16
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/mac/font_matcher_mac.mm23
-rw-r--r--chromium/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc12
14 files changed, 228 insertions, 98 deletions
diff --git a/chromium/third_party/blink/renderer/platform/fonts/font.cc b/chromium/third_party/blink/renderer/platform/fonts/font.cc
index 4fc2c843e14..2b110b2e0e0 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/font.cc
+++ b/chromium/third_party/blink/renderer/platform/fonts/font.cc
@@ -28,7 +28,6 @@
#include "cc/paint/paint_flags.h"
#include "third_party/blink/renderer/platform/fonts/character_range.h"
#include "third_party/blink/renderer/platform/fonts/font_cache.h"
-#include "third_party/blink/renderer/platform/fonts/font_fallback_iterator.h"
#include "third_party/blink/renderer/platform/fonts/font_fallback_list.h"
#include "third_party/blink/renderer/platform/fonts/ng_text_fragment_paint_info.h"
#include "third_party/blink/renderer/platform/fonts/shaping/caching_word_shaper.h"
@@ -464,12 +463,6 @@ void Font::WillUseFontData(const String& text) const {
GetFontDescription(), family.Family(), text);
}
-scoped_refptr<FontFallbackIterator> Font::CreateFontFallbackIterator(
- FontFallbackPriority fallback_priority) const {
- return FontFallbackIterator::Create(font_description_, font_fallback_list_,
- fallback_priority);
-}
-
GlyphData Font::GetEmphasisMarkGlyphData(const AtomicString& mark) const {
if (mark.IsEmpty())
return GlyphData();
diff --git a/chromium/third_party/blink/renderer/platform/fonts/font.h b/chromium/third_party/blink/renderer/platform/fonts/font.h
index d13cb218a04..ca24f5f5e49 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/font.h
+++ b/chromium/third_party/blink/renderer/platform/fonts/font.h
@@ -27,6 +27,7 @@
#include "cc/paint/node_id.h"
#include "third_party/blink/renderer/platform/fonts/font_description.h"
+#include "third_party/blink/renderer/platform/fonts/font_fallback_iterator.h"
#include "third_party/blink/renderer/platform/fonts/font_fallback_list.h"
#include "third_party/blink/renderer/platform/fonts/font_fallback_priority.h"
#include "third_party/blink/renderer/platform/fonts/simple_font_data.h"
@@ -53,7 +54,6 @@ namespace blink {
struct CharacterRange;
class FloatPoint;
class FloatRect;
-class FontFallbackIterator;
class FontData;
class FontSelector;
class ShapeCache;
@@ -230,8 +230,11 @@ class PLATFORM_EXPORT Font {
public:
FontSelector* GetFontSelector() const;
- scoped_refptr<FontFallbackIterator> CreateFontFallbackIterator(
- FontFallbackPriority) const;
+ FontFallbackIterator CreateFontFallbackIterator(
+ FontFallbackPriority fallback_priority) const {
+ return FontFallbackIterator(font_description_, font_fallback_list_,
+ fallback_priority);
+ }
void WillUseFontData(const String& text) const;
diff --git a/chromium/third_party/blink/renderer/platform/fonts/font_cache.cc b/chromium/third_party/blink/renderer/platform/fonts/font_cache.cc
index ee8216491bf..b4a7e9509cf 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/font_cache.cc
+++ b/chromium/third_party/blink/renderer/platform/fonts/font_cache.cc
@@ -115,7 +115,7 @@ FontCache::FontCache()
FontPlatformData* FontCache::SystemFontPlatformData(
const FontDescription& font_description) {
const AtomicString& family = FontCache::SystemFontFamily();
-#if defined(OS_LINUX)
+#if defined(OS_LINUX) || defined(OS_FUCHSIA)
if (family.IsEmpty() || family == font_family_names::kSystemUi)
return nullptr;
#else
diff --git a/chromium/third_party/blink/renderer/platform/fonts/font_cache.h b/chromium/third_party/blink/renderer/platform/fonts/font_cache.h
index 4025c77b42a..08c723bc646 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/font_cache.h
+++ b/chromium/third_party/blink/renderer/platform/fonts/font_cache.h
@@ -58,6 +58,10 @@
#include "third_party/skia/include/core/SkFontMgr.h"
#include "third_party/skia/include/core/SkRefCnt.h"
+#if defined(OS_LINUX)
+#include "ui/gfx/font_fallback_linux.h"
+#endif
+
#if defined(OS_WIN)
#include "third_party/blink/public/mojom/dwrite_font_proxy/dwrite_font_proxy.mojom-blink.h"
#include "third_party/blink/renderer/platform/fonts/win/fallback_family_style_cache_win.h"
@@ -238,17 +242,9 @@ class PLATFORM_EXPORT FontCache {
#endif // defined(OS_ANDROID)
#if defined(OS_LINUX)
- struct PlatformFallbackFont {
- String name;
- std::string filename;
- int fontconfig_interface_id;
- int ttc_index;
- bool is_bold;
- bool is_italic;
- };
- static void GetFontForCharacter(UChar32,
+ static bool GetFontForCharacter(UChar32,
const char* preferred_locale,
- PlatformFallbackFont*);
+ gfx::FallbackFontData*);
#endif // defined(OS_LINUX)
scoped_refptr<SimpleFontData> FontDataFromFontPlatformData(
diff --git a/chromium/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc b/chromium/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc
index 825ed95642d..1362d480c4b 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc
+++ b/chromium/third_party/blink/renderer/platform/fonts/font_fallback_iterator.cc
@@ -12,14 +12,6 @@
namespace blink {
-scoped_refptr<FontFallbackIterator> FontFallbackIterator::Create(
- const FontDescription& description,
- scoped_refptr<FontFallbackList> fallback_list,
- FontFallbackPriority font_fallback_priority) {
- return base::AdoptRef(new FontFallbackIterator(
- description, std::move(fallback_list), font_fallback_priority));
-}
-
FontFallbackIterator::FontFallbackIterator(
const FontDescription& description,
scoped_refptr<FontFallbackList> fallback_list,
diff --git a/chromium/third_party/blink/renderer/platform/fonts/font_fallback_iterator.h b/chromium/third_party/blink/renderer/platform/fonts/font_fallback_iterator.h
index 03f264cd632..b17424f89d8 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/font_fallback_iterator.h
+++ b/chromium/third_party/blink/renderer/platform/fonts/font_fallback_iterator.h
@@ -20,13 +20,16 @@ class FontDescription;
class FontFallbackList;
class SimpleFontData;
-class FontFallbackIterator : public RefCounted<FontFallbackIterator> {
- USING_FAST_MALLOC(FontFallbackIterator);
+class FontFallbackIterator {
+ STACK_ALLOCATED();
public:
- static scoped_refptr<FontFallbackIterator> Create(const FontDescription&,
- scoped_refptr<FontFallbackList>,
- FontFallbackPriority);
+ FontFallbackIterator(const FontDescription&,
+ scoped_refptr<FontFallbackList>,
+ FontFallbackPriority);
+ FontFallbackIterator(FontFallbackIterator&&) = default;
+ FontFallbackIterator(const FontFallbackIterator&) = delete;
+ FontFallbackIterator& operator=(const FontFallbackIterator&) = delete;
bool HasNext() const { return fallback_stage_ != kOutOfLuck; }
// Returns whether the next call to Next() needs a full hint list, or whether
@@ -43,9 +46,6 @@ class FontFallbackIterator : public RefCounted<FontFallbackIterator> {
scoped_refptr<FontDataForRangeSet> Next(const Vector<UChar32>& hint_list);
private:
- FontFallbackIterator(const FontDescription&,
- scoped_refptr<FontFallbackList>,
- FontFallbackPriority);
bool RangeSetContributesForHint(const Vector<UChar32> hint_list,
const FontDataForRangeSet*);
bool AlreadyLoadingRangeForHintChar(UChar32 hint_char);
@@ -83,8 +83,6 @@ class FontFallbackIterator : public RefCounted<FontFallbackIterator> {
HashSet<uint32_t> unique_font_data_for_range_sets_returned_;
Vector<scoped_refptr<FontDataForRangeSet>> tracked_loading_range_sets_;
FontFallbackPriority font_fallback_priority_;
-
- DISALLOW_COPY_AND_ASSIGN(FontFallbackIterator);
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/platform/fonts/font_fallback_list.cc b/chromium/third_party/blink/renderer/platform/fonts/font_fallback_list.cc
index be346f33c16..fa1a455e591 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/font_fallback_list.cc
+++ b/chromium/third_party/blink/renderer/platform/fonts/font_fallback_list.cc
@@ -165,8 +165,16 @@ scoped_refptr<FontData> FontFallbackList::GetFontData(
if (!result)
result = FontCache::GetFontCache()->GetFontData(font_description,
curr_family->Family());
- if (result)
+ if (result) {
+ if (font_selector_) {
+ font_selector_->ReportSuccessfulFontFamilyMatch(
+ curr_family->Family());
+ }
return result;
+ }
+
+ if (font_selector_)
+ font_selector_->ReportFailedFontFamilyMatch(curr_family->Family());
}
}
family_index = kCAllFamiliesScanned;
@@ -229,9 +237,9 @@ const FontData* FontFallbackList::FontDataAt(
// Ask the font cache for the font data.
// We are obtaining this font for the first time. We keep track of the
- // families we've looked at before in |m_familyIndex|, so that we never scan
- // the same spot in the list twice. getFontData will adjust our
- // |m_familyIndex| as it scans for the right font to make.
+ // families we've looked at before in |family_index_|, so that we never scan
+ // the same spot in the list twice. GetFontData will adjust our
+ // |family_index_| as it scans for the right font to make.
DCHECK_EQ(FontCache::GetFontCache()->Generation(), generation_);
scoped_refptr<FontData> result = GetFontData(font_description, family_index_);
if (result) {
diff --git a/chromium/third_party/blink/renderer/platform/fonts/font_matching_metrics.cc b/chromium/third_party/blink/renderer/platform/fonts/font_matching_metrics.cc
new file mode 100644
index 00000000000..5e1005a2e4d
--- /dev/null
+++ b/chromium/third_party/blink/renderer/platform/fonts/font_matching_metrics.cc
@@ -0,0 +1,69 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "third_party/blink/renderer/platform/fonts/font_matching_metrics.h"
+
+#include "services/metrics/public/cpp/metrics_utils.h"
+#include "services/metrics/public/cpp/ukm_builders.h"
+#include "services/metrics/public/cpp/ukm_recorder.h"
+
+namespace {
+
+constexpr double kUkmFontLoadCountBucketSpacing = 1.3;
+
+enum FontLoadContext { kTopLevel = 0, kSubFrame };
+
+template <typename T>
+HashSet<T> Intersection(const HashSet<T>& a, const HashSet<T>& b) {
+ HashSet<T> result;
+ for (const T& a_value : a) {
+ if (b.Contains(a_value))
+ result.insert(a_value);
+ }
+ return result;
+}
+
+} // namespace
+
+namespace blink {
+
+void FontMatchingMetrics::ReportSuccessfulFontFamilyMatch(
+ const AtomicString& font_family_name) {
+ successful_font_families_.insert(font_family_name);
+}
+
+void FontMatchingMetrics::ReportFailedFontFamilyMatch(
+ const AtomicString& font_family_name) {
+ failed_font_families_.insert(font_family_name);
+}
+
+void FontMatchingMetrics::ReportSystemFontFamily(
+ const AtomicString& font_family_name) {
+ system_font_families_.insert(font_family_name);
+}
+
+void FontMatchingMetrics::ReportWebFontFamily(
+ const AtomicString& font_family_name) {
+ web_font_families_.insert(font_family_name);
+}
+
+void FontMatchingMetrics::PublishUkmMetrics() {
+ ukm::builders::FontMatchAttempts(source_id_)
+ .SetLoadContext(top_level_ ? kTopLevel : kSubFrame)
+ .SetSystemFontFamilySuccesses(ukm::GetExponentialBucketMin(
+ Intersection(successful_font_families_, system_font_families_).size(),
+ kUkmFontLoadCountBucketSpacing))
+ .SetSystemFontFamilyFailures(ukm::GetExponentialBucketMin(
+ Intersection(failed_font_families_, system_font_families_).size(),
+ kUkmFontLoadCountBucketSpacing))
+ .SetWebFontFamilySuccesses(ukm::GetExponentialBucketMin(
+ Intersection(successful_font_families_, web_font_families_).size(),
+ kUkmFontLoadCountBucketSpacing))
+ .SetWebFontFamilyFailures(ukm::GetExponentialBucketMin(
+ Intersection(failed_font_families_, web_font_families_).size(),
+ kUkmFontLoadCountBucketSpacing))
+ .Record(ukm_recorder_);
+}
+
+} // namespace blink
diff --git a/chromium/third_party/blink/renderer/platform/fonts/font_matching_metrics.h b/chromium/third_party/blink/renderer/platform/fonts/font_matching_metrics.h
new file mode 100644
index 00000000000..c31be1c51b5
--- /dev/null
+++ b/chromium/third_party/blink/renderer/platform/fonts/font_matching_metrics.h
@@ -0,0 +1,76 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_MATCHING_METRICS_H_
+#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_MATCHING_METRICS_H_
+
+#include "services/metrics/public/cpp/ukm_source_id.h"
+#include "third_party/blink/renderer/platform/platform_export.h"
+#include "third_party/blink/renderer/platform/wtf/hash_set.h"
+#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
+#include "third_party/blink/renderer/platform/wtf/text/atomic_string_hash.h"
+
+namespace ukm {
+class UkmRecorder;
+} // namespace ukm
+
+namespace blink {
+
+// Tracks and reports UKM metrics of the number of attempted font family match
+// attempts (both successful and not successful) by the current frame.
+//
+// Only the number of successful / not successful font family match attempts are
+// reported to UKM. The class de-dupes attempts to match the same font family
+// name such that they are counted as one attempt.
+class PLATFORM_EXPORT FontMatchingMetrics {
+ public:
+ FontMatchingMetrics(bool top_level,
+ ukm::UkmRecorder* ukm_recorder,
+ ukm::SourceId source_id)
+ : top_level_(top_level),
+ ukm_recorder_(ukm_recorder),
+ source_id_(source_id) {}
+
+ // Called when a page attempts to match a font family, and the font family is
+ // available.
+ void ReportSuccessfulFontFamilyMatch(const AtomicString& font_family_name);
+
+ // Called when a page attempts to match a font family, and the font family is
+ // not available.
+ void ReportFailedFontFamilyMatch(const AtomicString& font_family_name);
+
+ // Called when a page attempts to match a system font family.
+ void ReportSystemFontFamily(const AtomicString& font_family_name);
+
+ // Called when a page attempts to match a web font family.
+ void ReportWebFontFamily(const AtomicString& font_family_name);
+
+ // Publishes the number of font family matches attempted (both successful and
+ // otherwise) to UKM. Called at page unload.
+ void PublishUkmMetrics();
+
+ private:
+ // Font family names successfully matched.
+ HashSet<AtomicString> successful_font_families_;
+
+ // Font family names that weren't successfully matched.
+ HashSet<AtomicString> failed_font_families_;
+
+ // System font families the page attempted to match.
+ HashSet<AtomicString> system_font_families_;
+
+ // Web font families the page attempted to match.
+ HashSet<AtomicString> web_font_families_;
+
+ // True if this FontMatchingMetrics instance is for a top-level frame, false
+ // otherwise.
+ const bool top_level_ = false;
+
+ ukm::UkmRecorder* const ukm_recorder_;
+ const ukm::SourceId source_id_;
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_FONT_MATCHING_METRICS_H_
diff --git a/chromium/third_party/blink/renderer/platform/fonts/font_selector.h b/chromium/third_party/blink/renderer/platform/fonts/font_selector.h
index 7d1bcb68740..0eaaf9e94fb 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/font_selector.h
+++ b/chromium/third_party/blink/renderer/platform/fonts/font_selector.h
@@ -61,6 +61,16 @@ class PLATFORM_EXPORT FontSelector : public FontCacheClient {
virtual void ReportNotDefGlyph() const = 0;
+ // Called when a page attempts to match a font family, and the font family is
+ // available.
+ virtual void ReportSuccessfulFontFamilyMatch(
+ const AtomicString& font_family_name) = 0;
+
+ // Called when a page attempts to match a font family, and the font family is
+ // not available.
+ virtual void ReportFailedFontFamilyMatch(
+ const AtomicString& font_family_name) = 0;
+
virtual void RegisterForInvalidationCallbacks(FontSelectorClient*) = 0;
virtual void UnregisterForInvalidationCallbacks(FontSelectorClient*) = 0;
diff --git a/chromium/third_party/blink/renderer/platform/fonts/linux/font_cache_linux.cc b/chromium/third_party/blink/renderer/platform/fonts/linux/font_cache_linux.cc
index 687fff054dc..39edc68d0bc 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/linux/font_cache_linux.cc
+++ b/chromium/third_party/blink/renderer/platform/fonts/linux/font_cache_linux.cc
@@ -25,7 +25,6 @@
#include "third_party/blink/renderer/platform/fonts/font_cache.h"
#include "build/build_config.h"
-#include "third_party/blink/public/platform/linux/out_of_process_font.h"
#include "third_party/blink/public/platform/linux/web_sandbox_support.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/fonts/font_platform_data.h"
@@ -50,33 +49,16 @@ void FontCache::SetSystemFontFamily(const AtomicString& family_name) {
MutableSystemFontFamily() = family_name;
}
-void FontCache::GetFontForCharacter(
- UChar32 c,
- const char* preferred_locale,
- FontCache::PlatformFallbackFont* fallback_font) {
+bool FontCache::GetFontForCharacter(UChar32 c,
+ const char* preferred_locale,
+ gfx::FallbackFontData* fallback_font) {
if (Platform::Current()->GetSandboxSupport()) {
- OutOfProcessFont web_fallback_font;
- Platform::Current()->GetSandboxSupport()->GetFallbackFontForCharacter(
- c, preferred_locale, &web_fallback_font);
- fallback_font->name = web_fallback_font.name;
- fallback_font->filename = std::string(web_fallback_font.filename.Data(),
- web_fallback_font.filename.size());
- fallback_font->fontconfig_interface_id =
- web_fallback_font.fontconfig_interface_id;
- fallback_font->ttc_index = web_fallback_font.ttc_index;
- fallback_font->is_bold = web_fallback_font.is_bold;
- fallback_font->is_italic = web_fallback_font.is_italic;
+ return Platform::Current()
+ ->GetSandboxSupport()
+ ->GetFallbackFontForCharacter(c, preferred_locale, fallback_font);
} else {
std::string locale = preferred_locale ? preferred_locale : std::string();
- gfx::FallbackFontData fallback_data =
- gfx::GetFallbackFontForChar(c, locale);
- fallback_font->name = String::FromUTF8(fallback_data.name.data(),
- fallback_data.name.length());
- fallback_font->filename = std::move(fallback_data.filename);
- fallback_font->fontconfig_interface_id = 0;
- fallback_font->ttc_index = fallback_data.ttc_index;
- fallback_font->is_bold = fallback_data.is_bold;
- fallback_font->is_italic = fallback_data.is_italic;
+ return gfx::GetFallbackFontForChar(c, locale, fallback_font);
}
}
@@ -89,7 +71,7 @@ scoped_refptr<SimpleFontData> FontCache::PlatformFallbackFontForCharacter(
// WebFontRendering::setSkiaFontManager. This is used to emulate android fonts
// on linux so we always request the family from the font manager and if none
// is found, we return the LastResort fallback font and avoid using
- // FontCache::getFontForCharacter which would use sandbox support to query the
+ // FontCache::GetFontForCharacter which would use sandbox support to query the
// underlying system for the font family.
if (font_manager_) {
AtomicString family_name = GetFamilyNameForCharacter(
@@ -120,15 +102,15 @@ scoped_refptr<SimpleFontData> FontCache::PlatformFallbackFontForCharacter(
return font_data;
}
- FontCache::PlatformFallbackFont fallback_font;
- FontCache::GetFontForCharacter(
- c, font_description.LocaleOrDefault().Ascii().c_str(), &fallback_font);
- if (fallback_font.name.IsEmpty())
+ gfx::FallbackFontData fallback_font;
+ if (!FontCache::GetFontForCharacter(
+ c, font_description.LocaleOrDefault().Ascii().c_str(),
+ &fallback_font))
return nullptr;
FontFaceCreationParams creation_params;
creation_params = FontFaceCreationParams(
- fallback_font.filename, fallback_font.fontconfig_interface_id,
+ fallback_font.filepath.value(), fallback_font.fontconfig_interface_id,
fallback_font.ttc_index);
// Changes weight and/or italic of given FontDescription depends on
diff --git a/chromium/third_party/blink/renderer/platform/fonts/linux/font_unique_name_lookup_linux.cc b/chromium/third_party/blink/renderer/platform/fonts/linux/font_unique_name_lookup_linux.cc
index 1c3b8d04a6a..62d92b7f412 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/linux/font_unique_name_lookup_linux.cc
+++ b/chromium/third_party/blink/renderer/platform/fonts/linux/font_unique_name_lookup_linux.cc
@@ -3,10 +3,11 @@
// found in the LICENSE file.
#include "third_party/blink/renderer/platform/fonts/linux/font_unique_name_lookup_linux.h"
-#include "third_party/blink/public/platform/linux/out_of_process_font.h"
+
#include "third_party/blink/public/platform/linux/web_sandbox_support.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/platform/fonts/skia/sktypeface_factory.h"
+#include "ui/gfx/font_fallback_linux.h"
namespace blink {
@@ -14,7 +15,7 @@ FontUniqueNameLookupLinux::~FontUniqueNameLookupLinux() = default;
sk_sp<SkTypeface> FontUniqueNameLookupLinux::MatchUniqueName(
const String& font_unique_name) {
- OutOfProcessFont uniquely_matched_font;
+ gfx::FallbackFontData uniquely_matched_font;
if (!Platform::Current()->GetSandboxSupport()) {
LOG(ERROR) << "@font-face src: local() instantiation only available when "
"connected to browser process.";
@@ -22,12 +23,11 @@ sk_sp<SkTypeface> FontUniqueNameLookupLinux::MatchUniqueName(
return nullptr;
}
- Platform::Current()
- ->GetSandboxSupport()
- ->MatchFontByPostscriptNameOrFullFontName(
- font_unique_name.Utf8(WTF::kStrictUTF8Conversion).c_str(),
- &uniquely_matched_font);
- if (!uniquely_matched_font.filename.size())
+ if (!Platform::Current()
+ ->GetSandboxSupport()
+ ->MatchFontByPostscriptNameOrFullFontName(
+ font_unique_name.Utf8(WTF::kStrictUTF8Conversion).c_str(),
+ &uniquely_matched_font))
return nullptr;
return SkTypeface_Factory::FromFontConfigInterfaceIdAndTtcIndex(
diff --git a/chromium/third_party/blink/renderer/platform/fonts/mac/font_matcher_mac.mm b/chromium/third_party/blink/renderer/platform/fonts/mac/font_matcher_mac.mm
index 0b9c2ef61fd..8d01704041c 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/mac/font_matcher_mac.mm
+++ b/chromium/third_party/blink/renderer/platform/fonts/mac/font_matcher_mac.mm
@@ -194,16 +194,19 @@ NSFont* MatchNSFontFamily(const AtomicString& desired_family_string,
NSString* desired_family = desired_family_string;
NSFontManager* font_manager = [NSFontManager sharedFontManager];
- // Do a simple case insensitive search for a matching font family.
- // NSFontManager requires exact name matches.
- // This addresses the problem of matching arial to Arial, etc., but perhaps
- // not all the issues.
- NSEnumerator* e = [[font_manager availableFontFamilies] objectEnumerator];
- NSString* available_family;
- while ((available_family = [e nextObject])) {
- if ([desired_family caseInsensitiveCompare:available_family] ==
- NSOrderedSame)
- break;
+ // From Mac OS 10.15 [NSFontManager availableFonts] does not list certain
+ // fonts that availableMembersOfFontFamily actually shows results for, for
+ // example "Hiragino Kaku Gothic ProN" is not listed, only Hiragino Sans is
+ // listed. We previously enumerated availableFontFamilies and looked for a
+ // case-insensitive string match here, but instead, we can rely on
+ // availableMembersOfFontFamily here to do a case-insensitive comparison, then
+ // set available_family to desired_family if the result was not empty.
+ // See https://crbug.com/1000542
+ NSString* available_family = nil;
+ NSArray* fonts_in_family =
+ [font_manager availableMembersOfFontFamily:desired_family];
+ if (fonts_in_family && [fonts_in_family count]) {
+ available_family = desired_family;
}
int app_kit_font_weight = ToAppKitFontWeight(desired_weight);
diff --git a/chromium/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc b/chromium/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc
index 11baf4df7db..c919c686aa6 100644
--- a/chromium/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc
+++ b/chromium/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_shaper.cc
@@ -855,8 +855,8 @@ void HarfBuzzShaper::ShapeSegment(
font_description.VariantCaps() != FontDescription::kCapsNormal;
OpenTypeCapsSupport caps_support;
- scoped_refptr<FontFallbackIterator> fallback_iterator =
- font->CreateFontFallbackIterator(segment.font_fallback_priority);
+ FontFallbackIterator fallback_iterator(
+ font->CreateFontFallbackIterator(segment.font_fallback_priority));
range_data->reshape_queue.push_back(
ReshapeQueueItem(kReshapeQueueNextFont, 0, 0));
@@ -867,7 +867,7 @@ void HarfBuzzShaper::ShapeSegment(
Vector<UChar32> fallback_chars_hint;
// Reserve sufficient capacity to avoid multiple reallocations, only when a
// full hint list is needed.
- if (fallback_iterator->NeedsHintList()) {
+ if (fallback_iterator.NeedsHintList()) {
fallback_chars_hint.ReserveInitialCapacity(range_data->end -
range_data->start);
}
@@ -877,7 +877,7 @@ void HarfBuzzShaper::ShapeSegment(
if (current_queue_item.action_ == kReshapeQueueNextFont) {
if (!CollectFallbackHintChars(range_data->reshape_queue,
- fallback_iterator->NeedsHintList(),
+ fallback_iterator.NeedsHintList(),
fallback_chars_hint)) {
// Give up shaping since we cannot retrieve a font fallback
// font without a hintlist.
@@ -886,7 +886,7 @@ void HarfBuzzShaper::ShapeSegment(
}
current_font_data_for_range_set =
- fallback_iterator->Next(fallback_chars_hint);
+ fallback_iterator.Next(fallback_chars_hint);
if (!current_font_data_for_range_set->FontData()) {
DCHECK(range_data->reshape_queue.empty());
break;
@@ -959,7 +959,7 @@ void HarfBuzzShaper::ShapeSegment(
ExtractShapeResults(range_data, font_cycle_queued, current_queue_item,
adjusted_font, segment.script, canvas_rotation,
- !fallback_iterator->HasNext(), result);
+ !fallback_iterator.HasNext(), result);
hb_buffer_reset(range_data->buffer);
}