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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/changes/1.x/1.3.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# [1.3.0](https://github.com/PHPOffice/PHPWord/tree/1.3.0) (WIP)

[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.2.0...1.3.0)

## Enhancements

### Bug fixes

- MsDoc Reader : Correct Font Size Calculation by [@oleibman](https://github.com/oleibman) Issue [#2526](https://github.com/PHPOffice/PHPWord/issues/2526) PR [#2531](https://github.com/PHPOffice/PHPWord/pull/2531)

### Miscellaneous


### BC Breaks
2 changes: 1 addition & 1 deletion src/PhpWord/Reader/MsDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@ private function readPrl($data, $pos, $cbNum)
break;
// sprmCHps
case 0x43:
$oStylePrl->styleFont['size'] = dechex($operand / 2);
$oStylePrl->styleFont['size'] = $operand / 2;

break;
// sprmCIss
Expand Down
16 changes: 16 additions & 0 deletions tests/PhpWordTests/Reader/MsDocTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ public function testLoad(): void
self::assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $phpWord);
}

public function testLoadHalfPointFont(): void
{
$filename = __DIR__ . '/../_files/documents/reader.font-halfpoint.doc';
$phpWord = IOFactory::load($filename, 'MsDoc');
$sections = $phpWord->getSections();
self::assertCount(1, $sections);
$elements = $sections[0]->getElements();
self::assertArrayHasKey(0, $elements);
$element0 = $elements[0];
if (method_exists($element0, 'getFontStyle')) {
self::assertSame(19.5, $element0->getFontStyle()->getSize());
} else {
self::fail('Unexpected no font style for first element');
}
}

/**
* Test exception on not existing file.
*/
Expand Down
Binary file not shown.
Loading