Commit 5dd15b25 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Address post-commit comments in crrev.com/c/2261898

Bug: 1065508
Change-Id: If27098661c2edfc6f20f8ae2dff0f261599e308d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270673Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783791}
parent d2bfa2ba
...@@ -190,11 +190,13 @@ bool FontCustomPlatformData::MayBeIconFont() const { ...@@ -190,11 +190,13 @@ bool FontCustomPlatformData::MayBeIconFont() const {
// We first obtain the list of glyphs mapped from PUA codepoint range: // We first obtain the list of glyphs mapped from PUA codepoint range:
// https://unicode.org/charts/PDF/UE000.pdf // https://unicode.org/charts/PDF/UE000.pdf
const SkUnichar pua_start = 0xE000; // Note: The two supplementary PUA here are too long but not used much by
const SkUnichar pua_end = 0xF900; // icon fonts, so we don't include them in this heuristic.
Vector<SkUnichar> pua_codepoints(pua_end - pua_start); wtf_size_t pua_length =
for (wtf_size_t i = 0; i < pua_codepoints.size(); ++i) kPrivateUseLastCharacter - kPrivateUseFirstCharacter + 1;
pua_codepoints[i] = pua_start + i; Vector<SkUnichar> pua_codepoints(pua_length);
for (wtf_size_t i = 0; i < pua_length; ++i)
pua_codepoints[i] = kPrivateUseFirstCharacter + i;
Vector<SkGlyphID> glyphs(pua_codepoints.size()); Vector<SkGlyphID> glyphs(pua_codepoints.size());
base_typeface_->unicharsToGlyphs(pua_codepoints.data(), base_typeface_->unicharsToGlyphs(pua_codepoints.data(),
...@@ -206,8 +208,8 @@ bool FontCustomPlatformData::MayBeIconFont() const { ...@@ -206,8 +208,8 @@ bool FontCustomPlatformData::MayBeIconFont() const {
if (!glyphs[0]) if (!glyphs[0])
glyphs.EraseAt(0); glyphs.EraseAt(0);
// We use the heuristic that if most of the define glyphs are in PUA, then // We use the heuristic that if more than half of the define glyphs are in
// the font may be an icon font. // PUA, then the font may be an icon font.
wtf_size_t pua_glyph_count = glyphs.size(); wtf_size_t pua_glyph_count = glyphs.size();
wtf_size_t total_glyphs = base_typeface_->countGlyphs(); wtf_size_t total_glyphs = base_typeface_->countGlyphs();
may_be_icon_font_ = pua_glyph_count * 2 > total_glyphs; may_be_icon_font_ = pua_glyph_count * 2 > total_glyphs;
......
...@@ -172,6 +172,8 @@ const UChar kZeroWidthJoinerCharacter = 0x200D; ...@@ -172,6 +172,8 @@ const UChar kZeroWidthJoinerCharacter = 0x200D;
const UChar kZeroWidthNonJoinerCharacter = 0x200C; const UChar kZeroWidthNonJoinerCharacter = 0x200C;
const UChar kZeroWidthSpaceCharacter = 0x200B; const UChar kZeroWidthSpaceCharacter = 0x200B;
const UChar kZeroWidthNoBreakSpaceCharacter = 0xFEFF; const UChar kZeroWidthNoBreakSpaceCharacter = 0xFEFF;
const UChar kPrivateUseFirstCharacter = 0xE000;
const UChar kPrivateUseLastCharacter = 0xF8FF;
const UChar32 kMaxCodepoint = 0x10ffff; const UChar32 kMaxCodepoint = 0x10ffff;
} // namespace unicode } // namespace unicode
...@@ -270,6 +272,8 @@ using WTF::unicode::kParagraphSeparator; ...@@ -270,6 +272,8 @@ using WTF::unicode::kParagraphSeparator;
using WTF::unicode::kPartialDifferential; using WTF::unicode::kPartialDifferential;
using WTF::unicode::kPopDirectionalFormattingCharacter; using WTF::unicode::kPopDirectionalFormattingCharacter;
using WTF::unicode::kPopDirectionalIsolateCharacter; using WTF::unicode::kPopDirectionalIsolateCharacter;
using WTF::unicode::kPrivateUseFirstCharacter;
using WTF::unicode::kPrivateUseLastCharacter;
using WTF::unicode::kRainbowCharacter; using WTF::unicode::kRainbowCharacter;
using WTF::unicode::kReplacementCharacter; using WTF::unicode::kReplacementCharacter;
using WTF::unicode::kReverseSolidusCharacter; using WTF::unicode::kReverseSolidusCharacter;
......
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