Freetype render fonts differently than in Ubuntu
-
- Offline
- 1 year 6 days ago
- 2017-03-24
I want to put truetype font into the pucture in Alpine linux and this picture save or get bits values (load()).
This module I using in my user interface graphic display.
So i have been using python with pillow module which converts truetype fonts to bitmap (thanks freetype lib)
Actually in Ubuntu everything works fine:
Ubuntu example: http://i.imgur.com/e9TuHJl.jpg
but in Alpine text is rendering different (bad):
Alpine example: http://i.imgur.com/uKfA1wX.jpg
Version of Python is 3.5 (Ubuntu and Alpine are same)
Version of Pillow is 4.0.0 (Ubuntu and Alpine are same)
Freetype version
Ubuntu: libfreetype6-dev_2.6.1-0.1ubuntu2.1_amd64.deb
Alpine: freetype-2.7-r0
I use this simple script:
from PIL import Image from PIL import ImageDraw from PIL import ImageFont image = Image.new('1', (192, 64)) draw = ImageDraw.Draw(image) font = ImageFont.truetype('fnt/arial.ttf', 10) draw.text((0,0), 'Hello world!', font=font, fill = 1) font = ImageFont.truetype('fnt/arial.ttf', 15) draw.text((0,15), 'Hello world!', font=font, fill = 1) font = ImageFont.truetype('fnt/arial.ttf', 20) draw.text((0,40), 'Hello world!', font=font, fill = 1) image.save('test', 'JPEG')
Has anyone know why its render differently? I am 100% that font is loading from my directory (font file is same in Ubuntu & Alpine)
Thanks Mike
Finally when I have compiled older version of freetype (2.4.1 from https://github.com/LuaDist/freetype), output is fine (image from ubuntu = image from Alpine)