haikuwebkit/LayoutTests/mathml/radical-fallback.html

30 lines
805 B
HTML
Raw Permalink Normal View History

MathOperator: Add fallback mechanisms for stretching and mirroring radical symbols https://bugs.webkit.org/show_bug.cgi?id=156836 Source/WebCore: Patch by Frederic Wang <fwang@igalia.com> on 2016-06-17 Reviewed by Sergio Villar Senin. Some platforms do not have OpenType MATH fonts pre-installed and thus can not draw stretchy operators using size variants or glyph assembly. This is especially problematic for the radical symbol which is used to write roots. Currently, we have some fallback code to draw that symbol using graphical primitives but it is a bit complex and makes the style of radical inconsistent with the font used. We solve these issues by just scaling the base glyph via a scale transform. Such scale transform is also used to mirror the radical symbol so that we have some support for right-to-left roots until we can do glyph-level mirroring via the OpenType rtlm feature. Test: mathml/radical-fallback.html * rendering/mathml/MathOperator.cpp: Add a constant for the code point U+221A of the radical. (WebCore::MathOperator::reset): In general, we don't need any vertical scaling for radical symbols so m_radicalVerticalScale is initialized to 1. (WebCore::MathOperator::calculateStretchyData): If we don't have a font with a MATH table and we try streching a radical, then we update the vertical metrics to match the target size and set m_radicalVerticalScale to the value necessary to make the base glyph scaled to that size. (WebCore::MathOperator::paint): For a radical operator, we may apply a scale transform of parameters (radicalHorizontalScale, m_radicalVerticalScale) in order to support RTL mirroring or vertical stretching. * rendering/mathml/MathOperator.h: We add a m_radicalVerticalScale member to indicate the scaling to apply to the base radical glyph when the stretchy fallback is necessary. (WebCore::MathOperator::isStretched): The operator is also considered stretched when the m_radicalVerticalScale is applied to the base size. * rendering/mathml/RenderMathMLRadicalOperator.cpp: Remove code specific to the old fallback mechanism. * rendering/mathml/RenderMathMLRadicalOperator.h: Ditto. LayoutTests: Reviewed by Sergio Villar Senin. We add a pixel test to verify the result of stretching a radical operator. We test RTL/LTR direction as well as default/sans-serif font in order to check the fallback code. * mathml/radical-fallback.html: Added. * platform/gtk/mathml/radical-fallback-expected.png: Added. * platform/gtk/mathml/radical-fallback-expected.txt: Added. * platform/ios-simulator/mathml/radical-fallback-expected.txt: Added. * platform/mac/mathml/radical-fallback-expected.png: Added. * platform/mac/mathml/radical-fallback-expected.txt: Added. * platform/ios-simulator/mathml/presentation/roots.txt: Updated. Canonical link: https://commits.webkit.org/176939@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202161 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-17 09:24:49 +00:00
<!DOCTYPE html>
<html>
<head>
<title>Radical fallback</title>
<meta charset="utf-8"/>
</head>
<body>
<!-- This pixel test verifies stretching of radical operators with either
the default MathML font or a sans-serif font. The latter is likely
Update OS X and iOS expectations for some MathML pixel tests. https://bugs.webkit.org/show_bug.cgi?id=159339 Unreviewed test gardening. Patch by Frederic Wang <fwang@igalia.com> on 2016-07-01 * mathml/opentype/fraction-line.html: Add a comment about font requirements. * mathml/opentype/horizontal-munderover.html: Ditto. * mathml/opentype/horizontal.html: Ditto. * mathml/opentype/large-operators-italic-correction.html: Ditto. * mathml/opentype/large-operators.html: Ditto. * mathml/opentype/vertical.html: Ditto. * mathml/presentation/attributes-mathvariant.html: Ditto. * mathml/presentation/fractions-linethickness.html: Ditto. * mathml/presentation/tokenElements-mathvariant.html: Ditto. * mathml/radical-fallback.html: Ditto. * platform/ios-simulator-wk1/TestExpectations: Update expectations. * platform/ios-simulator-wk2/TestExpectations: Ditto. * platform/ios-simulator-wk2/mathml/opentype/large-operators-expected.png: Removed. * platform/ios-simulator-wk2/mathml/opentype/vertical-expected.png: Removed. * platform/ios-simulator-wk2/mathml/presentation/mo-stretch-expected.png: Removed. * platform/ios-simulator/TestExpectations: * platform/ios-simulator/mathml/opentype/horizontal-expected.txt: Removed. * platform/ios-simulator/mathml/opentype/horizontal-munderover-expected.txt: Removed. * platform/ios-simulator/mathml/opentype/large-operators-expected.txt: Removed. * platform/ios-simulator/mathml/opentype/opentype-stretchy-expected.png: Added. * platform/ios-simulator/mathml/opentype/opentype-stretchy-horizontal-expected.png: Added. * platform/ios-simulator/mathml/opentype/opentype-stretchy-horizontal-expected.txt: * platform/ios-simulator/mathml/opentype/vertical-expected.txt: Removed. * platform/ios-simulator/mathml/presentation/menclose-notation-default-longdiv-expected.png: Added. * platform/ios-simulator/mathml/presentation/menclose-notation-values-expected.png: Added. * platform/ios-simulator/mathml/presentation/mo-stretch-expected.png: Added. * platform/ios-simulator/mathml/presentation/mo-stretch-expected.txt: * platform/ios-simulator/mathml/presentation/mspace-children-expected.png: Added. * platform/ios-simulator/mathml/radical-fallback-expected.png: * platform/mac/TestExpectations: Update expectations. * platform/mac/mathml/opentype/horizontal-expected.txt: Removed. * platform/mac/mathml/opentype/horizontal-munderover-expected.txt: Removed. * platform/mac/mathml/opentype/large-operators-expected.txt: Removed. * platform/mac/mathml/opentype/opentype-stretchy-expected.png: Added. * platform/mac/mathml/opentype/vertical-expected.txt: Removed. * platform/mac/mathml/presentation/menclose-notation-values-expected.png: * platform/mac/mathml/presentation/menclose-notation-values-expected.txt: * platform/mac/mathml/presentation/mo-stretch-expected.png: * platform/mac/mathml/presentation/mo-stretch-expected.txt: * platform/mac/mathml/presentation/mspace-children-expected.png: Added. * platform/mac/mathml/presentation/roots-expected.png: * platform/mac/mathml/presentation/roots-expected.txt: * platform/mac/mathml/radical-fallback-expected.png: * platform/mac/mathml/radical-fallback-expected.txt: Canonical link: https://commits.webkit.org/177479@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202748 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-01 19:41:30 +00:00
to require a fallback mechanism as sans-serif are generally not math
MathOperator: Add fallback mechanisms for stretching and mirroring radical symbols https://bugs.webkit.org/show_bug.cgi?id=156836 Source/WebCore: Patch by Frederic Wang <fwang@igalia.com> on 2016-06-17 Reviewed by Sergio Villar Senin. Some platforms do not have OpenType MATH fonts pre-installed and thus can not draw stretchy operators using size variants or glyph assembly. This is especially problematic for the radical symbol which is used to write roots. Currently, we have some fallback code to draw that symbol using graphical primitives but it is a bit complex and makes the style of radical inconsistent with the font used. We solve these issues by just scaling the base glyph via a scale transform. Such scale transform is also used to mirror the radical symbol so that we have some support for right-to-left roots until we can do glyph-level mirroring via the OpenType rtlm feature. Test: mathml/radical-fallback.html * rendering/mathml/MathOperator.cpp: Add a constant for the code point U+221A of the radical. (WebCore::MathOperator::reset): In general, we don't need any vertical scaling for radical symbols so m_radicalVerticalScale is initialized to 1. (WebCore::MathOperator::calculateStretchyData): If we don't have a font with a MATH table and we try streching a radical, then we update the vertical metrics to match the target size and set m_radicalVerticalScale to the value necessary to make the base glyph scaled to that size. (WebCore::MathOperator::paint): For a radical operator, we may apply a scale transform of parameters (radicalHorizontalScale, m_radicalVerticalScale) in order to support RTL mirroring or vertical stretching. * rendering/mathml/MathOperator.h: We add a m_radicalVerticalScale member to indicate the scaling to apply to the base radical glyph when the stretchy fallback is necessary. (WebCore::MathOperator::isStretched): The operator is also considered stretched when the m_radicalVerticalScale is applied to the base size. * rendering/mathml/RenderMathMLRadicalOperator.cpp: Remove code specific to the old fallback mechanism. * rendering/mathml/RenderMathMLRadicalOperator.h: Ditto. LayoutTests: Reviewed by Sergio Villar Senin. We add a pixel test to verify the result of stretching a radical operator. We test RTL/LTR direction as well as default/sans-serif font in order to check the fallback code. * mathml/radical-fallback.html: Added. * platform/gtk/mathml/radical-fallback-expected.png: Added. * platform/gtk/mathml/radical-fallback-expected.txt: Added. * platform/ios-simulator/mathml/radical-fallback-expected.txt: Added. * platform/mac/mathml/radical-fallback-expected.png: Added. * platform/mac/mathml/radical-fallback-expected.txt: Added. * platform/ios-simulator/mathml/presentation/roots.txt: Updated. Canonical link: https://commits.webkit.org/176939@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202161 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-06-17 09:24:49 +00:00
fonts and so can not stretch radicals. -->
<p>Large LTR radicals:
<math>
<msqrt><mspace height="5em"/></msqrt>
<msqrt style="font-family: sans-serif"><mspace height="5em"/></msqrt>
</math>
</p>
<p>Large RTL radicals:
<math dir="rtl">
<msqrt><mspace height="5em"/></msqrt>
<msqrt style="font-family: sans-serif"><mspace height="5em"/></msqrt>
</math>
</p>
</body>
</html>