3 Copyright 1991, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
28 * Author: Keith Packard, MIT X Consortium
35 #include <X11/fonts/fntfilst.h>
36 #include <X11/fonts/bitmap.h>
39 bitmapGetGlyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
40 FontEncoding charEncoding,
41 unsigned long *glyphCount, /* RETURN */
42 CharInfoPtr *glyphs) /* RETURN */
44 BitmapFontPtr bitmapFont;
45 unsigned int firstCol;
46 register unsigned int numCols;
47 unsigned int firstRow;
49 CharInfoPtr *glyphsBase;
50 register unsigned int c;
51 register CharInfoPtr pci;
53 CharInfoPtr **encoding;
56 bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
57 encoding = bitmapFont->encoding;
58 pDefault = bitmapFont->pDefault;
59 firstCol = pFont->info.firstCol;
60 numCols = pFont->info.lastCol - firstCol + 1;
62 switch (charEncoding) {
66 if (pFont->info.firstRow > 0)
68 if (pFont->info.allExist && pDefault) {
70 c = (*chars++) - firstCol;
72 *glyphs++ = ACCESSENCODING(encoding,c);
78 c = (*chars++) - firstCol;
79 if (c < numCols && (pci = ACCESSENCODING(encoding,c)))
87 if (pFont->info.allExist && pDefault) {
90 c = (c | *chars++) - firstCol;
92 *glyphs++ = ACCESSENCODING(encoding,c);
99 c = (c | *chars++) - firstCol;
100 if (c < numCols && (pci = ACCESSENCODING(encoding,c)))
103 *glyphs++ = pDefault;
109 firstRow = pFont->info.firstRow;
110 numRows = pFont->info.lastRow - firstRow + 1;
112 r = (*chars++) - firstRow;
113 c = (*chars++) - firstCol;
114 if (r < numRows && c < numCols &&
115 (pci = ACCESSENCODING(encoding, r * numCols + c)))
118 *glyphs++ = pDefault;
122 *glyphCount = glyphs - glyphsBase;
126 static CharInfoRec nonExistantChar;
129 bitmapGetMetrics(FontPtr pFont, unsigned long count, unsigned char *chars,
130 FontEncoding charEncoding,
131 unsigned long *glyphCount, /* RETURN */
132 xCharInfo **glyphs) /* RETURN */
135 xCharInfo *ink_metrics;
137 BitmapFontPtr bitmapFont;
138 CharInfoPtr oldDefault;
141 bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
142 oldDefault = bitmapFont->pDefault;
143 bitmapFont->pDefault = &nonExistantChar;
144 ret = bitmapGetGlyphs(pFont, count, chars, charEncoding, glyphCount, (CharInfoPtr *) glyphs);
145 if (ret == Successful) {
146 if (bitmapFont->ink_metrics) {
147 metrics = bitmapFont->metrics;
148 ink_metrics = bitmapFont->ink_metrics;
149 for (i = 0; i < *glyphCount; i++) {
150 if (glyphs[i] != (xCharInfo *) & nonExistantChar)
151 glyphs[i] = ink_metrics + (((CharInfoPtr) glyphs[i]) - metrics);
155 bitmapFont->pDefault = oldDefault;