Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Font Size Calculated by MsDoc Reader #2531

Merged
merged 4 commits into from
Dec 28, 2023

Conversation

oleibman
Copy link
Contributor

Description

Fix #2526. Most of that issue has already been fixed. The one remaining problem was a deprecation message handling font size. The code used dechex($operand / 2), and issued the deprecation message whenever $operand was odd because dechex is designed only for integer conversion. $operand is actually 2 times the point size, so it will be odd only when the point size is some integer plus half a point (no other fractions are allowed). At any rate, it seems that dechex should not be used here in the first place; font size is a numeric value, not a hex string.

There are many problems with MsDoc Reader at the moment. This PR is narrowly focused on the problem at hand. Its test is, at least, more detailed than the existing MsDoc Reader test, which does nothing more than confirm that read successfully creates a PhpWord object. The new test verifies that the font size is as expected, but does not validate any other aspect of the read.

Fix #2526

Checklist:

  • I have run composer run-script check --timeout=0 and no errors were reported
  • The new code is covered by unit tests (check build/coverage for coverage report)
  • I have updated the documentation to describe the changes

Fix PHPOffice#2526. Most of that issue has already been fixed. The one remaining problem was a deprecation message handling font size. The code used `dechex($operand / 2)`, and issued the deprecation message whenever `$operand` was odd because `dechex` is designed only for integer conversion. `$operand` is actually 2 times the point size, so it will be odd only when the point size is some integer plus half a point (no other fractions are allowed). At any rate, it seems that `dechex` should not be used here in the first place; font size is a numeric value, not a hex string.

There are many problems with MsDoc Reader at the moment. This PR is narrowly focused on the problem at hand. Its test is, at least, more detailed than the existing MsDoc Reader test, which does nothing more than confirm that read successfully creates a PhpWord object. The new test verifies that the font size is as expected, but does not validate any other aspect of the read.
@coveralls
Copy link

coveralls commented Dec 17, 2023

Coverage Status

coverage: 97.212% (+1.7%) from 95.532%
when pulling 0709ae3 on oleibman:word2526
into e76b701 on PHPOffice:master.

Copy link
Member

@Progi1984 Progi1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oleibman A small feedback ?

Could you create a 1.3.0.md file for changelog?

tests/PhpWordTests/Reader/MsDocTest.php Outdated Show resolved Hide resolved
@Progi1984 Progi1984 added this to the 2.0.0 milestone Dec 18, 2023
@Progi1984 Progi1984 merged commit 903c7a3 into PHPOffice:master Dec 28, 2023
13 checks passed
@Progi1984 Progi1984 deleted the word2526 branch December 28, 2023 08:16
@Progi1984
Copy link
Member

Thanks @oleibman. It's the first contribution for PhpWord 2.0

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.

Deprecated: Implicit conversion from float 10.5 to int loses precision
3 participants