Skip to content

Custom Font Format

Fonts created with gint.font() return an object representing a font used by dfont().


Font Attributes

You can inspect the font fields like this:

f = gint.font(...)
print(f.line_height)
print(f.glyph_width)
AttributeTypeDescription
propint0 = monospaced, 1 = proportional
line_heightintTotal vertical space for each line
data_heightintPixel height of glyphs
block_countintNumber of glyph encoding blocks
glyph_countintTotal number of characters
char_spacingintSpace between characters
line_distanceintAdditional line spacing
blocksbytesGlyph block map
databytesGlyph bitmap data
widthint(Mono) Width of each character
storage_sizeint(Mono) Size of bitmap data
glyph_indexbytes(Prop) Glyph lookup table
glyph_widthbytes(Prop) Per-glyph widths

Mono vs Proportional Fonts

  • Monospaced fonts need width and storage_size.
  • Proportional fonts use glyph_index and glyph_width.

Example: Print Metadata

print("height:", font_shmup.line_height)
print("monospaced?" if font_shmup.prop == 0 else "proportional")