From af2872325ed461252303ec8b7987058b664843f1 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 10 Mar 2018 20:32:18 -0500 Subject: Update Chickadee manual. --- manuals/chickadee/Fonts.html | 197 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 manuals/chickadee/Fonts.html (limited to 'manuals/chickadee/Fonts.html') diff --git a/manuals/chickadee/Fonts.html b/manuals/chickadee/Fonts.html new file mode 100644 index 0000000..198bddb --- /dev/null +++ b/manuals/chickadee/Fonts.html @@ -0,0 +1,197 @@ + + + + + +The Chickadee Game Toolkit: Fonts + + + + + + + + + + + + + + + + + + + + + +
+

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

+
+
+ +

2.4.5 Fonts

+ +

Unlike the traditional TrueType font format that many are accustomed +to, Chickadee loads and renders bitmap fonts in the +Angel Code format. But why use this seemingly obscure format? It’s +easy to find TTFs but not easy to find FNTs (the canonical file +extension used for Angel Code fonts) and bitmap fonts don’t scale +well. The reason is efficiency. +

+

If all of the glyphs of a font are pre-rendered and packed into an +image file then it becomes possible to use a texture atlas +(see Textures) and a sprite batch (see Sprites) when +rendering, which is a more efficient way to render fonts than using, +say, SDL_ttf or other +solutions that involve using the FreeType library directly. +

+

Now what about scaling? In libraries that use TTF fonts, one must +choose the size that the glyphs will be rasterized at up front. To +use n sizes of the same font, one must load n variants +of that font. If the size of the text is dynamic, some kind of +texture scaling algorithm must be used and the text will inevitably +look blurry. At first glance, using bitmap fonts seem to have an even +worse issue. Instead of just loading the same font n times at +different sizes, one would need to generate n image files for +each font size needed. This is where the “signed distance field” +rendering technique comes in. Introduced by +Valve in 2007, signed distance field fonts can be efficiently stored +in a bitmap and be rendered at arbitrary scale factors with good +results. Chickadee can render both traditional bitmap fonts and +signed distance field fonts. Signed distance field font +rendering is not yet available, so be patient. +

+

While Chickadee does not yet offer a tool for converting TTF fonts +into FNT fonts, tools such as +Hiero may be used +in the meantime. +

+

The following procedures can be found in the (chickadee render +font) module. +

+
+
Scheme Procedure: load-font file
+

Load the Angel Code formatted XML document in file and return a +new font object. +

+ +
+
Scheme Procedure: font? obj
+

Return #t if obj is a font object. +

+ +
+
Scheme Procedure: font-face font
+

Return the name of font. +

+ +
+
Scheme Procedure: font-line-height font
+

Return the line height of font. +

+ +
+
Scheme Procedure: font-line-height font
+

Return the line height of font. +

+ +
+
Scheme Procedure: font-bold? font
+

Return #t if font is a bold font. +

+ +
+
Scheme Procedure: font-italic? font
+

Return #t if font is an italicized font. +

+ +
+
Scheme Procedure: draw-text font text position
+

[#:scale] [#:rotation] [#:blend-mode] +

+

Draw the string text with the first character starting at +position using font. +

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

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

+ +
+
+

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

+
+ + + + + -- cgit v1.2.3