Font rendering configuration in Blink has a lot of platform-specific logic, which makes it hard to add new platforms and keep behavior consistent across different platform. There is also a lot of complexity that doesn't need to be there.
Specifically the following can be done to improve this code:
1. Move FontRenderStyle class so it can be used on platforms other than Linux & Android. It's mostly generic code that should be usable on all platforms and particularly those that that use FreeType for font rendering (e.g. Fuchsia). Pending CL also renames this class to WebFontRenderStyle, see https://chromium-review.googlesource.com/c/chromium/src/+/896839
2. Use FontRenderStyle on Fuchsia & Windows. Remove some OS_WIN ifdefs from FontCache and FontPlatformData.
3. Remove WebFontRendering class. Currently content layer calls WebFontRendering to pass system font configuration. It redirects all calls to other classes in the blink platform layer. It would be easier to the content layer to talk to blink platform directly.
4. Don't use FontCache class to store system font configuration. Currently FontCache is used on various font configuration options, which makes little sense. Move this logic somewhere else. Specifically font sizing/styling info can be stored in WebThemeEngine. Font rendering options - in FontRenderStyle.
5. Related to (4). Separate font rendering parameters (such as hinting level, subpixel rendering, etc) from system font styling configuration (default fonts size, menu font, etc.). Currently both categories are controlled via WebFontRendering interface, but they are applied at different layers. Tt doesn't make sense to mix them together. Default font sizing can be moved to blink::WebThemeEngine.
6. On Linux font rendering configuration is passed between content and blink platform in two steps: (1) renderer sets default configuration in RenderViewImpl::UpdateFontRenderingFromRendererPrefs() based on RendererPreferences, (2) blink requests rendering parameters for each font via WebSandboxSupport::GetWebFontRenderStyleForStrike() callback. There is no reason we need both. It would be better to add blink::Platform::GetWebFontRenderStyleForStrike() and use it on all platforms. Then (1) won't be needed.
Comment 1 by drott@chromium.org
, Feb 2 2018