def test_greek_letters(self): pdf=FPDF() initPDF(pdf) setFontPDF(pdf,'symbol') p = lp.ListParser( lp.CommandParser(lp.ParagraphItemCreator) ) s = r'\alpha\beta\gamma' p.match( s ) self.assertTrue( p.hasMatch() ) res = p[0].docItem.writePDF()+' '+p[1].docItem.writePDF()+' '+p[2].docItem.writePDF() self.assertEquals( res, u'\u03b1 \u03b2 \u03b3') pdf.write(0, res) pdf.add_font('djv','','font/DejaVuSans.ttf',uni=True) pdf.set_font('djv','',12) pdf.write(0, u' \u23a8 \u23a7 \u23a9 \u23aa \u239e \u2320 \u2321 \u23ae') pdf.ln(10) pdf.add_font('smb','','font/Symbola.ttf',uni=True) pdf.set_font('smb','',12) pdf.write(0, u' \u23b7 \u03b1 \u03b2 \u03b3') pdf.ln(10) pdf.add_font('jax','','font/mathjax_amsregular.ttf',uni=True) pdf.set_font('jax','',12) pdf.write(0, u' abc \u23b7 \u03b1 \u03b2 \u03b3') pdf.ln(10) pdf.add_font('jax','','font/MathJax/ttf/mathjax_size1regular.ttf',uni=True) pdf.set_font('jax','',12) pdf.write(0, u' abc \u23b7 \u03b1 \u03b2 \u03b3') pdf.output('out/latex/test_greek_letters.pdf', 'F')
def test_Word_cellPDF(self): p = lp.WordParser() s = r'alpha\beta' p.match(s) self.assertTrue( p.hasMatch() ) self.assertEquals( p.getMatch(s), 'alpha') pdf=FPDF() initPDF(pdf) p.docItem.resizePDF( pdf ) p.docItem.cellPDF( pdf ) p.docItem.resizePDF( pdf, p.docItem.rect.x1() + 10, p.docItem.rect.y0() ) p.docItem.cellPDF( pdf ) p.docItem.resizePDF( pdf, p.docItem.rect.x1() + 10, p.docItem.rect.y0() ) p.docItem.cellPDF( pdf ) r = p.docItem.rect p = lp.CommandParser(lp.ParagraphItemCreator) p.match(r'\alpha') setFontPDF(pdf,'symbol') #pdf.set_font('DejaVu','',11) p.docItem.resizePDF( pdf, r.x1() + 10, r.y0() ) p.docItem.cellPDF( pdf ) pdf.output('out/latex/test_Word_cellPDF.pdf', 'F')
def test_Paragraph_cellPDF(self): p = lp.ParagraphParser() s = 'The year 1866 was marked by a bizarre development, an unexplained and downright inexplicable phenomenon that surely no one has forgotten. Without getting into those rumors that upset civilians in the seaports and deranged the public' s += r'\alpha, \beta, \gamma' p.match( s ) self.assertTrue( p.hasMatch() ) p.docItem.textAlignment = 'c' pdf=FPDF() initPDF(pdf) setFontPDF(pdf,'symbol') p.docItem.resizePDF(pdf) p.docItem.cellPDF(pdf) pdf.output('out/latex/test_Paragraph_cellPDF.pdf', 'F')