Outdated egg!
This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
freetype bindings for Chicken.
Usage
(use freetype) (define lib (ft-init-freetype)) (define face (ft-new-face lib "/usr/share/fonts/truetype/msttcorefonts/arial.ttf")) (ft-set-char-size face 0 (* 16 64) 300 300) (ft-set-pixel-sizes face 0 16) (define AV (make-ft-vector)) (ft-get-kerning face (ft-get-char-index face (char->integer #\A)) (ft-get-char-index face (char->integer #\V)) FT_KERNING_DEFAULT AV) (print "AV kerning: " (ft-vector-x AV) " " (ft-vector-y AV))
AV kerning: -64 0
Procedures
[procedure] (ft-init-freetype) => <error-code>Create a new freetype library object.
[procedure] (ft-new-face <lib> <path>) => <face>Load a font face from a file. Returns #f if the file can't be loaded.
[procedure] (ft-set-char-size <face> <char-width> <char-height> <hres> <vres>) => <error-code>[procedure] (ft-set-pixel-size <face> <pixel-width> <pixel-height>) => <error-code>
[procedure] (ft-get-char-index <face> <char-code>) => <glyph-index>
[procedure] (ft-load-glyph <face> <glyph-index> <load-flags>) => <error-code>
[procedure] (ft-load-char <face> <char-code> <load-flags>) => <error-code>
[procedure] (ft-render-glyph <glyph> <render-flags>) => <error-code>
[procedure] (ft-get-kerning <face> <left> <right> <kerning-mode> <vector>) => <error-code>
[procedure] (ft-select-charmap <face> <charmap-index>) => <error-code>
[procedure] (ft-set-transform <face> <matrix> <delta>)
Records
ft-vector
- make-ft-vector
- free-ft-vector
- ft-vector-x
- ft-vector-y
- ft-vector-x-set!
- ft-vector-y-set!
ft-matrix
- make-ft-matrix
- free-ft-matrix
- ft-matrix-xx
- ft-matrix-xy
- ft-matrix-yx
- ft-matrix-yy
- ft-matrix-xx-set!
- ft-matrix-xy-set!
- ft-matrix-yx-set!
- ft-matrix-yy-set!
ft-face
- free-ft-face
- ft-face-num-faces
- ft-face-face-index
- ft-face-face-flags
- ft-face-style-flags
- ft-face-num-glyphs
- ft-face-family-name
- ft-face-style-name
- ft-face-num-fixed-sizes
- ft-face-available-sizes
- ft-face-num-charmaps
- ft-face-charmaps
- ft-face-generic-data
- ft-face-generic-finalizer
- ft-face-bbox-xmin
- ft-face-bbox-xmax
- ft-face-bbox-ymin
- ft-face-bbox-ymax
- ft-face-units-per-EM
- ft-face-ascender
- ft-face-descender
- ft-face-height
- ft-face-max-advance-width
- ft-face-max-advance-height
- ft-face-underline-position
- ft-face-underline-thickness
- ft-face-glyph
- ft-face-size
- ft-face-charmap
ft-glyph-slot
- free-ft-glyph-slot
- ft-glyph-slot-library
- ft-glyph-slot-face
- ft-glyph-slot-next
- ft-glyph-slot-reserved
- ft-glyph-slot-generic-data
- ft-glyph-slot-generic-finalizer
- ft-glyph-slot-metrics
- ft-glyph-slot-linear-hori-advance
- ft-glyph-slot-linear-vert-advance
- ft-glyph-slot-advance-x
- ft-glyph-slot-advance-y
- ft-glyph-slot-format
- ft-glyph-slot-bitmap
- ft-glyph-slot-outline
- ft-glyph-slot-num_subglyphs
- ft-glyph-slot-subglyphs
- ft-glyph-slot-control-data
- ft-glyph-slot-control-len
- ft-glyph-slot-lsb-delta
- ft-glyph-slot-rsb-delta
ft-bitmap
- free-ft-bitmap
- ft-bitmap-rows
- ft-bitmap-width
- ft-bitmap-pitch
- ft-bitmap-buffer
- ft-bitmap-num-grays
- ft-bitmap-pixel-mode
- ft-bitmap-palette-mode
- ft-bitmap-palette
ft-glyph-metrics
- free-ft-glyph-metrics
- ft-glyph-metrics-width
- ft-glyph-metrics-height
- ft-glyph-metrics-hori-bearing-x
- ft-glyph-metrics-hori-bearing-y
- ft-glyph-metrics-hori-advance
- ft-glyph-metrics-vert-bearing-x
- ft-glyph-metrics-vert-bearing-y
- ft-glyph-metrics-vert-advance
Enums
Encodings
- FT_ENCODING_NONE
- FT_ENCODING_MS_SYMBOL
- FT_ENCODING_UNICODE
- FT_ENCODING_SJIS
- FT_ENCODING_GB2312
- FT_ENCODING_BIG5
- FT_ENCODING_WANSUNG
- FT_ENCODING_JOHAB
- FT_ENCODING_ADOBE_STANDARD
- FT_ENCODING_ADOBE_EXPERT
- FT_ENCODING_ADOBE_CUSTOM
- FT_ENCODING_ADOBE_LATIN_1
- FT_ENCODING_OLD_LATIN_2
- FT_ENCODING_APPLE_ROMAN
Face Flags
- FT_FACE_FLAG_SCALABLE
- FT_FACE_FLAG_FIXED_SIZES
- FT_FACE_FLAG_FIXED_WIDTH
- FT_FACE_FLAG_SFNT
- FT_FACE_FLAG_HORIZONTAL
- FT_FACE_FLAG_VERTICAL
- FT_FACE_FLAG_KERNING
- FT_FACE_FLAG_FAST_GLYPHS
- FT_FACE_FLAG_MULTIPLE_MASTERS
- FT_FACE_FLAG_GLYPH_NAMES
- FT_FACE_FLAG_EXTERNAL_STREAM
Style Flags
- FT_STYLE_FLAG_ITALIC
- FT_STYLE_FLAG_BOLD
Open Flags
- FT_OPEN_MEMORY
- FT_OPEN_STREAM
- FT_OPEN_PATHNAME
- FT_OPEN_DRIVER
- FT_OPEN_PARAMS
Load Options
- FT_LOAD_DEFAULT
- FT_LOAD_NO_SCALE
- FT_LOAD_NO_HINTING
- FT_LOAD_RENDER
- FT_LOAD_NO_BITMAP
- FT_LOAD_VERTICAL_LAYOUT
- FT_LOAD_FORCE_AUTOHINT
- FT_LOAD_CROP_BITMAP
- FT_LOAD_PEDANTIC
- FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH
- FT_LOAD_NO_RECURSE
- FT_LOAD_IGNORE_TRANSFORM
- FT_LOAD_MONOCHROME
- FT_LOAD_LINEAR_DESIGN
- FT_LOAD_TARGET_NORMAL
- FT_LOAD_TARGET_LIGHT
- FT_LOAD_TARGET_MONO
- FT_LOAD_TARGET_LCD
- FT_LOAD_TARGET_LCD_V
Render Mode
- FT_RENDER_MODE_NORMAL
- FT_RENDER_MODE_LIGHT
- FT_RENDER_MODE_MONO
- FT_RENDER_MODE_LCD
- FT_RENDER_MODE_LCD_V
- FT_RENDER_MODE_MAX
Kerning Mode
- FT_KERNING_DEFAULT
- FT_KERNING_UNFITTED
- FT_KERNING_UNSCALED
Example
;; Render an anti-aliased "A" to text using the chars 0-9 for grayscale. (use freetype lolevel) (define lib (ft-init-freetype)) (define face (ft-new-face lib "/usr/share/fonts/truetype/msttcorefonts/arial.ttf")) (ft-set-char-size face 0 (* 16 64) 300 300) (ft-set-pixel-sizes face 0 16) (ft-load-char face (char->integer #\A) FT_LOAD_DEFAULT) (ft-render-glyph (ft-face-glyph face) FT_RENDER_MODE_NORMAL) (let* ((glyph (ft-face-glyph face)) (bitmap (ft-glyph-slot-bitmap glyph)) (width (ft-bitmap-width bitmap)) (rows (ft-bitmap-rows bitmap)) (buf (ft-bitmap-buffer bitmap))) (do ((i 0 (+ i 1))) ((= i rows)) (do ((j 0 (+ j 1))) ((= j width)) (let ((d (pointer-u8-ref (pointer+ buf (+ j (* i width)))))) (write-char (if (zero? d) #\space (integer->char (+ (inexact->exact (truncate (/ d 25.6))) (char->integer #\0))))))) (newline)))
393 666 09190 37 73 63 36 090 090 27 72 6999996 090 090 26 72 63 36 080 080
Author
License
BSD
History
- 0.1
- initial release