DescriptionUse the correct font metrics in base PlatformFontWin if DirectWrite is used in the browser for font metrics.
The PlatformFontWin class uses GDI for creating fonts and their metrics. If DirectWrite is used for
font metrics then the metrics returned by GDI for the fonts and those calculated by skia using DirectWrite
differ leading to text getting clipped etc.
DirectWrite provides an interface IDWriteGdiInterop for interoperability with GDI. Converting the GDI font
to a DirectWrite font face object (IDWriteFontFace) and then converting this back to a GDI font gives us the
correct metrics.
The other option could be to create a PlatformFontSkia class on the same lines as PlatformFontWin and use skia
to get the font metrics. The amount of work needed there is unkown. We could look at this as a possible alternative
in case the above approach does not work.
Changes in this patch are as below:-
1. We use DirectWrite to create a IDWriteFactory interface in content browser. This is passed down to skia as the
default factory.
2. The factory created in step 1 is also passsed via a static setter function to the PlatformFontWin class. The presence
of a non NULL IDWriteFactory interface is used by this class to create a DirectWrite metrics compatible GDI font.
3. HarfBuzz text rendering is enabled by default in the browser. The MaybeEnableDirectWriteFontRendering function now
checks for the disable harfbuzz text rendering switch instead.
BUG=427804, 427802
Committed: https://crrev.com/9fd5754d8c121d7c6fbc5b88d361a1c3e0d03900
Cr-Commit-Position: refs/heads/master@{#301987}
Patch Set 1 #
Total comments: 6
Patch Set 2 : Code review comments from scottmg #
Total comments: 2
Patch Set 3 : Code review comments from sky #
Messages
Total messages: 10 (2 generated)
|