⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 248018 in webkit


Ignore:
Timestamp:
Jul 30, 2019, 2:48:27 PM (7 years ago)
Author:
mmaxfield@apple.com
Message:

REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
https://bugs.webkit.org/show_bug.cgi?id=200065
<rdar://problem/50912757>

Reviewed by Simon Fraser.

Source/WebCore:

Before r241288, we were mapping Japanese sans-serif to Hiragino Kaku Gothic ProN, which
has a 300 weight and a 600 weight. However, we can't use that font because it's user-installed,
so in r241288 we switched to using Hiragino Sans, which has a 300 weight, a 600 weight, and an
800 weight. According to the CSS font selection algorithm, sites that request a weight of 700
would get the 800 weight instead of the 600 weight, which caused the text to look too heavy.
Therefore, the apparent visual change is from a weight change from 600 to 800.

In general, this is working as intended. However, text on Yahoo Japan looks too heavy in weight

  1. Instead, this patch adds a quirk specific to Yahoo Japan that overwrites any font requests

to give them a weight of 600 instead of 700. This way, the lighter font will be used.

No new tests because quirks cannot be tested.

  • css/CSSFontSelector.cpp:

(WebCore::resolveGenericFamily):
(WebCore::CSSFontSelector::fontRangesForFamily):

  • page/Quirks.cpp:

(WebCore::Quirks::shouldLightenJapaneseBoldSansSerif const):

  • page/Quirks.h:

