function testShouldLexBiggerFontTable() { $lexer = new JoshRibakoff_Note_SectionLexer(); $lexer->setInput(array('\\rtf\\ansi\\deff0', array('\\fonttbl{\\f0\\fnil\\fcharset0 Microsoft Sans Serif;}{\\f1\\fnil\\fcharset0 fnilMicrosoft Sans Serif;}{\\f2\\fnil\\fcharset204 fnilMicrosoft Sans Serif;}'), array('\\colortbl;\\red0\\green0\\blue0; \\red0\\green0\\blue255;\\red0\\green255\\blue255;\\red0\\green255\\ blue0;\\red255\\green0\\blue255;\\red255\\green0\\blue0;\\red255\\ green255\\blue0;\\red255\\green255\\blue255;'), array('\\stylesheet{\\fs20 \\snext0Normal;}'), array('\\info{\\author John Doe} {\\creatim\\yr1990\\mo7\\dy30\\hr10\\min48}{\\version1}{\\edmins0} {\\nofpages1}{\\nofwords0}{\\nofchars0}{\\vern8351}'), '\\widoctrl\\ftnbj \\sectd\\linex0\\endnhere \\pard\\plain \\fs20 This is plain text.\\par')); $expected = array('f0' => '\\fnil\\fcharset0 Microsoft Sans Serif', 'f1' => '\\fnil\\fcharset0 fnilMicrosoft Sans Serif', 'f2' => '\\fnil\\fcharset204 fnilMicrosoft Sans Serif'); $this->assertEquals($expected, $lexer->fontTable(), 'should lex out more complex font table'); }
/** Set the RTF text this Note object should represent. Overwrites any previously set RTF data. */ function setRTF($rtf) { $this->raw_rtf = $rtf; $rtf = $this->stripOuterBraces($rtf); $tree = $this->convertBracesToArray($rtf); // find 'text' section (last element of tree array) and escape RTF tokens (brace lexer un-escapes them) $textSection = $tree[count($tree) - 1]; $textSection = str_replace('{', '\\{', $textSection); $textSection = str_replace('}', '\\}', $textSection); $tree[count($tree) - 1] = $textSection; $sectionLexer = new JoshRibakoff_Note_SectionLexer(); $sectionLexer->setInput($tree); $this->rtf_fonttable = $sectionLexer->fontTable(); $this->rtf_colortable = $sectionLexer->colorTable(); $this->rtf_text_pieces = $sectionLexer->textPieces(); $this->rtf_text = $sectionLexer->text(); }