1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
<?php
use PHPUnit\Framework\TestCase;
use RtfHtmlPhp\Document;
use RtfHtmlPhp\Html\HtmlFormatter;
class FontFamilyTest extends TestCase
{
public function testParseFontFamilyHtml()
{
$rtf = file_get_contents("tests/rtf/fonts.rtf");
$document = new Document($rtf);
$formatter = new HtmlFormatter();
$html = $formatter->format($document);
$this->assertEquals(
'<p><span style="font-family:Arial,sans-serif;font-size:15px;">Hello, world.</span></p>',
$html
);
$expected = <<<EOT
{
WORD rtf (1)
WORD ansi (1)
WORD ansicpg (1252)
WORD deff (0)
WORD nouicompat (1)
WORD deflang (1033)
{
WORD fonttbl (1)
{
WORD f (0)
WORD fswiss (1)
WORD fcharset (0)
TEXT Arial;
}
}
{
SYMBOL * (0)
WORD generator (1)
TEXT Riched20 10.0.18362
}
WORD viewkind (4)
WORD uc (1)
WORD pard (1)
WORD sa (200)
WORD sl (276)
WORD slmult (1)
WORD fs (22)
WORD lang (9)
TEXT Hello, world.
WORD par (1)
}
EOT;
$this->assertSame($expected, (string) $document);
}
}
|