|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
#lang racket/base
|
|
|
|
|
#lang debug racket/base
|
|
|
|
|
(require ffi/unsafe
|
|
|
|
|
ffi/unsafe/define
|
|
|
|
|
racket/draw/private/libs)
|
|
|
|
@ -92,6 +92,7 @@
|
|
|
|
|
[vertBearingY _FT_Pos]
|
|
|
|
|
[vertAdvance _FT_Pos]))
|
|
|
|
|
(provide (struct-out FT_Glyph_Metrics)
|
|
|
|
|
FT_Glyph_Metrics->list
|
|
|
|
|
_FT_Glyph_Metrics _FT_Glyph_Metrics-pointer)
|
|
|
|
|
|
|
|
|
|
(define-cstruct _FT_Vector
|
|
|
|
@ -344,10 +345,11 @@
|
|
|
|
|
-> (err : _FT_Error)))
|
|
|
|
|
|
|
|
|
|
(define+provide FT_KERNING_UNSCALED 2)
|
|
|
|
|
(define+provide FT_LOAD_DEFAULT 0)
|
|
|
|
|
(define+provide FT_LOAD_RENDER (expt 2 2))
|
|
|
|
|
(define+provide FT_LOAD_LINEAR_DESIGN (expt 2 13))
|
|
|
|
|
(define+provide FT_LOAD_NO_RECURSE (expt 2 10))
|
|
|
|
|
(define+provide FT_LOAD_DEFAULT #x0)
|
|
|
|
|
(define+provide FT_LOAD_RENDER (arithmetic-shift 1 2))
|
|
|
|
|
(define+provide FT_LOAD_LINEAR_DESIGN (arithmetic-shift 1 13))
|
|
|
|
|
(define+provide FT_LOAD_NO_RECURSE (arithmetic-shift 1 10))
|
|
|
|
|
(define+provide FT_LOAD_NO_SCALE (arithmetic-shift 1 0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -394,7 +396,8 @@
|
|
|
|
|
(module+ test
|
|
|
|
|
(require rackunit)
|
|
|
|
|
(define ft-library (FT_Init_FreeType))
|
|
|
|
|
(define face (FT_New_Face ft-library "../assets/charter.ttf"))
|
|
|
|
|
(define (test-face face-str)
|
|
|
|
|
(define face (FT_New_Face ft-library face-str))
|
|
|
|
|
(check-equal? (FT_Get_Postscript_Name face) "Charter")
|
|
|
|
|
(check-equal? (FT_FaceRec-units_per_EM face) 1000)
|
|
|
|
|
(check-true (FT_Load_Sfnt_Table face (tag->int #"cmap") 0 0 0))
|
|
|
|
@ -416,6 +419,7 @@
|
|
|
|
|
; want bearingX (lsb) and advanceX (advance width)
|
|
|
|
|
(define g (FT_FaceRec-glyph face))
|
|
|
|
|
(define metrics (FT_GlyphSlotRec-metrics g))
|
|
|
|
|
#R (FT_Glyph_Metrics->list metrics)
|
|
|
|
|
(define bearingX (FT_Glyph_Metrics-horiBearingX metrics))
|
|
|
|
|
(check-equal? bearingX 33)
|
|
|
|
|
(define advanceX (FT_Glyph_Metrics-horiAdvance metrics))
|
|
|
|
@ -438,7 +442,10 @@
|
|
|
|
|
(check-equal? (FT_TT_OS2-sCapHeight os2-table) 671)
|
|
|
|
|
(check-equal? (FT_TT_OS2-sxHeight os2-table) 481)
|
|
|
|
|
|
|
|
|
|
(FT_Done_Face face)
|
|
|
|
|
(FT_Done_Face face))
|
|
|
|
|
|
|
|
|
|
(test-face "../assets/charter.ttf")
|
|
|
|
|
(test-face "../assets/charter.otf")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|