ffi reorg

main
Matthew Butterick 6 years ago
parent a921849ad6
commit 85358635ed

@ -306,7 +306,9 @@
_FT_UInt
-> (err : _FT_Error)))
(define-freetype FT_New_Face (_fun _FT_Library _full-path _FT_Long
(define-freetype FT_New_Face (_fun _FT_Library
(path : _full-path)
(_FT_Long = 0)
(ftf : (_ptr o (_or-null _FT_Face)))
-> (err : _FT_Error)
-> (cond
@ -314,6 +316,8 @@
;; see https://www.freetype.org/freetype2/docs/tutorial/step1.html
(FT_Set_Char_Size ftf 0 1000 0 0)
ftf]
[(= err 1)
(error 'FT_New_Face (format "font ~v not found" path))]
[(error 'FT_New_Face (format "error ~a" err))])))
@ -390,7 +394,7 @@
(module+ test
(require rackunit)
(define ft-library (FT_Init_FreeType))
(define face (FT_New_Face ft-library "charter.ttf" 0))
(define face (FT_New_Face ft-library "../assets/charter.ttf"))
(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))

@ -2,6 +2,7 @@
(require ffi/unsafe
ffi/unsafe/define
racket/draw/private/libs
"freetype.rkt"
"harfbuzz-helper.rkt")
(provide (all-defined-out))
@ -65,7 +66,6 @@
(define-harfbuzz hb_buffer_set_language (_fun _hb_buffer_t _hb_language_t -> _void))
(define-harfbuzz hb_buffer_get_language (_fun _hb_buffer_t -> _hb_language_t))
(require "freetype-ffi.rkt")
(define _hb_font_t _pointer)
(define _hb_destroy_func_t (_or-null _pointer))
(define-harfbuzz hb_ft_font_create (_fun _FT_Face _hb_destroy_func_t -> _hb_font_t))
@ -131,7 +131,7 @@
(define ft-lib (FT_Init_FreeType))
(require racket/runtime-path)
(define-runtime-path test-font-path "fira.ttf")
(define-runtime-path test-font-path "../assets/fira.ttf")
(module+ test
(require rackunit)
@ -147,7 +147,7 @@
(check-equal? #"en" (hb_language_to_string (hb_buffer_get_language buf)))
;; Create a face and a font, using FreeType for now.
(define face (FT_New_Face ft-lib test-font-path 0))
(define face (FT_New_Face ft-lib test-font-path))
(define font (hb_ft_font_create face #f))
;; Shape!
@ -165,7 +165,7 @@
(hb_font_destroy font))
(define (make-font path-string)
(define face (FT_New_Face ft-lib path-string 0))
(define face (FT_New_Face ft-lib path-string))
(hb_ft_font_create face #f))
(define HB_FEATURE_GLOBAL_START 0)

@ -1,7 +1,7 @@
#lang debug racket/base
(require (for-syntax racket/base)
"helper.rkt"
"freetype-ffi.rkt"
"ffi/freetype.rkt"
"subset.rkt"
"glyph.rkt"
"bbox.rkt"
@ -16,7 +16,10 @@
sugar/unstable/class
sugar/unstable/contract
sugar/unstable/dict
sugar/unstable/js)
sugar/unstable/js
"ffi/harfbuzz.rkt"
"glyph-position.rkt"
sugar/list)
(provide (all-defined-out))
#|
@ -56,7 +59,7 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js
[_glyphs (mhash)]
[_layoutEngine #f]
[directory #f]
[ft-face (and _src (FT_New_Face ft-library _src 0))])
[ft-face (and _src (FT_New_Face ft-library _src))])
(send this _decodeDirectory)
(define/public (_getTable table-tag)
@ -248,7 +251,6 @@ https://github.com/mbutterick/fontkit/blob/master/src/TTFFont.js
(define current-layout-caching (make-parameter #false))
(define layout-cache (make-hash))
(require "harfbuzz-ffi.rkt" "glyph-position.rkt" sugar/list)
(define (harfbuzz-glyphrun this string userFeatures script language)
#;(string? (listof symbol?) symbol? symbol? . ->m . GlyphRun?)
(define face (· this ft-face))

@ -9,7 +9,7 @@
sugar/unstable/dict
sugar/unstable/js
sugar/unstable/stub
"freetype-ffi.rkt"
"ffi/freetype.rkt"
"helper.rkt")
(provide (all-defined-out))
(module+ test (require rackunit))

Loading…
Cancel
Save