Skip to content

Commit 903c7a3

Browse files
authored
Merge pull request #2531 from oleibman/word2526
Correct Font Size Calculated by MsDoc Reader
2 parents e76b701 + 0709ae3 commit 903c7a3

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

docs/changes/1.x/1.3.0.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# [1.3.0](https://github.com/PHPOffice/PHPWord/tree/1.3.0) (WIP)
2+
3+
[Full Changelog](https://github.com/PHPOffice/PHPWord/compare/1.2.0...1.3.0)
4+
5+
## Enhancements
6+
7+
### Bug fixes
8+
9+
- 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)
10+
11+
### Miscellaneous
12+
13+
14+
### BC Breaks

src/PhpWord/Reader/MsDoc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,7 @@ private function readPrl($data, $pos, $cbNum)
18711871
break;
18721872
// sprmCHps
18731873
case 0x43:
1874-
$oStylePrl->styleFont['size'] = dechex($operand / 2);
1874+
$oStylePrl->styleFont['size'] = $operand / 2;
18751875

18761876
break;
18771877
// sprmCIss

tests/PhpWordTests/Reader/MsDocTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ public function testLoad(): void
6060
self::assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $phpWord);
6161
}
6262

63+
public function testLoadHalfPointFont(): void
64+
{
65+
$filename = __DIR__ . '/../_files/documents/reader.font-halfpoint.doc';
66+
$phpWord = IOFactory::load($filename, 'MsDoc');
67+
$sections = $phpWord->getSections();
68+
self::assertCount(1, $sections);
69+
$elements = $sections[0]->getElements();
70+
self::assertArrayHasKey(0, $elements);
71+
$element0 = $elements[0];
72+
if (method_exists($element0, 'getFontStyle')) {
73+
self::assertSame(19.5, $element0->getFontStyle()->getSize());
74+
} else {
75+
self::fail('Unexpected no font style for first element');
76+
}
77+
}
78+
6379
/**
6480
* Test exception on not existing file.
6581
*/
Binary file not shown.

0 commit comments

Comments
 (0)