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-2024 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 bu_vfont
22  *
23  * @brief
24  * Provide a machine-independent interface to files containing
25  * Berkeley VFONT format vector fonts, stored with VAX byte ordering and word
26  * alignment.
27  *
28  * This header file describes the in-memory format used by the BRL-CAD
29  * Package routines for manipulating fonts stored in the Berkeley
30  * VFONT format.
31  *
32  * Note that the VFONT files are in the format found on a VAX -- no
33  * conversion has been applied.
34  *
35  * Merely TARing or RCPing the VAX /usr/lib/vfont directory onto any
36  * machine suffices to install the fonts.
37  *
38  * The VAX format of the fonts is invisible to software actually using
39  * the fonts, except to be aware that bit zero in a byte of font data
40  * is on the right hand side (lsb).
41  *
42  * The VAX declaration of the file is:
43  *
44  * struct header {
45  * short magic;
46  * unsigned short size;
47  * short maxx;
48  * short maxy;
49  * short xtend;
50  * };
51  * struct dispatch {
52  * unsigned short addr;
53  * short nbytes;
54  * char up, down, left, right;
55  * short width;
56  * };
57  * char bits[header.size];
58  *
59  * The char fields up, down, left, and right in the VAX-version
60  * of struct dispatch are signed. Use the SXT macro to extend the sign.
61  *
62  * The actual bits array has the upper left corner of the bitmap in
63  * the first byte. Bits are scanned out of the bytes in a
64  * left-to-right, top-to-bottom order (most decidedly non-VAX style).
65  * Never seems to be any consistency in data formats.
66  *
67  */
68 /** @{ */
69 /** @file include/bu/vfont.h */
70 
71 #ifndef BU_VFONT_H
72 #define BU_VFONT_H
73 
74 #include "common.h"
75 
76 #include "bu/defines.h"
77 
78 #define SXT(c) ((c)|((c&0x80)?(~0xFF):0))
79 
81  unsigned short vd_addr;
82  short vd_nbytes;
83  short vd_up;
84  short vd_down;
85  short vd_left;
86  short vd_right;
87  short vd_width;
88 };
89 struct vfont {
90  short vf_maxx;
91  short vf_maxy;
92  short vf_xtend;
93  struct vfont_dispatch vf_dispatch[256];
94  char *vf_bits;
95 };
96 #define VFONT_NULL ((struct vfont *)NULL)
97 
98 __BEGIN_DECLS
99 
100 /**
101  * Fetch the named font, and return a struct vfont pointer.
102  *
103  * First the filename provided is used, then the BRL-CAD font
104  * directory is searched (for places where "system" directories are
105  * considered sacred), and then finally the ordinary font directory is
106  * searched.
107  *
108  * The font files are treated as pure byte streams, and are expected
109  * to be in VAX order.
110  *
111  * VFONT_NULL is returned on error. On ordinary errors, the function
112  * is silent. On extraordinary errors, a remark is placed on stderr.
113  */
114 BU_EXPORT extern struct vfont *vfont_get(char *font);
115 
116 /**
117  * Return the storage associated with a struct vfont
118  */
119 BU_EXPORT extern void vfont_free(struct vfont *font);
120 
121 __END_DECLS
122 
123 #endif /* BU_VFONT_H */
124 
125 /** @} */
126 /*
127  * Local Variables:
128  * mode: C
129  * tab-width: 8
130  * indent-tabs-mode: t
131  * c-file-style: "stroustrup"
132  * End:
133  * ex: shiftwidth=4 tabstop=8
134  */
Header file for the BRL-CAD common definitions.
void vfont_free(struct vfont *font)
struct vfont * vfont_get(char *font)
short vd_down
Definition: vfont.h:84
short vd_right
Definition: vfont.h:86
short vd_width
Definition: vfont.h:87
short vd_up
Definition: vfont.h:83
unsigned short vd_addr
Definition: vfont.h:81
short vd_nbytes
Definition: vfont.h:82
short vd_left
Definition: vfont.h:85
Definition: vfont.h:89
short vf_xtend
Definition: vfont.h:92
char * vf_bits
Definition: vfont.h:94
struct vfont_dispatch vf_dispatch[256]
Definition: vfont.h:93
short vf_maxy
Definition: vfont.h:91
short vf_maxx
Definition: vfont.h:90