BRL-CAD
vfont.h
Go to the documentation of this file.
1 /* V F O N T . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2014 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 
21 /** @addtogroup vfont */
22 /** @{ */
23 /** @file include/bu/vfont.h
24  *
25  * This header file describes the in-memory format used by the BRL-CAD
26  * Package routines for manipulating fonts stored in the Berkeley
27  * VFONT format.
28  *
29  * Note that the VFONT files are in the format found on a VAX -- no
30  * conversion has been applied.
31  *
32  * Merely TARing or RCPing the VAX /usr/lib/vfont directory onto any
33  * machine suffices to install the fonts.
34  *
35  * The VAX format of the fonts is invisible to software actually using
36  * the fonts, except to be aware that bit zero in a byte of font data
37  * is on the right hand side (lsb).
38  *
39  * The VAX declaration of the file is:
40  *
41  * struct header {
42  * short magic;
43  * unsigned short size;
44  * short maxx;
45  * short maxy;
46  * short xtend;
47  * };
48  * struct dispatch {
49  * unsigned short addr;
50  * short nbytes;
51  * char up, down, left, right;
52  * short width;
53  * };
54  * char bits[header.size];
55  *
56  * The char fields up, down, left, and right in the VAX-version
57  * of struct dispatch are signed. Use the SXT macro to extend the sign.
58  *
59  * The actual bits array has the upper left corner of the bitmap in
60  * the first byte. Bits are scanned out of the bytes in a
61  * left-to-right, top-to-bottom order (most decidedly non-VAX style).
62  * Never seems to be any consistency in data formats.
63  *
64  */
65 
66 #ifndef BU_VFONT_H
67 #define BU_VFONT_H
68 
69 #include "common.h"
70 
71 #include "bu/defines.h"
72 
73 #define SXT(c) ((c)|((c&0x80)?(~0xFF):0))
74 
76  unsigned short vd_addr;
77  short vd_nbytes;
78  short vd_up;
79  short vd_down;
80  short vd_left;
81  short vd_right;
82  short vd_width;
83 };
84 struct vfont {
85  short vf_maxx;
86  short vf_maxy;
87  short vf_xtend;
89  char *vf_bits;
90 };
91 #define VFONT_NULL ((struct vfont *)NULL)
92 
93 /** @file vfont.c
94  *
95  * @brief Berkeley Vector Fonts
96  *
97  * Provide a machine-independent interface to files containing
98  * Berkeley VFONT format fonts, stored with VAX byte ordering and word
99  * alignment.
100  *
101  */
102 
104 
105 /**
106  * Fetch the named font, and return a struct vfont pointer.
107  *
108  * First the filename provided is used, then the BRL-CAD font
109  * directory is searched (for places where "system" directories are
110  * considered sacred), and then finally the ordinary font directory is
111  * searched.
112  *
113  * The font files are treated as pure byte streams, and are expected
114  * to be in VAX order.
115  *
116  * VFONT_NULL is returned on error. On ordinary errors, the function
117  * is silent. On extraordinary errors, a remark is placed on stderr.
118  */
119 BU_EXPORT extern struct vfont *vfont_get(char *font);
120 
121 /**
122  * Return the storage associated with a struct vfont
123  */
124 BU_EXPORT extern void vfont_free(struct vfont *font);
125 
127 
128 #endif /* BU_VFONT_H */
129 
130 /** @} */
131 /*
132  * Local Variables:
133  * mode: C
134  * tab-width: 8
135  * indent-tabs-mode: t
136  * c-file-style: "stroustrup"
137  * End:
138  * ex: shiftwidth=4 tabstop=8
139  */
short vd_nbytes
Definition: vfont.h:77
short vf_maxy
Definition: vfont.h:86
Header file for the BRL-CAD common definitions.
struct vfont * vfont_get(char *font)
Definition: vfont.c:124
short vf_maxx
Definition: vfont.h:85
short vd_down
Definition: vfont.h:79
#define __BEGIN_DECLS
Definition: common.h:73
short vd_width
Definition: vfont.h:82
char * vf_bits
Definition: vfont.h:89
Definition: vfont.h:84
short vd_left
Definition: vfont.h:80
short vd_up
Definition: vfont.h:78
void vfont_free(struct vfont *font)
struct vfont_dispatch vf_dispatch[256]
Definition: vfont.h:88
unsigned short vd_addr
Definition: vfont.h:76
#define __END_DECLS
Definition: common.h:74
short vd_right
Definition: vfont.h:81
short vf_xtend
Definition: vfont.h:87