[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 07:58:41 +1300 |
On Fri, 25 Nov 2016 18:22:55 +0000, Olumide wrote:
> On 25/11/2016 17:25, Lawrence D'Oliveiro wrote:
>> On Fri, 25 Nov 2016 13:02:39 +0000, Olumide wrote:
>>
>>> FreeType assigns a zero width of to the space character
>>> (Arial.ttf).
>>
>> That can’t be right. Are you sure you are looking at the glyph
>> metrics, not the dimensions of the bitmap?
>
> Just had a look at glyph metrics. Glyph width, height, bearings Y and
> X are all zero.
Watch out for hinting and size settings:
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 = 1.0, 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
family name = Arial
char 32, size = 1, hinting = no, metrics = {'vertBearingY': 0.46875,
'height': 0.0, 'horiBearingY': 0.0, 'horiBearingX': 0.0, 'vertAdvance': 0.9375,
'horiAdvance': 0.28125, 'vertBearingX': -0.140625, 'width': 0.0}, glyph metrics
= {'vertBearingY': 0.46875, 'height': 0.0, 'horiBearingY': 0.0, 'horiBearingX':
0.0, 'vertAdvance': 0.9375, 'horiAdvance': 0.28125, 'vertBearingX': -0.140625,
'width': 0.0}
char 32, size = 1, hinting = yes, metrics = {'vertBearingY': 0.0, 'height':
0.0, 'horiBearingY': 0.0, 'horiBearingX': 0.0, 'vertAdvance': 1.0,
'horiAdvance': 0.0, 'vertBearingX': -1.0, 'width': 0.0}, glyph metrics =
{'vertBearingY': 0.0, 'height': 0.0, 'horiBearingY': 0.0, 'horiBearingX': 0.0,
'vertAdvance': 1.0, 'horiAdvance': 0.0, 'vertBearingX': -1.0, 'width': 0.0}
char 87, size = 1, hinting = no, metrics = {'vertBearingY': 0.109375,
'height': 0.71875, 'horiBearingY': 0.71875, 'horiBearingX': 0.015625,
'vertAdvance': 0.9375, 'horiAdvance': 0.9375, 'vertBearingX': -0.453125,
'width': 0.921875}, glyph metrics = {'vertBearingY': 0.109375, 'height':
0.71875, 'horiBearingY': 0.71875, 'horiBearingX': 0.015625, 'vertAdvance':
0.9375, 'horiAdvance': 0.9375, 'vertBearingX': -0.453125, 'width': 0.921875}
char 87, size = 1, hinting = yes, metrics = {'vertBearingY': 0.0, 'height':
1.0, 'horiBearingY': 1.0, 'horiBearingX': 0.0, 'vertAdvance': 1.0,
'horiAdvance': 1.0, 'vertBearingX': -1.0, 'width': 1.0}, glyph metrics =
{'vertBearingY': 0.0, 'height': 1.0, 'horiBearingY': 1.0, 'horiBearingX': 0.0,
'vertAdvance': 1.0, 'horiAdvance': 1.0, 'vertBearingX': -1.0, 'width': 1.0}
char 32, size = 24, hinting = no, metrics = {'vertBearingY': 0.46875,
'height': 0.0, 'horiBearingY': 0.0, 'horiBearingX': 0.0, 'vertAdvance': 0.9375,
'horiAdvance': 0.28125, 'vertBearingX': -0.140625, 'width': 0.0}, glyph metrics
= {'vertBearingY': 0.46875, 'height': 0.0, 'horiBearingY': 0.0, 'horiBearingX':
0.0, 'vertAdvance': 0.9375, 'horiAdvance': 0.28125, 'vertBearingX': -0.140625,
'width': 0.0}
char 32, size = 24, hinting = yes, metrics = {'vertBearingY': 0.0,
'height': 0.0, 'horiBearingY': 0.0, 'horiBearingX': 0.0, 'vertAdvance': 1.0,
'horiAdvance': 0.0, 'vertBearingX': -1.0, 'width': 0.0}, glyph metrics =
{'vertBearingY': 0.0, 'height': 0.0, 'horiBearingY': 0.0, 'horiBearingX': 0.0,
'vertAdvance': 1.0, 'horiAdvance': 0.0, 'vertBearingX': -1.0, 'width': 0.0}
char 87, size = 24, hinting = no, metrics = {'vertBearingY': 0.109375,
'height': 0.71875, 'horiBearingY': 0.71875, 'horiBearingX': 0.015625,
'vertAdvance': 0.9375, 'horiAdvance': 0.9375, 'vertBearingX': -0.453125,
'width': 0.921875}, glyph metrics = {'vertBearingY': 0.109375, 'height':
0.71875, 'horiBearingY': 0.71875, 'horiBearingX': 0.015625, 'vertAdvance':
0.9375, 'horiAdvance': 0.9375, 'vertBearingX': -0.453125, 'width': 0.921875}
char 87, size = 24, hinting = yes, metrics = {'vertBearingY': 0.0,
'height': 1.0, 'horiBearingY': 1.0, 'horiBearingX': 0.0, 'vertAdvance': 1.0,
'horiAdvance': 1.0, 'vertBearingX': -1.0, 'width': 1.0}, glyph metrics =
{'vertBearingY': 0.0, 'height': 1.0, 'horiBearingY': 1.0, 'horiBearingX': 0.0,
'vertAdvance': 1.0, 'horiAdvance': 1.0, 'vertBearingX': -1.0, 'width': 1.0}