Glyph object
Glyph()
#
#
Syntax#
ParametersName | R/O | Type | Default Value | Description |
---|---|---|---|---|
meta_dict | Required | dictionary (string as keys, integer or string as values) | N/A | dictionary of the meta information |
font | Required | Font object | N/A | The font the glyph belongs to |
#
Return valueGlyph object
#
DescriptionInitialize a Glyph object. Load a dictionary of meta information and the font the glyph belongs.
note
Usually you get the glyph object from font.glyph(character) and do not need to use Glyph()
.
.meta
#
#
Syntax#
Examples#
Typedictionary (string as keys, integer or string or list as values)
#
DescriptionThe glyph's meta data.
Glyph meta information's names (keys), value types, and their descriptions in the BDF spec:
'glyphname'
: (string) seeSTARTCHAR
'codepoint'
: (integer) seeENCODING
'bbw'
: (integer) seeBBX
'bbh'
: (integer) seeBBX
'bbxoff'
: (integer) seeBBX
'bbyoff'
: (integer) seeBBX
'swx0'
: (integer) seeSWIDTH
'swy0'
: (integer) seeSWIDTH
'dwx0'
: (integer) seeDWIDTH
'dwy0'
: (integer) seeDWIDTH
'swx1'
: (integer) seeSWIDTH1
'swy1'
: (integer) seeSWIDTH1
'dwx1'
: (integer) seeDWIDTH1
'dwy1'
: (integer) seeDWIDTH1
'vvectorx'
: (integer) seeVVECTOR
'vvectory'
: (integer) seeVVECTOR
'hexdata'
: (list of strings) the glyph's shape data in the form of list of hexadecimal-encoded string
note
.font
#
#
Syntax#
Examples#
TypeFont object
#
DescriptionIt's a reference to the glyph's font object.
.cp()
#
#
Syntax#
Examples#
ParametersNo parameters
#
Return value(integer) codepoint of the glyph
#
DescriptionGet the codepoint of the glyph.
.chr()
#
#
Syntax#
Examples#
ParametersNo parameters
#
Return value(string) character (one character string) of the glyph
#
DescriptionGet the character of the glyph.
.draw()
#
#
Syntax#
ExamplesIn these examples, we use the "quoteright" ('
) glyph in the BDF spec's example figure 3.
Click to see the output of quoteright.draw()
(with default mode 0)
Click to see the output of quoteright.draw(1)
Click to see the output of quoteright.draw(2)
Click to see the output of quoteright.draw(-1, (6, 17, 1, 1))
#
ParametersName | R/O | Type | Default Value | Description |
---|---|---|---|---|
mode | Optional | integer | 0 | See below |
bb | Optional | tuple of four integers | None | See below |
mode
can be:
0
(default): area represented by the bitmap hex data, positioned and resized (cropped) (fbbx
×fbby
) according toFONTBOUNDINGBOX
(the font's global bounding box)1
: area represented by the bitmap hex data, resized (cropped) according toBBX
(bbw
×bbh
), which is the individual glyph bounding box, without unnecessary blank margin (but still possible to have blank margin sometimes)2
: area represented by the bitmap hex data, original, without removing the right-padded'0'
s-1
: user specified area.bb
parameter is useless when mode-1
is not chosen. But if mode-1
is chosen, you MUST specifybb
parameter, which is a tuple(bbx, bby, bbxoff, bbyoff)
representing your customized font bounding box. Similar toFONTBOUNDINGBOX
,bbx
andbby
represent the size,bbxoff
andbbyoff
represent the relative position (displacement) of the starting (bottom-left) point from the origin
#
Return valueBitmap object
#
DescriptionDraw the glyph to a Bitmap object.
.origin()
#
#
Syntax#
Examples#
ParametersName | R/O | Type | Default Value | Description |
---|---|---|---|---|
mode | Optional | integer | 0 | Same as .draw() 's mode parameter |
fromorigin | Optional | boolean | False | False : to the originTrue : from the origin |
xoff | Optional | integers | None | See below |
yoff | Optional | integers | None | See below |
Similar to .draw()
, xoff
and yoff
parameters are useless when mode -1
is not chosen, but if mode=-1
in .origin()
, you MUST specify xoff
and yoff
, which are equivalent to bb[2]
("bbxoff") and bb[3]
("bbyoff") in the method .draw()
.
#
Return value(tuple of two integers) The relative position (displacement) represented by (x, y)
tuple (where right and top directions are positive)
#
DescriptionGet the relative position (displacement) of the origin from the left bottom corner of the bitmap drawn by the method .draw()
, or vice versa (i.e. displacement of the left bottom corner of the bitmap from the origin).
str()
and print()
#
#
Syntax#
ExamplesClick to see the output of str(quoteright)
#
Description(string) str()
gets a human-readable (multi-line) string representation of the Glyph object. It's actually the string converted from .draw()
with default parameters.
print()
prints a human-readable (multi-line) string representation of the Glyph object.
See also str()
and print()
for Bitmap object
repr()
#
#
Syntax#
Examples#
Description(string) It gets a programmer-readable string representation of the Glyph object.