Source/WTF:

  • wtf/Platform.h:
Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r248008 r248018  
     12019-07-30  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
     4        https://bugs.webkit.org/show_bug.cgi?id=200065
     5        <rdar://problem/50912757>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * wtf/Platform.h:
     10
    1112019-07-30  Michael Catanzaro  <mcatanzaro@igalia.com>
    212
  • trunk/Source/WTF/wtf/Platform.h

    r247754 r248018  
    16171617#define HAVE_DESIGN_SYSTEM_UI_FONTS 1
    16181618#endif
     1619
     1620#if (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 130000)
     1621#define USE_HIRAGINO_SANS_WORKAROUND 1
     1622#endif
  • trunk/Source/WebCore/ChangeLog

    r248013 r248018  
     12019-07-30  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
     4        https://bugs.webkit.org/show_bug.cgi?id=200065
     5        <rdar://problem/50912757>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Before r241288, we were mapping Japanese sans-serif to Hiragino Kaku Gothic ProN, which
     10        has a 300 weight and a 600 weight. However, we can't use that font because it's user-installed,
     11        so in r241288 we switched to using Hiragino Sans, which has a 300 weight, a 600 weight, and an
     12        800 weight. According to the CSS font selection algorithm, sites that request a weight of 700
     13        would get the 800 weight instead of the 600 weight, which caused the text to look too heavy.
     14        Therefore, the apparent visual change is from a weight change from 600 to 800.
     15
     16        In general, this is working as intended. However, text on Yahoo Japan looks too heavy in weight
     17        800. Instead, this patch adds a quirk specific to Yahoo Japan that overwrites any font requests
     18        to give them a weight of 600 instead of 700. This way, the lighter font will be used.
     19
     20        No new tests because quirks cannot be tested.
     21
     22        * css/CSSFontSelector.cpp:
     23        (WebCore::resolveGenericFamily):
     24        (WebCore::CSSFontSelector::fontRangesForFamily):
     25        * page/Quirks.cpp:
     26        (WebCore::Quirks::shouldLightenJapaneseBoldSansSerif const):
     27        * page/Quirks.h:
     28
    1292019-07-30  Michael Catanzaro  <mcatanzaro@igalia.com>
    230
  • trunk/Source/WebCore/css/CSSFontSelector.cpp

    r246490 r248018  
    4747#include "FrameLoader.h"
    4848#include "Logging.h"
     49#include "Quirks.h"
    4950#include "ResourceLoadObserver.h"
    5051#include "RuntimeEnabledFeatures.h"
     
    275276}
    276277
    277 static AtomString resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomString& familyName)
     278static Optional<AtomString> resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomString& familyName)
    278279{
    279280    auto platformResult = FontDescription::platformResolveGenericFamily(fontDescription.script(), fontDescription.locale(), familyName);
     
    282283
    283284    if (!document)
    284         return familyName;
     285        return WTF::nullopt;
    285286
    286287    const Settings& settings = document->settings();
     
    302303        return settings.standardFontFamily(script);
    303304
    304     return familyName;
     305    return WTF::nullopt;
    305306}
    306307
     
    313314    bool resolveGenericFamilyFirst = familyName == standardFamily;
    314315
    315     AtomString familyForLookup = resolveGenericFamilyFirst ? resolveGenericFamily(m_document.get(), fontDescription, familyName) : familyName;
    316     auto* face = m_cssFontFaceSet->fontFace(fontDescription.fontSelectionRequest(), familyForLookup);
     316    AtomString familyForLookup = familyName;
     317    Optional<FontDescription> overrideFontDescription;
     318    const FontDescription* fontDescriptionForLookup = &fontDescription;
     319    auto resolveGenericFamily = [&]() {
     320        if (auto genericFamilyOptional = WebCore::resolveGenericFamily(m_document.get(), fontDescription, familyName)) {
     321            if (m_document && m_document->quirks().shouldLightenJapaneseBoldSansSerif() && familyForLookup == sansSerifFamily && fontDescription.weight() == boldWeightValue() && fontDescription.script() == USCRIPT_KATAKANA_OR_HIRAGANA) {
     322                overrideFontDescription = fontDescription;
     323                overrideFontDescription->setWeight(FontSelectionValue(600));
     324                fontDescriptionForLookup = &*overrideFontDescription;
     325            }
     326            familyForLookup = *genericFamilyOptional;
     327        }
     328    };
     329
     330    if (resolveGenericFamilyFirst)
     331        resolveGenericFamily();
     332    auto* face = m_cssFontFaceSet->fontFace(fontDescriptionForLookup->fontSelectionRequest(), familyForLookup);
    317333    if (face) {
    318334        if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled()) {
     
    320336                ResourceLoadObserver::shared().logFontLoad(*m_document, familyForLookup.string(), true);
    321337        }
    322         return face->fontRanges(fontDescription);
    323     }
     338        return face->fontRanges(*fontDescriptionForLookup);
     339    }
     340
    324341    if (!resolveGenericFamilyFirst)
    325         familyForLookup = resolveGenericFamily(m_document.get(), fontDescription, familyName);
    326     auto font = FontCache::singleton().fontForFamily(fontDescription, familyForLookup);
     342        resolveGenericFamily();
     343    auto font = FontCache::singleton().fontForFamily(*fontDescriptionForLookup, familyForLookup);
    327344    if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled()) {
    328345        if (m_document)
  • trunk/Source/WebCore/page/Quirks.cpp

    r247879 r248018  
    386386}
    387387
     388bool Quirks::shouldLightenJapaneseBoldSansSerif() const
     389{
     390#if USE(HIRAGINO_SANS_WORKAROUND)
     391    if (!needsQuirks())
     392        return false;
     393
     394    // lang="ja" style="font: bold sans-serif;" content would naturally get HiraginoSans-W8 here, but that's visually
     395    // too bold. Instead, we should pick HiraginoSans-W6 instead.
     396    // FIXME: webkit.org/b/200047 Remove this quirk.
     397    auto host = m_document->topDocument().url().host();
     398    return equalLettersIgnoringASCIICase(host, "m.yahoo.co.jp");
     399#else
     400    return false;
     401#endif
     402}
     403
    388404// FIXME(<rdar://problem/50394969>): Remove after desmos.com adopts inputmode="none".
    389405bool Quirks::needsInputModeNoneImplicitly(const HTMLElement& element) const
  • trunk/Source/WebCore/page/Quirks.h

    r247873 r248018  
    5858    bool needsInputModeNoneImplicitly(const HTMLElement&) const;
    5959    bool needsDeferKeyDownAndKeyPressTimersUntilNextEditingCommand() const;
     60    bool shouldLightenJapaneseBoldSansSerif() const;
    6061
    6162    WEBCORE_EXPORT bool shouldDispatchSyntheticMouseEventsWhenModifyingSelection() const;
Note: See TracChangeset for help on using the changeset viewer.