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 "hmtx" table.
29 ;;; https://learn.microsoft.com/en-us/typography/opentype/spec/hmtx
30 ;;; https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6hmtx.html
32 ;;; $Id: hmtx.lisp,v 1.3 2006/02/18 23:13:43 xach Exp $
34 (in-package #:zpb-ttf
)
36 (defmethod load-hmtx-info ((font-loader font-loader
))
37 (let* ((horizontal-metrics-count (horizontal-metrics-count font-loader
))
38 (advance-widths (make-array horizontal-metrics-count
))
39 (left-side-bearings (make-array horizontal-metrics-count
)))
40 (seek-to-table "hmtx" font-loader
)
41 (with-slots (input-stream) font-loader
42 (dotimes (i horizontal-metrics-count
)
43 (setf (svref advance-widths i
) (read-uint16 input-stream
))
44 (setf (svref left-side-bearings i
) (read-int16 input-stream
))))
45 (setf (advance-widths font-loader
) advance-widths
46 (left-side-bearings font-loader
) left-side-bearings
)))