Skip to content

Style\Font : Raise a superscript by 30% and not by 300% - #998

Merged
Progi1984 merged 2 commits into
PHPOffice:masterfrom
sapientpro:fix/baseline-superscript-scale
Sep 8, 2026
Merged

Progi1984 merged 2 commits into
PHPOffice:masterfrom
sapientpro:fix/baseline-superscript-scale

Conversation

@dkulyk

@dkulyk dkulyk commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

Font::BASELINE_SUPERSCRIPT is 300000 and BASELINE_SUBSCRIPT is -250000. The baseline
attribute is written in thousandths of a percent, so those ask for a 300% raise and a 250% drop and
the character lands on a line of its own.

before after

30000 and -25000 are what 0.9.0 wrote, before the constants replaced the hard-coded values in
ec4700e, and what LibreOffice uses
for the same thing: oox/source/drawingml/textcharacterpropertiescontext.cxx maps
<w:vertAlign w:val="superscript"/> to baseline = 30000 and subscript to -25000. On import it
reads CharEscapement = baseline / 1000 and treats it as a percentage, which is why 300000 renders
as a 300% raise rather than being ignored.

Note this is not a schema violation -- baseline is ST_Percentage, unbounded in
tests/resources/schema/ecma-376/dml-main.xsd, and a slide carrying 300000 validates. The value
is simply ten times too large.

.odp is unaffected: the ODPresentation Writer does not write style:text-position at all, so
superscript is dropped there whatever the constant says. Separate matter.

Fixes #997

Checklist:

  • My CI is 🟢

The unit tests pass, 1123 tests and 9172 assertions. The seven PHP Static Analysis jobs fail on master itself since phpoffice/common 1.1.0. PHPOffice/Common#64 dropped the <\DOMElement> from XMLReader::getElements()'s @return \DOMNodeList, so a node it yields is now inferred as DOMNode -- 18 errors, all in Reader/PowerPoint2007.php, none from this branch. git checkout master && composer update phpoffice/common && vendor/bin/phpstan analyse reproduces them.

  • I have covered by unit tests my new code (check build/coverage for coverage report)

The ten assertions in PptSlidesTest and PptChartsTest that pinned the written attribute now pin the corrected value.

docs/usage/styles.md carried the old values and called the unit a percentage.

docs/changes/1.3.0.md.

@coveralls

coveralls commented Sep 7, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 94.091%. remained the same — sapientpro:fix/baseline-superscript-scale into PHPOffice:master

The baseline attribute is written in thousandths of a percent, so
BASELINE_SUPERSCRIPT of 300000 asks for a 300% raise and puts the character on
a line of its own. 0.9.0 wrote 30000 and -25000 before the constants replaced
the hard-coded values, and LibreOffice uses those same two numbers when it maps
w:vertAlign to baseline.
@dkulyk
dkulyk force-pushed the fix/baseline-superscript-scale branch from a9dfba9 to 6730d19 Compare September 8, 2026 08:01
@Progi1984 Progi1984 added this to the 1.3.0 milestone Sep 8, 2026
@Progi1984
Progi1984 merged commit d0ada42 into PHPOffice:master Sep 8, 2026
26 checks passed
@dkulyk
dkulyk deleted the fix/baseline-superscript-scale branch September 8, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Font::BASELINE_SUPERSCRIPT / BASELINE_SUBSCRIPT values are out of OOXML valid range, causing broken vertical text rendering

3 participants