Skip to content
Matthias Görges edited this page May 30, 2014 · 4 revisions

ttf-compile outputs a scheme font file to stdout for compilation.

Parameter Description
fname TTF file name
pointlist List of font sizes to build
glyphlist List of characters to render
name Scheme font name

Example

Example 1: Return image information of the panda-icon.png from uSquish.

> (ttf-compile "fonts/cmss.ttf" '(10 12 14) '(20 127) "ascii")                      
(c-declare  #<<end-of-c-declare
#include <string.h>
static unsigned char ascii_font[]={
// length=219 [4096]
1, 6, 
255, 255, 255, 255, 0, 96, 128, 32, 0, 0, 32, 192, 6, 96, 18, 1, 73, 132, 64, 0, 0, 73, 224, 0, 7, 96, 20, 1, 55, 136, 96, 0, 
0, 123, 224, 1, 8, 128, 23, 1, 40, 0, 32, 0, 0, 40, 32, 1, 32, 0, 0, 40, 128, 18, 0, 48, 32, 10, 0, 0, 32, 5, 192, 7, 
96, 63, 0, 56, 32, 18, 32, 0, 0, 56, 32, 1, 96, 0, 32, 6, 96, 23, 160, 56, 160, 6, 96, 18, 192, 55, 192, 7, 96, 20, 32, 47, 
64, 0, 224, 67, 63, 96, 0, 160, 120, 160, 6, 96, 0, 192, 119, 192, 7, 96, 0, 224, 10, 127, 96, 0, 96, 51, 224, 50, 63, 1, 116, 128, 
32, 0, 0, 52, 192, 6, 96, 0, 128, 113, 224, 30, 127, 224, 10, 0, 0, 89, 65, 190, 1, 132, 89, 224, 0, 7, 96, 0, 224, 15, 191, 224, 
31, 0, 0, 60, 97, 254, 1, 136, 128, 224, 1, 8, 224, 253, 0, 224, 253, 0, 224, 253, 0, 224, 253, 0, 224, 253, 0, 224, 253, 0, 224, 253, 
0, 224, 253, 0, 224, 253, 0, 224, 253, 0, 224, 253, 0, 224, 253, 0, 224, 253, 0, 224, 103, 0, 2, 0, 0, 0};
end-of-c-declare
)
(define ascii.z  (let ((u8v (make-u8vector 220))) ((c-lambda (scheme-object int) void    "memcpy(___CAST(void*,___BODY_AS(___arg1,___tSUBTYPED)),ascii_font,___arg2);") u8v 220) u8v))
(define ascii.raw (glCoreTextureCreate 64 64 (u8vector-decompress ascii.z) GL_LINEAR GL_REPEAT))
(define ascii_10.fnt (list
(list 0 (list 0 10 ascii.raw 0. 0. 0. 0.) 0 0 0)
(list 20 (list 6 7 ascii.raw 0.078125 0.117188 0.179688 0.000000) 1 7.500000 7)
(list 127 (list 6 7 ascii.raw 0.187500 0.117188 0.289062 0.000000) 1 7.500000 7)
))
(define ascii_12.fnt (list
(list 0 (list 0 12 ascii.raw 0. 0. 0. 0.) 0 0 0)
(list 20 (list 7 8 ascii.raw 0.375000 0.132812 0.492188 0.000000) 1 9.000000 8)
(list 127 (list 7 8 ascii.raw 0.500000 0.132812 0.617188 0.000000) 1 9.000000 8)
))
(define ascii_14.fnt (list
(list 0 (list 0 13 ascii.raw 0. 0. 0. 0.) 0 0 0)
(list 20 (list 8 9 ascii.raw 0.703125 0.148438 0.835938 0.000000) 1 10.500000 9)
(list 127 (list 8 9 ascii.raw 0.843750 0.148438 0.976562 0.000000) 1 10.500000 9)
))
#t

Clone this wiki locally