haikuwebkit/LayoutTests/css3/font-variant-petite-caps-sy...

96 lines
5.0 KiB
HTML
Raw Permalink Normal View History

font-variant-caps does not work if the font does not support font features https://bugs.webkit.org/show_bug.cgi?id=149774 Reviewed by Antti Koivisto. Source/WebCore: This test implements synthesis for small-caps and all-small-caps. It does so by moving font variant selection into a higher level (ComplexTextController). In general, the approach is to use the pure font feature until we encounter a character which needs to be uppercased, and which the font feature does not support uppercasing. In this situation, we try again with synthesis. In this case, synthesis means artificially uppercasing letters and rendering them with a smaller font. We require system support to know which glyphs a particular font feature supports. Therefore, on operating systems which do not include this support, we will simply say that the font feature does not support any glyphs. Test: css3/font-variant-small-caps-synthesis.html css3/font-variant-petite-caps-synthesis.html * platform/graphics/Font.cpp: (WebCore::Font::noSmallCapsFont): Return the same font, but without smcp or c2sc. This function utilizes a cache. * platform/graphics/Font.h: (WebCore::Font::variantFont): Small caps should never go through this function anymore. * platform/graphics/FontCascade.h: Because we're moving variant selection into a higher level, we remove the FontVariant argument from the lower-level call. * platform/graphics/FontCascadeFonts.cpp: (WebCore::FontCascadeFonts::glyphDataForVariant): Use early-return style. (WebCore::FontCascadeFonts::glyphDataForNormalVariant): Ditto. * platform/graphics/cocoa/FontCascadeCocoa.mm: (WebCore::FontCascade::fontForCombiningCharacterSequence): Because we're moving variant selection into a higher level, we remove the FontVariant argument from the lower-level call. * platform/graphics/cocoa/FontCocoa.mm: (WebCore::Font::smallCapsSupportsCharacter): (WebCore::Font::allSmallCapsSupportsCharacter): (WebCore::smallCapsOpenTypeDictionary): Helper function for smallCapsSupportsCharacter(). (WebCore::smallCapsTrueTypeDictionary): Ditto. (WebCore::unionBitVectors): (WebCore::Font::glyphsSupportedBySmallCaps): Compute a bit vector of supported glyphs. (WebCore::Font::glyphsSupportedByAllSmallCaps): Ditto. (WebCore::createDerivativeFont): Moving common code into its own helper function. (WebCore::Font::createFontWithoutSmallCaps): (WebCore::Font::platformCreateScaledFont): Use the common code. * platform/graphics/mac/ComplexTextController.cpp: (WebCore::capitalized): What is the capitalized form of a character? (WebCore::ComplexTextController::collectComplexTextRuns): Implement the core logic of this patch. This includes the retry when we encounter a character which is not supported by the font feature. * platform/spi/cocoa/CoreTextSPI.h: LayoutTests: Adding two new font which include lowercase characters which respond to 'smcp' and 'c2sc'. The character mappings are: OpenType: 'smcp': f 'c2sc': g TrueType: kLowerCaseType / kLowerCaseSmallCapsSelector: r kUpperCaseType / kUpperCaseSmallCapsSelector: u * css3/font-variant-all-expected.html: * css3/font-variant-all.html: * css3/font-variant-small-caps-synthesis-expected.html: Added. * css3/font-variant-small-caps-synthesis.html: Added. * css3/font-variant-petite-caps-synthesis-expected.html: Added. * css3/font-variant-petite-caps-synthesis.html: Added. * css3/resources/FontWithFeaturesLowercaseSmallCaps.otf: Added. * css3/resources/FontWithFeaturesLowercaseSmallCaps.ttf: Added. * platform/mac/TestExpectations: * platform/mac/fast/writing-mode/broken-ideograph-small-caps-expected.txt: Canonical link: https://commits.webkit.org/170248@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-12-10 08:37:03 +00:00
<!DOCTYPE html>
<html>
<head>
<style>
@font-face {
/* Opentype. "L" responds to pcap; "M" responds to c2pc */
font-family: "testfontotf";
src: url("resources/FontWithFeatures.otf") format("opentype");
}
@font-face {
/* Truetype. "S" responds to smcp; "V" responds to c2sc */
/* Truetype. "T" responds to smcp; "W" responds to c2sc */
font-family: "testfontttf";
src: url("resources/FontWithFeatures.ttf") format("truetype");
}
font-variant-caps does not work if the font does not support font features https://bugs.webkit.org/show_bug.cgi?id=149774 Reviewed by Antti Koivisto. Source/WebCore: This test implements synthesis for small-caps and all-small-caps. It does so by moving font variant selection into a higher level (ComplexTextController). In general, the approach is to use the pure font feature until we encounter a character which needs to be uppercased, and which the font feature does not support uppercasing. In this situation, we try again with synthesis. In this case, synthesis means artificially uppercasing letters and rendering them with a smaller font. We require system support to know which glyphs a particular font feature supports. Therefore, on operating systems which do not include this support, we will simply say that the font feature does not support any glyphs. Test: css3/font-variant-small-caps-synthesis.html css3/font-variant-petite-caps-synthesis.html * platform/graphics/Font.cpp: (WebCore::Font::noSmallCapsFont): Return the same font, but without smcp or c2sc. This function utilizes a cache. * platform/graphics/Font.h: (WebCore::Font::variantFont): Small caps should never go through this function anymore. * platform/graphics/FontCascade.h: Because we're moving variant selection into a higher level, we remove the FontVariant argument from the lower-level call. * platform/graphics/FontCascadeFonts.cpp: (WebCore::FontCascadeFonts::glyphDataForVariant): Use early-return style. (WebCore::FontCascadeFonts::glyphDataForNormalVariant): Ditto. * platform/graphics/cocoa/FontCascadeCocoa.mm: (WebCore::FontCascade::fontForCombiningCharacterSequence): Because we're moving variant selection into a higher level, we remove the FontVariant argument from the lower-level call. * platform/graphics/cocoa/FontCocoa.mm: (WebCore::Font::smallCapsSupportsCharacter): (WebCore::Font::allSmallCapsSupportsCharacter): (WebCore::smallCapsOpenTypeDictionary): Helper function for smallCapsSupportsCharacter(). (WebCore::smallCapsTrueTypeDictionary): Ditto. (WebCore::unionBitVectors): (WebCore::Font::glyphsSupportedBySmallCaps): Compute a bit vector of supported glyphs. (WebCore::Font::glyphsSupportedByAllSmallCaps): Ditto. (WebCore::createDerivativeFont): Moving common code into its own helper function. (WebCore::Font::createFontWithoutSmallCaps): (WebCore::Font::platformCreateScaledFont): Use the common code. * platform/graphics/mac/ComplexTextController.cpp: (WebCore::capitalized): What is the capitalized form of a character? (WebCore::ComplexTextController::collectComplexTextRuns): Implement the core logic of this patch. This includes the retry when we encounter a character which is not supported by the font feature. * platform/spi/cocoa/CoreTextSPI.h: LayoutTests: Adding two new font which include lowercase characters which respond to 'smcp' and 'c2sc'. The character mappings are: OpenType: 'smcp': f 'c2sc': g TrueType: kLowerCaseType / kLowerCaseSmallCapsSelector: r kUpperCaseType / kUpperCaseSmallCapsSelector: u * css3/font-variant-all-expected.html: * css3/font-variant-all.html: * css3/font-variant-small-caps-synthesis-expected.html: Added. * css3/font-variant-small-caps-synthesis.html: Added. * css3/font-variant-petite-caps-synthesis-expected.html: Added. * css3/font-variant-petite-caps-synthesis.html: Added. * css3/resources/FontWithFeaturesLowercaseSmallCaps.otf: Added. * css3/resources/FontWithFeaturesLowercaseSmallCaps.ttf: Added. * platform/mac/TestExpectations: * platform/mac/fast/writing-mode/broken-ideograph-small-caps-expected.txt: Canonical link: https://commits.webkit.org/170248@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-12-10 08:37:03 +00:00
.test {
font-size: 20px;
display: inline-block;
}
</style>
</head>
<body>
This test makes sure that font-variant synthesis is correctly applied. The test passes when a particular pattern of Xs and checks appear below. Also note that the correct size of the character is required.
<div style="border: solid black 1px;">
<div class="test" style="font-variant-caps: petite-caps;">ASDF</div>
<div class="test" style="font-variant-caps: petite-caps;">asdf</div>
<div class="test" style="font-variant-caps: petite-caps;">asDF</div>
<div class="test" style="font-variant-caps: petite-caps;">ASdf</div>
<div class="test" style="font-variant-caps: all-petite-caps;">ASDF</div>
<div class="test" style="font-variant-caps: all-petite-caps;">asdf</div>
<div class="test" style="font-variant-caps: all-petite-caps;">asDF</div>
<div class="test" style="font-variant-caps: all-petite-caps;">ASdf</div>
</div>
<div style="font-family: testfontotf; border: solid black 1px; margin: 5px; font-feature-settings: 'ntrl';">
<div class="test">AB</div>
<div class="test">a</div>
<div class="test">L</div>
<div class="test">M</div>
<div class="test" style="font-variant-caps: petite-caps;">a</div>
<div class="test" style="font-variant-caps: petite-caps;">L</div>
<div class="test" style="font-variant-caps: petite-caps;">aL</div>
<div class="test" style="font-variant-caps: petite-caps;">La</div>
<div class="test" style="font-variant-caps: petite-caps;">AL</div>
<div class="test" style="font-variant-caps: petite-caps;">LA</div>
<div class="test" style="font-variant-caps: petite-caps;">M</div>
<div class="test" style="font-variant-caps: petite-caps;">aM</div>
<div class="test" style="font-variant-caps: petite-caps;">Ma</div>
<div class="test" style="font-variant-caps: petite-caps;">AM</div>
<div class="test" style="font-variant-caps: petite-caps;">MA</div>
</div>
<div style="font-family: testfontttf; border: solid black 1px; margin: 5px; font-feature-settings: 'ntrl';">
<div class="test">AB</div>
<div class="test">a</div>
<div class="test">T</div>
<div class="test">W</div>
<div class="test" style="font-variant-caps: petite-caps;">a</div>
<div class="test" style="font-variant-caps: petite-caps;">T</div>
<div class="test" style="font-variant-caps: petite-caps;">aT</div>
<div class="test" style="font-variant-caps: petite-caps;">Ta</div>
<div class="test" style="font-variant-caps: petite-caps;">AT</div>
<div class="test" style="font-variant-caps: petite-caps;">TA</div>
<div class="test" style="font-variant-caps: petite-caps;">W</div>
<div class="test" style="font-variant-caps: petite-caps;">aW</div>
<div class="test" style="font-variant-caps: petite-caps;">Wa</div>
<div class="test" style="font-variant-caps: petite-caps;">AW</div>
<div class="test" style="font-variant-caps: petite-caps;">WA</div>
</div>
font-variant-caps does not work if the font does not support font features https://bugs.webkit.org/show_bug.cgi?id=149774 Reviewed by Antti Koivisto. Source/WebCore: This test implements synthesis for small-caps and all-small-caps. It does so by moving font variant selection into a higher level (ComplexTextController). In general, the approach is to use the pure font feature until we encounter a character which needs to be uppercased, and which the font feature does not support uppercasing. In this situation, we try again with synthesis. In this case, synthesis means artificially uppercasing letters and rendering them with a smaller font. We require system support to know which glyphs a particular font feature supports. Therefore, on operating systems which do not include this support, we will simply say that the font feature does not support any glyphs. Test: css3/font-variant-small-caps-synthesis.html css3/font-variant-petite-caps-synthesis.html * platform/graphics/Font.cpp: (WebCore::Font::noSmallCapsFont): Return the same font, but without smcp or c2sc. This function utilizes a cache. * platform/graphics/Font.h: (WebCore::Font::variantFont): Small caps should never go through this function anymore. * platform/graphics/FontCascade.h: Because we're moving variant selection into a higher level, we remove the FontVariant argument from the lower-level call. * platform/graphics/FontCascadeFonts.cpp: (WebCore::FontCascadeFonts::glyphDataForVariant): Use early-return style. (WebCore::FontCascadeFonts::glyphDataForNormalVariant): Ditto. * platform/graphics/cocoa/FontCascadeCocoa.mm: (WebCore::FontCascade::fontForCombiningCharacterSequence): Because we're moving variant selection into a higher level, we remove the FontVariant argument from the lower-level call. * platform/graphics/cocoa/FontCocoa.mm: (WebCore::Font::smallCapsSupportsCharacter): (WebCore::Font::allSmallCapsSupportsCharacter): (WebCore::smallCapsOpenTypeDictionary): Helper function for smallCapsSupportsCharacter(). (WebCore::smallCapsTrueTypeDictionary): Ditto. (WebCore::unionBitVectors): (WebCore::Font::glyphsSupportedBySmallCaps): Compute a bit vector of supported glyphs. (WebCore::Font::glyphsSupportedByAllSmallCaps): Ditto. (WebCore::createDerivativeFont): Moving common code into its own helper function. (WebCore::Font::createFontWithoutSmallCaps): (WebCore::Font::platformCreateScaledFont): Use the common code. * platform/graphics/mac/ComplexTextController.cpp: (WebCore::capitalized): What is the capitalized form of a character? (WebCore::ComplexTextController::collectComplexTextRuns): Implement the core logic of this patch. This includes the retry when we encounter a character which is not supported by the font feature. * platform/spi/cocoa/CoreTextSPI.h: LayoutTests: Adding two new font which include lowercase characters which respond to 'smcp' and 'c2sc'. The character mappings are: OpenType: 'smcp': f 'c2sc': g TrueType: kLowerCaseType / kLowerCaseSmallCapsSelector: r kUpperCaseType / kUpperCaseSmallCapsSelector: u * css3/font-variant-all-expected.html: * css3/font-variant-all.html: * css3/font-variant-small-caps-synthesis-expected.html: Added. * css3/font-variant-small-caps-synthesis.html: Added. * css3/font-variant-petite-caps-synthesis-expected.html: Added. * css3/font-variant-petite-caps-synthesis.html: Added. * css3/resources/FontWithFeaturesLowercaseSmallCaps.otf: Added. * css3/resources/FontWithFeaturesLowercaseSmallCaps.ttf: Added. * platform/mac/TestExpectations: * platform/mac/fast/writing-mode/broken-ideograph-small-caps-expected.txt: Canonical link: https://commits.webkit.org/170248@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-12-10 08:37:03 +00:00
<div style="font-family: testfontotf; border: solid blue 1px; margin: 5px; font-feature-settings: 'ntrl';">
<div class="test" style="font-variant-caps: all-petite-caps;">a</div>
<div class="test" style="font-variant-caps: all-petite-caps;">L</div>
<div class="test" style="font-variant-caps: all-petite-caps;">aL</div>
<div class="test" style="font-variant-caps: all-petite-caps;">La</div>
<div class="test" style="font-variant-caps: all-petite-caps;">AL</div>
<div class="test" style="font-variant-caps: all-petite-caps;">LA</div>
<div class="test" style="font-variant-caps: all-petite-caps;">M</div>
<div class="test" style="font-variant-caps: all-petite-caps;">aM</div>
<div class="test" style="font-variant-caps: all-petite-caps;">Ma</div>
<div class="test" style="font-variant-caps: all-petite-caps;">AM</div>
<div class="test" style="font-variant-caps: all-petite-caps;">MA</div>
</div>
<div style="font-family: testfontttf; border: solid blue 1px; margin: 5px; font-feature-settings: 'ntrl';">
<div class="test" style="font-variant-caps: all-petite-caps;">a</div>
<div class="test" style="font-variant-caps: all-petite-caps;">T</div>
<div class="test" style="font-variant-caps: all-petite-caps;">aT</div>
<div class="test" style="font-variant-caps: all-petite-caps;">Ta</div>
<div class="test" style="font-variant-caps: all-petite-caps;">AT</div>
<div class="test" style="font-variant-caps: all-petite-caps;">TA</div>
<div class="test" style="font-variant-caps: all-petite-caps;">W</div>
<div class="test" style="font-variant-caps: all-petite-caps;">aW</div>
<div class="test" style="font-variant-caps: all-petite-caps;">Wa</div>
<div class="test" style="font-variant-caps: all-petite-caps;">AW</div>
<div class="test" style="font-variant-caps: all-petite-caps;">WA</div>
</div>
font-variant-caps does not work if the font does not support font features https://bugs.webkit.org/show_bug.cgi?id=149774 Reviewed by Antti Koivisto. Source/WebCore: This test implements synthesis for small-caps and all-small-caps. It does so by moving font variant selection into a higher level (ComplexTextController). In general, the approach is to use the pure font feature until we encounter a character which needs to be uppercased, and which the font feature does not support uppercasing. In this situation, we try again with synthesis. In this case, synthesis means artificially uppercasing letters and rendering them with a smaller font. We require system support to know which glyphs a particular font feature supports. Therefore, on operating systems which do not include this support, we will simply say that the font feature does not support any glyphs. Test: css3/font-variant-small-caps-synthesis.html css3/font-variant-petite-caps-synthesis.html * platform/graphics/Font.cpp: (WebCore::Font::noSmallCapsFont): Return the same font, but without smcp or c2sc. This function utilizes a cache. * platform/graphics/Font.h: (WebCore::Font::variantFont): Small caps should never go through this function anymore. * platform/graphics/FontCascade.h: Because we're moving variant selection into a higher level, we remove the FontVariant argument from the lower-level call. * platform/graphics/FontCascadeFonts.cpp: (WebCore::FontCascadeFonts::glyphDataForVariant): Use early-return style. (WebCore::FontCascadeFonts::glyphDataForNormalVariant): Ditto. * platform/graphics/cocoa/FontCascadeCocoa.mm: (WebCore::FontCascade::fontForCombiningCharacterSequence): Because we're moving variant selection into a higher level, we remove the FontVariant argument from the lower-level call. * platform/graphics/cocoa/FontCocoa.mm: (WebCore::Font::smallCapsSupportsCharacter): (WebCore::Font::allSmallCapsSupportsCharacter): (WebCore::smallCapsOpenTypeDictionary): Helper function for smallCapsSupportsCharacter(). (WebCore::smallCapsTrueTypeDictionary): Ditto. (WebCore::unionBitVectors): (WebCore::Font::glyphsSupportedBySmallCaps): Compute a bit vector of supported glyphs. (WebCore::Font::glyphsSupportedByAllSmallCaps): Ditto. (WebCore::createDerivativeFont): Moving common code into its own helper function. (WebCore::Font::createFontWithoutSmallCaps): (WebCore::Font::platformCreateScaledFont): Use the common code. * platform/graphics/mac/ComplexTextController.cpp: (WebCore::capitalized): What is the capitalized form of a character? (WebCore::ComplexTextController::collectComplexTextRuns): Implement the core logic of this patch. This includes the retry when we encounter a character which is not supported by the font feature. * platform/spi/cocoa/CoreTextSPI.h: LayoutTests: Adding two new font which include lowercase characters which respond to 'smcp' and 'c2sc'. The character mappings are: OpenType: 'smcp': f 'c2sc': g TrueType: kLowerCaseType / kLowerCaseSmallCapsSelector: r kUpperCaseType / kUpperCaseSmallCapsSelector: u * css3/font-variant-all-expected.html: * css3/font-variant-all.html: * css3/font-variant-small-caps-synthesis-expected.html: Added. * css3/font-variant-small-caps-synthesis.html: Added. * css3/font-variant-petite-caps-synthesis-expected.html: Added. * css3/font-variant-petite-caps-synthesis.html: Added. * css3/resources/FontWithFeaturesLowercaseSmallCaps.otf: Added. * css3/resources/FontWithFeaturesLowercaseSmallCaps.ttf: Added. * platform/mac/TestExpectations: * platform/mac/fast/writing-mode/broken-ideograph-small-caps-expected.txt: Canonical link: https://commits.webkit.org/170248@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193894 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-12-10 08:37:03 +00:00
</div>
</body>
</html>