1 ;;; Copyright (c) 2006 Zachary Beane, All Rights Reserved
3 ;;; Redistribution and use in source and binary forms, with or without
4 ;;; modification, are permitted provided that the following conditions
7 ;;; * Redistributions of source code must retain the above copyright
8 ;;; notice, this list of conditions and the following disclaimer.
10 ;;; * Redistributions in binary form must reproduce the above
11 ;;; copyright notice, this list of conditions and the following
12 ;;; disclaimer in the documentation and/or other materials
13 ;;; provided with the distribution.
15 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
16 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 ;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 ;;; Loading data from the "head" table.
29 ;;; http://www.microsoft.com/OpenType/OTSpec/head.htm
30 ;;; http://developer.apple.com/fonts/TTRefMan/RM06/Chap6head.html
32 ;;; $Id: head.lisp,v 1.5 2006/02/18 23:13:43 xach Exp $
34 (in-package #:zpb-ttf
)
36 (defmethod load-head-info ((font-loader font-loader
))
37 (seek-to-table "head" font-loader
)
38 (with-slots (input-stream units
/em bounding-box loca-offset-format
)
40 (flet ((skip-bytes (count)
41 (file-position input-stream
(+ count
42 (file-position input-stream
)))))
43 (let ((version (read-uint32 input-stream
)))
44 (check-version "\"head\" table" version
#x00010000
))
45 ;; skip fontRevsion and checkSumAdjustment (both uint32)
47 ;; check the magicNumber
48 (let ((magic-number (read-uint32 input-stream
)))
49 (when (/= magic-number
#x5F0F3CF5
)
51 :location
"\"head\" table"
52 :expected-values
(list #x5F0F3CF5
)
53 :actual-value magic-number
)))
56 (setf units
/em
(read-uint16 input-stream
))
57 ;; skip created and modified dates
59 (setf bounding-box
(vector (read-int16 input-stream
)
60 (read-int16 input-stream
)
61 (read-int16 input-stream
)
62 (read-int16 input-stream
)))
63 ;; skip macStyle, lowestRecPPEM, fontDirectionHint
65 ;; set the loca-offset-format
66 (if (zerop (read-int16 input-stream
))
67 (setf loca-offset-format
:short
)
68 (setf loca-offset-format
:long
)))))