Next: , Previous: , Up: Graphics   [Contents][Index]


2.3.5 Fonts

Printing text to the screen is quite easy:

(draw-text "Hello, world" (vec2 100.0 100.0))

Chickadee supports OpenType/TrueType fonts (via the FreeType library), bitmap fonts in Angel Code bmfont format, and simple sprite sheet bitmap fonts. A default font named Inconsolata is used for all text rendering operations where a font is not specified, as is the case in the above example.

The following procedures can be found in the (chickadee graphics font) module:

Procedure: load-font file-name point-size [#:char-set]

Load the scalable (OpenType, TrueType, etc.) font in the file file-name and display it at the given point-size. By default, all the characters in the ASCII character set are loaded. This can be changed by passing a different character set (see Character Sets in GNU Guile Reference Manual) using the char-set keyword argument.

Procedure: load-bitmap-font file

Load the Angel Code font (in either XML or FNT format) in file and return a new font object.

Procedure: font? obj

Return #t if obj is a font object.

Procedure: font-face font

Return the name of font.

Procedure: font-line-height font

Return the line height of font.

Procedure: font-line-height font

Return the line height of font.

Procedure: font-bold? font

Return #t if font is a bold font.

Procedure: font-italic? font

Return #t if font is an italicized font.

Procedure: draw-text text position

[#:font] [#:color] [#:origin] [#:scale] [#:rotation] [#:blend-mode] [#:start 0] [#:end (string-length text)]

Draw the string text with the first character starting at position using font. If font is not specified, a built-in font is used.

(draw-text "Hello, world!" (vec2 128.0 128.0))

To render a substring of text, use the start and end arguments.

Refer to draw-sprite (see Sprites) for information about the other arguments.


Next: , Previous: , Up: Graphics   [Contents][Index]