Update release date
[zpb-ttf.git] / loca.lisp
blobf5f4c0ad9228ff851a44572207e6963185a9f3d3
1 ;;; Copyright (c) 2006 Zachary Beane, All Rights Reserved
2 ;;;
3 ;;; Redistribution and use in source and binary forms, with or without
4 ;;; modification, are permitted provided that the following conditions
5 ;;; are met:
6 ;;;
7 ;;; * Redistributions of source code must retain the above copyright
8 ;;; notice, this list of conditions and the following disclaimer.
9 ;;;
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.
14 ;;;
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.
26 ;;;
27 ;;; Loading data from the "loca" table.
28 ;;;
29 ;;; https://docs.microsoft.com/en-us/typography/opentype/spec/loca
30 ;;; http://developer.apple.com/fonts/TTRefMan/RM06/Chap6loca.html
31 ;;;
32 ;;; $Id: loca.lisp,v 1.3 2006/02/18 23:13:43 xach Exp $
34 (in-package #:zpb-ttf)
36 (defmethod load-loca-info ((font-loader font-loader))
37 (seek-to-table "loca" font-loader)
38 (with-slots (input-stream glyph-locations glyph-count loca-offset-format)
39 font-loader
40 (setf glyph-locations (make-array (1+ glyph-count)))
41 (dotimes (i (1+ glyph-count))
42 (setf (svref glyph-locations i)
43 (if (eql loca-offset-format :short)
44 (* (read-uint16 input-stream) 2)
45 (read-uint32 input-stream))))))
47 (defmethod glyph-location (index (font-loader font-loader))
48 (aref (glyph-locations font-loader) index))
50 (defmethod glyph-length (index (font-loader font-loader))
51 (with-slots (glyph-locations)
52 font-loader
53 (- (aref glyph-locations (1+ index))
54 (aref glyph-locations index))))