Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
MathOperator: Add fallback mechanisms for stretching and mirroring ra…
…dical 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
- Loading branch information