Add font-variant-caps support in HarfBuzzShaper
The previous preparatory CLs added:
* Support for lowercasing and moving the step of filling HarfBuzz'
buffer to CaseMappingHarfBuzzBufferFiller
* Adding OpenType feature detecting in OpenTypeCapsSupport
* Adding support for parsing the font-variant-caps CSS property and
piping the parsed values to FontDescription
In this CL, we are putting the pieces together and adding LayoutTests
for the feature (partially taken from Mozilla's test case repository).
The CSS Fonts Level 3 specification [1] suggests to implement a mixture
of full OpenType support with optional fallback to similar OpenType
features or full synthesis of caps-related features.
This is implemented as follows:
RunSegmenter no longer needs to unconditionally determine case of
sub-runs. We only need to segment into smaller lowercase/uppercase
segments if there is none or partial OpenType support in the font.
In HarfBuzzShaper, first it is determined whether a font-variant-caps
feature other than CapsNormal is requested and thus whether any caps
specific processing is required. If no caps processing is required,
shaping proceeds without any extra overhead.
Then, in the inner shaping loop, OpenTypeCapsSupport is queried for
whether additional run splitting is required in case of partial or no
font support. If it is, the run is split into sub-runs of contiguous
lower- or uppercase.
If OpenTypeCapsSupport has determined that a downscaled font is to be
used for synthetic rendering, HarfBuzzShaper switches to that font for
shaping.
CaseMappingHarfBuzzBufferFiller adds the full run or sub-run to the
HarfBuzzBuffer while changing case at the same time if needed for
synthesis.
If full or partial support is available in the font
CapsFeatureSettingsScopedOverlay activates the determined features for
this shaping run, until it goes out of scope.
In the shaping call HarfBuzz then shapes the run according to the
configured caps-related features.
We get full OpenType caps support, with fallback to partial support, or
synthetic caps rendering.
[1] https://drafts.csswg.org/css-fonts/#font-variant-caps-prop
BUG=587094
TEST=fast/text/font-features/*.html
Review URL: https://codereview.chromium.org/1880113002
Cr-Commit-Position: refs/heads/master@{#389732}
22 files changed