Glyph object
Glyph()#
Syntax#
Parameters#
| Name | 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 value#
Glyph object
Description#
Initialize 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#
Type#
dictionary (string as keys, integer or string or list as values)
Description#
The 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#
Type#
Font object
Description#
It's a reference to the glyph's font object.
.cp()#
Syntax#
Examples#
Parameters#
No parameters
Return value#
(integer) codepoint of the glyph
Description#
Get the codepoint of the glyph.
.chr()#
Syntax#
Examples#
Parameters#
No parameters
Return value#
(string) character (one character string) of the glyph
Description#
Get the character of the glyph.
.draw()#
Syntax#
Examples#
In 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))
Parameters#
| Name | 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.bbparameter is useless when mode-1is not chosen. But if mode-1is chosen, you MUST specifybbparameter, which is a tuple(bbx, bby, bbxoff, bbyoff)representing your customized font bounding box. Similar toFONTBOUNDINGBOX,bbxandbbyrepresent the size,bbxoffandbbyoffrepresent the relative position (displacement) of the starting (bottom-left) point from the origin
Return value#
Bitmap object
Description#
Draw the glyph to a Bitmap object.
.origin()#
Syntax#
Examples#
Parameters#
| Name | 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)
Description#
Get 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#
Examples#
Click 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.