• Dana Fried's avatar
    Unscale text by Windows Text Scaling factor to avoid double-scaling. · eeb7bfd6
    Dana Fried authored
    Eliminates text rendering artifacts resulting from launching Chrome
    browser with Windows Text Zoom enabled.
    
    ----------
    Background
    ----------
    
    The new Windows Text Zoom accessibility feature scales small text on
    the screen by an amount in addition to normal DPI scaling. In
    consultation with MS accessibility engineers, we have decided that
    rather than doing complex and extensive scaling math in Chrome, we are
    just going to have the browser scale additionally by that factor.
    Chrome now scales dynamically with the zoom factor.
    
    When we read default system fonts (such as those used by the
    views::Label class - used by tabs, menu items, bookmarks, etc.), Windows
    reports the logical size of the font. This does not take DPI into
    account, but it *does* take the Windows Text Zoom amount into account
    (for backwards-compatibility with apps that don't read it directly).
    
    When the UI renders the text, it scales by the overall browser scale
    factor (which includes both DPI and Windows Text Zoom). So effectively,
    if the Text Zoom is set before Chrome starts, all system-default text
    ends up scaled *twice*.
    
    Correct text size (current behavior only if Text Zoom is changed *after*
    launching Chrome):
     Text Scale 100% 150% 200%
    DPI 100%     12   18   24
    DPI 150%     18   27   36
    DPI 200%     24   36   48
    
    Current text size if Text Zoom is enabled prior to launching Chrome:
     Text Scale 100% 150% 200%
    DPI 100%     12   27   48
    DPI 150%     18   39   72
    DPI 200%     24   54   96
    
    -------------
    Patch Details
    -------------
    
    This change captures the situations in which we ask Windows for a system
    font (for menus and captions), and removes the additional scaling done by
    the OS, since we are already taking this into account when rendering
    text.
    
    We already apply scaling for localization in most of these places for
    similar reasons, so there is a precedent.
    
    Chrome still scales appropriately when Text Scale Factor or DPI is set
    prior to Chrome launch or changed dynamically while Chrome is running.
    
    ----------
    Follow-Ups
    ----------
    
    We call GetNonClientMetrics() in a number of plces, and use LOGFONT*
    structs as well. These are Windows implementation details and should
    ideally be hidden away from browser code. We should consolidate to a
    single cache of system fonts, which will internally ensure that the fonts
    are scaled appropriately (preferably in gfx::PlatformFontWin or similar).
    
    Bug: 866513
    Change-Id: Ideb248e2f196bb93d46a3f60780c68cf31446097
    Reviewed-on: https://chromium-review.googlesource.com/1235313
    Commit-Queue: Dana Fried <dfried@chromium.org>
    Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
    Reviewed-by: default avatarScott Violet <sky@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#593732}
    eeb7bfd6
dpi.h 1.99 KB