Re: Using Symbola or equivalent Unicode6 font with Reportlab

Robin Becker <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
Hi Mathieu,

On 20/02/2014 17:09, Mathieu Comandon wrote:
> Hi,
>
> I'm trying to generate a set of "superfonts" based on Symbola.ttf (
> http://users.teilar.gr/~g1951d/ ). The plan is to merge the regular fonts
> we use in our application with Symbola.ttf in order to allow printing
> almost any possible glyph.
>
I have looked for such a font without success.



> I tried generating a PDF from sources containing Unicode6 characters or
> non-latin alphabets (Japanese, Chinese, Arabic, Hebrew). Neither the
> composite Times + Symbola I created on FontForge nor the plain Symbola
> displayed the non Latin characters.
>
It's not clear exactly how you are doing the conversion. Are you creating a 
combined TTF? I have used MS Mincho & MS Gothic on windows and they are 
certainly able to display both latin & CJK / Arabic / etc etc. However, I'm not 
sure what parts of unicode you're referring to when you mention unicode 6.

As I understand it there are some issues in python 2.x unicode related to going 
outside the standard plane, but I'm not sure if that's what you mean.




> Before I go any further, like converting Symbola to a CIDFont, which if I
> understand is they right way to display non Latin characters, I would like
> to know if I'm heading into the right direction. Is this even possible, or
> am i going to hit a wall at some point ?

this code produces the attached pdf & png.
####################
def main():
	from reportlab.pdfbase.ttfonts import TTFont
	from reportlab.pdfbase.pdfmetrics import registerFont
	from reportlab.graphics.shapes import Drawing, String

	registerFont(TTFont('ms-mincho','/WINDOWS/Fonts/msmincho.ttc',subfontIndex=1))

	d = Drawing(400,200)
	d.add(String(10,190,u'ABCDE\u00c7\u2286\u211d\u20a3\u2657\u2677\u305b\u30f2\u3223\u52e3\u9d7a',fontName='ms-mincho',fontSize=10))
	d.save(formats=['pdf','png'],outDir='/tmp',fnRoot='test-fonts')

if __name__=='__main__':
	main()
###################

the character \u2677 is supposed to be 'white club suit', but it goes wrong in 
both PDF & PNG. I think there's a glyph there, but perhaps it has a bad 
definition or something and when we use freetype in the bitmap renderer 
something goes very wrong.
-- 
Robin Becker
test-fonts.pdf (application/pdf, 17.3 KB) - not displayed
test-fonts.png (image/png, 2.8 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.