Updated version to 1.0.3.
[zpb-ttf.git] / bounding-box.lisp
blobc8e55f9a663dbb8e8330b94edfe8039f9bff794c
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 ;;;; Bounding boxes, which are common to both the overall font and
28 ;;;; individual glyphs.
29 ;;;;
30 ;;;; $Id: bounding-box.lisp,v 1.2 2006/02/18 23:13:43 xach Exp $
32 (in-package :zpb-ttf)
34 (defgeneric bounding-box (object))
36 (macrolet ((bbox-accessor (name index)
37 `(progn
38 (defgeneric ,name (object)
39 (:method (object)
40 (aref (bounding-box object) ,index)))
41 (defgeneric (setf ,name) (new-value object)
42 (:method (new-value object)
43 (setf (aref (bounding-box object) ,index) new-value))))))
44 (bbox-accessor xmin 0)
45 (bbox-accessor ymin 1)
46 (bbox-accessor xmax 2)
47 (bbox-accessor ymax 3))
49 (defmethod bounding-box ((object array))
50 object)