I see 2 lines were changed, the main - if 'face' in attrs and attrs['face'].lower() in self.font_list: + if 'face' in attrs:
but I still get File "/home/jurgis/web2py/applications/apskaitele/controllers/default.py" <https://jurgis.pythonanywhere.com/admin/default/edit/apskaitele/controllers/default.py>, line 61, in pdftest pdf.write_html(u"<font face='DejaVu'>Ąžuolas</font>") File "/home/jurgis/web2py/gluon/contrib/fpdf/html.py", line 397, in write_html File "/usr/local/lib/python2.7/HTMLParser.py", line 114, in feed self.goahead(0) File "/usr/local/lib/python2.7/HTMLParser.py", line 152, in goahead if i < j: self.handle_data(rawdata[i:j]) File "/home/jurgis/web2py/gluon/contrib/fpdf/html.py", line 122, in handle_data File "/home/jurgis/web2py/gluon/contrib/fpdf/fpdf.py", line 822, in write txt = self.normalize_text(txt) File "/home/jurgis/web2py/gluon/contrib/fpdf/fpdf.py", line 1012, in normalize_text txt = txt.encode('latin1') UnicodeEncodeError: 'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256) and if I pdf.write_html(u"<font face='DejaVu'>Ąžuolas</font>".encode('utf8')) I get Ä„Å3⁄4uolas On Sat, Apr 27, 2013 at 3:24 AM, Mariano Reingart <reing...@gmail.com>wrote: > Sorry, I misread the email. > > Unicode fonts were not supported in html2pdf. > > I've made a change to allow them, please update html.py: > > https://pyfpdf.googlecode.com/hg/fpdf/html.py > > Then, you need to load a ttf unicode font, and then pass it in <font> > face attribute: > > pdf=MyFPDF() > # add utf8 font > pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True) > # first page: > pdf.add_page() > pdf.write_html(u"<font face='DejaVu'>Ąžuolas</font>") > > For more info and complete code, see: > > https://code.google.com/p/pyfpdf/wiki/Web2Py > > Let me know if that works so I can update the docs and web2py contrib > version > > Best regards > Mariano Reingart > http://www.sistemasagiles.com.ar > http://reingart.blogspot.com > > > On Fri, Apr 26, 2013 at 11:45 PM, Mariano Reingart <reing...@gmail.com> > wrote: > > On Fri, Apr 26, 2013 at 11:42 PM, Mariano Reingart <reing...@gmail.com> > wrote: > >> On Fri, Apr 26, 2013 at 6:34 PM, Jonathan Lundell <jlund...@pobox.com> > wrote: > >>> On 26 Apr 2013, at 1:17 PM, Jurgis Pralgauskis > >>> <jurgis.pralgaus...@gmail.com> wrote: > >>> > >>> ok, SOLVED ttf issue for unicode example > >>> http://code.google.com/p/pyfpdf/wiki/Unicode > >>> just needed to create directory gluon > contrib > fpdf > font > >>> and place needed ttf files insited it :) > >>> then pdf.write(8, u"Ąžuolas") works fine > >>> > >>> > >>> The fpdf logic uses utf8 for fonts it sees as UTF-based, otherwise > latin-1. > >>> It looks to me as though either it isn't recognizing your fonts as > UTF, or > >>> there's some overlooked case that it's making a mistake with. Have a > look at > >>> FPDF.set_font: > >>> > >>> self.unifontsubset = (self.fonts[fontkey]['type'] == 'TTF') > >>> > >>> ...and make sure it's getting set. > >>> > >> > >> Yes, as Jhonatan saids, FPDF (and the PDF standard, BTW) only support > >> latin1 characters for standard font. > >> > >> If you need utf8 characters, you need to embeed a T > > > > You need to embed a UTF8 TTF font, for example: > > > > # Add a DejaVu Unicode font (uses UTF-8) > > # Supports more than 200 languages. For a coverage status see: > > # > http://dejavu.svn.sourceforge.net/viewvc/dejavu/trunk/dejavu-fonts/langcover.txt > > pdf.add_font('DejaVu', '', 'DejaVuSansCondensed.ttf', uni=True) > > > > (sorry, the previous message was sent incomplete) > > > > I'll try to enhance the docs about this, thank for reporting the issue > > > > Best regards > > > > Mariano Reingart > > http://www.sistemasagiles.com.ar > > http://reingart.blogspot.com > > -- > > --- > You received this message because you are subscribed to a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/KJDeQoLKw-M/unsubscribe?hl=en. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Jurgis Pralgauskis tel: 8-616 77613; Don't worry, be happy and make things better ;) http://galvosukykla.lt -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.