[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] Width of space element
From: |
Lawrence D'Oliveiro |
Subject: |
Re: [ft] Width of space element |
Date: |
Sat, 26 Nov 2016 08:11:26 +1300 |
I wrote:
> Watch out for hinting and size settings:
> ...
> font.set_char_size(size = 1.0, resolution = freetype.base_dpi)
^^^
Sorry, try that again:
import sys
import freetype2 as freetype
from freetype2 import \
FT
l = freetype.Library()
font = l.new_face("corefonts/arial.ttf")
sys.stdout.write("family name = %s\n" % font.family_name)
for size in (1.0, 24.0) :
font.set_char_size(size = size, resolution = freetype.base_dpi)
for char in (" ", "W") :
for hinting, load_flags in \
(
("no", FT.LOAD_NO_HINTING),
("yes", FT.LOAD_DEFAULT),
) \
:
font.load_char(char_code = ord(char), load_flags = load_flags)
sys.stdout.write \
(
"char %d, size = %.3g, hinting = %s, metrics = %s,
glyph metrics = %s\n"
%
(ord(char), size, hinting, font.glyph.metrics,
font.glyph.metrics)
)
#end for load_flags
#end for char
#end for size
producing output
family name = Arial
char 32, size = 1, hinting = no, metrics = {'width': 0.0, 'vertAdvance':
0.9375, 'vertBearingY': 0.46875, 'vertBearingX': -0.140625, 'height': 0.0,
'horiBearingX': 0.0, 'horiAdvance': 0.28125, 'horiBearingY': 0.0}, glyph
metrics = {'width': 0.0, 'vertAdvance': 0.9375, 'vertBearingY': 0.46875,
'vertBearingX': -0.140625, 'height': 0.0, 'horiBearingX': 0.0, 'horiAdvance':
0.28125, 'horiBearingY': 0.0}
char 32, size = 1, hinting = yes, metrics = {'width': 0.0, 'vertAdvance':
1.0, 'vertBearingY': 0.0, 'vertBearingX': -1.0, 'height': 0.0, 'horiBearingX':
0.0, 'horiAdvance': 0.0, 'horiBearingY': 0.0}, glyph metrics = {'width': 0.0,
'vertAdvance': 1.0, 'vertBearingY': 0.0, 'vertBearingX': -1.0, 'height': 0.0,
'horiBearingX': 0.0, 'horiAdvance': 0.0, 'horiBearingY': 0.0}
char 87, size = 1, hinting = no, metrics = {'width': 0.921875,
'vertAdvance': 0.9375, 'vertBearingY': 0.109375, 'vertBearingX': -0.453125,
'height': 0.71875, 'horiBearingX': 0.015625, 'horiAdvance': 0.9375,
'horiBearingY': 0.71875}, glyph metrics = {'width': 0.921875, 'vertAdvance':
0.9375, 'vertBearingY': 0.109375, 'vertBearingX': -0.453125, 'height': 0.71875,
'horiBearingX': 0.015625, 'horiAdvance': 0.9375, 'horiBearingY': 0.71875}
char 87, size = 1, hinting = yes, metrics = {'width': 1.0, 'vertAdvance':
1.0, 'vertBearingY': 0.0, 'vertBearingX': -1.0, 'height': 1.0, 'horiBearingX':
0.0, 'horiAdvance': 1.0, 'horiBearingY': 1.0}, glyph metrics = {'width': 1.0,
'vertAdvance': 1.0, 'vertBearingY': 0.0, 'vertBearingX': -1.0, 'height': 1.0,
'horiBearingX': 0.0, 'horiAdvance': 1.0, 'horiBearingY': 1.0}
char 32, size = 24, hinting = no, metrics = {'width': 0.0, 'vertAdvance':
28.15625, 'vertBearingY': 14.078125, 'vertBearingX': -4.15625, 'height': 0.0,
'horiBearingX': 0.0, 'horiAdvance': 8.328125, 'horiBearingY': 0.0}, glyph
metrics = {'width': 0.0, 'vertAdvance': 28.15625, 'vertBearingY': 14.078125,
'vertBearingX': -4.15625, 'height': 0.0, 'horiBearingX': 0.0, 'horiAdvance':
8.328125, 'horiBearingY': 0.0}
char 32, size = 24, hinting = yes, metrics = {'width': 0.0, 'vertAdvance':
28.0, 'vertBearingY': 14.0, 'vertBearingX': -5.0, 'height': 0.0,
'horiBearingX': 0.0, 'horiAdvance': 8.0, 'horiBearingY': 0.0}, glyph metrics =
{'width': 0.0, 'vertAdvance': 28.0, 'vertBearingY': 14.0, 'vertBearingX': -5.0,
'height': 0.0, 'horiBearingX': 0.0, 'horiAdvance': 8.0, 'horiBearingY': 0.0}
char 87, size = 24, hinting = no, metrics = {'width': 27.625,
'vertAdvance': 28.15625, 'vertBearingY': 3.34375, 'vertBearingX': -13.796875,
'height': 21.46875, 'horiBearingX': 0.359375, 'horiAdvance': 28.3125,
'horiBearingY': 21.46875}, glyph metrics = {'width': 27.625, 'vertAdvance':
28.15625, 'vertBearingY': 3.34375, 'vertBearingX': -13.796875, 'height':
21.46875, 'horiBearingX': 0.359375, 'horiAdvance': 28.3125, 'horiBearingY':
21.46875}
char 87, size = 24, hinting = yes, metrics = {'width': 29.0, 'vertAdvance':
28.0, 'vertBearingY': 3.0, 'vertBearingX': -15.0, 'height': 22.0,
'horiBearingX': 0.0, 'horiAdvance': 30.0, 'horiBearingY': 22.0}, glyph metrics
= {'width': 29.0, 'vertAdvance': 28.0, 'vertBearingY': 3.0, 'vertBearingX':
-15.0, 'height': 22.0, 'horiBearingX': 0.0, 'horiAdvance': 30.0,
'horiBearingY': 22.0}