Skip to content

Commit 8bdcd40

Browse files
authored
Merge pull request #70 from Leshana/fix-font-family
Fix placing comma between font-family names.
2 parents e4cff76 + f93afb8 commit 8bdcd40

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/Html/Font.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public function toStyle(): string {
1414
if($this->name) array_push($list, $this->name);
1515
if($this->family) array_push($list, $this->family);
1616
if(sizeof($list) == 0) return "";
17-
return "font-family:" . join($list) . ";";
17+
return "font-family:" . join($list, ',') . ";";
1818
}
1919
}

tests/FontFamilyTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
use PHPUnit\Framework\TestCase;
4+
use RtfHtmlPhp\Document;
5+
use RtfHtmlPhp\Html\HtmlFormatter;
6+
7+
final class FontFamilyTestTest extends TestCase
8+
{
9+
public function testParseFontFamilyHtml(): void
10+
{
11+
$rtf = file_get_contents("tests/rtf/fonts.rtf");
12+
$document = new Document($rtf);
13+
$formatter = new HtmlFormatter();
14+
$html = $formatter->Format($document);
15+
16+
$this->assertEquals(
17+
'<p><span style="font-family:Arial,sans-serif;font-size:15px;">Hello, world.</span></p>',
18+
$html
19+
);
20+
}
21+
}

tests/rtf/fonts.rtf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
2+
{\*\generator Riched20 10.0.18362}\viewkind4\uc1
3+
\pard\sa200\sl276\slmult1\fs22\lang9 Hello, world.\par
4+
}

0 commit comments

Comments
 (0)