add hfs-seconds type

main
Matthew Butterick 5 years ago
parent d050669d3a
commit 4d6399fac5

@ -1,5 +1,6 @@
#lang racket/base
(require xenomorph)
#lang debug racket/base
(require xenomorph
racket/date)
(provide head)
#|
@ -7,6 +8,17 @@ approximates
https://github.com/mbutterick/fontkit/blob/master/src/tables/head.js
|#
; `name` table dates are seconds since 1/1/1904 (Mac file convention)
; whereas Racket / posix tracks since 1/1/1970
; so we adjust with the difference in seconds
(define mac-to-posix-delta 2082844800)
(define hfs-seconds (x:int #:size 8
#:signed #f
#:endian 'be
#:post-decode (λ (int) (seconds->date (- int mac-to-posix-delta)))
#:pre-encode (λ (dt) (+ (date->seconds dt) mac-to-posix-delta))))
(define head (x:struct
'version int32be ;; 0x00010000 (version 1.0)
'revision int32be ;; set by font manufacturer
@ -14,8 +26,8 @@ https://github.com/mbutterick/fontkit/blob/master/src/tables/head.js
'magicNumber uint32be ;; set to 0x5F0F3CF5
'flags uint16be
'unitsPerEm uint16be ;; range from 64 to 16384
'created (x:array #:type int32be #:length 2)
'modified (x:array #:type int32be #:length 2)
'created hfs-seconds
'modified hfs-seconds
'xMin int16be ;; for all glyph bounding boxes
'yMin int16be ;; for all glyph bounding boxes
'xMax int16be ;; for all glyph bounding boxes

Loading…
Cancel
Save