svgio: font-variation-settings is an inherited property
It is inherited per CSS Fonts, so the children of a group must inherit it when set on the group. Change-Id: I3a7f1c58b249e0d647c3b8a15f9e2043b7d6c891 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209212 Reviewed-by: Khaled Hosny <khaled@libreoffice.org> Tested-by: Jenkins
This commit is contained in:
committed by
Khaled Hosny
parent
f998b64054
commit
02c7caae9a
@@ -422,7 +422,7 @@ namespace svgio::svgreader
|
||||
void setFontWeight(const FontWeight aFontWeight) { maFontWeight = aFontWeight; }
|
||||
|
||||
/// FontVariations content
|
||||
const std::vector<vcl::font::Variation>& getFontVariations() const { return maFontVariations; }
|
||||
const std::vector<vcl::font::Variation>& getFontVariations() const;
|
||||
void setFontVariations(std::vector<vcl::font::Variation>&& rFontVariations) { maFontVariations = std::move(rFontVariations); }
|
||||
|
||||
/// FontDirection content
|
||||
|
||||
@@ -2293,6 +2293,21 @@ CPPUNIT_TEST_FIXTURE(Test, testFontVariationSettings)
|
||||
assertXPath(pDocument, "//textsimpleportion[7]", "font-variation-settings", u"\"wght\" 700");
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(Test, testFontVariationSettingsInherit)
|
||||
{
|
||||
// font-variation-settings is an inherited property.
|
||||
xmlDocUniquePtr pDocument
|
||||
= dumpAndParseSvg(u"/svgio/qa/cppunit/data/font-variation-settings-inherit.svg");
|
||||
|
||||
assertXPath(pDocument, "//textsimpleportion", 3);
|
||||
// inherited from the group
|
||||
assertXPath(pDocument, "//textsimpleportion[1]", "font-variation-settings", u"\"wght\" 300");
|
||||
// the child's own list replaces the inherited one, it does not merge with it
|
||||
assertXPath(pDocument, "//textsimpleportion[2]", "font-variation-settings", u"\"wght\" 700");
|
||||
// the script of the text makes no difference
|
||||
assertXPath(pDocument, "//textsimpleportion[3]", "font-variation-settings", u"\"wght\" 300");
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<g font-family="Reem Kufi" font-variation-settings="'wght' 300">
|
||||
<text y="1em">Inherited</text>
|
||||
<text y="2em" style="font-variation-settings: 'wght' 700">Overridden</text>
|
||||
<text y="3em" font-family="Noto Sans Arabic">مرحبا</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 304 B |
@@ -1367,7 +1367,7 @@ namespace svgio::svgreader
|
||||
maBaselineShift(BaselineShift::Baseline),
|
||||
maBaselineShiftNumber(0),
|
||||
maDominantBaseline(DominantBaseline::Auto),
|
||||
maResolvingParent(36, 0),
|
||||
maResolvingParent(37, 0),
|
||||
mbStrokeDasharraySet(false),
|
||||
mbUseFillFromContextFill(false),
|
||||
mbUseFillFromContextStroke(false),
|
||||
@@ -2843,6 +2843,28 @@ namespace svgio::svgreader
|
||||
return FontStyle::normal;
|
||||
}
|
||||
|
||||
const std::vector<vcl::font::Variation>& SvgStyleAttributes::getFontVariations() const
|
||||
{
|
||||
if (!maFontVariations.empty())
|
||||
{
|
||||
return maFontVariations;
|
||||
}
|
||||
|
||||
const SvgStyleAttributes* pSvgStyleAttributes = getCssStyleOrParentStyle();
|
||||
|
||||
if (pSvgStyleAttributes && maResolvingParent[36] < nStyleDepthLimit)
|
||||
{
|
||||
++maResolvingParent[36];
|
||||
const std::vector<vcl::font::Variation>& rInherited
|
||||
= pSvgStyleAttributes->getFontVariations();
|
||||
--maResolvingParent[36];
|
||||
|
||||
return rInherited;
|
||||
}
|
||||
|
||||
return maFontVariations;
|
||||
}
|
||||
|
||||
FontWeight SvgStyleAttributes::getFontWeight() const
|
||||
{
|
||||
if(maFontWeight != FontWeight::notset)
|
||||
|
||||
Reference in New Issue
Block a user