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
34 #include <X11/fonts/fntfilst.h>
36 BitmapSourcesRec FontFileBitmapSources;
39 FontFileRegisterBitmapSource (FontPathElementPtr fpe)
41 FontPathElementPtr *new;
45 for (i = 0; i < FontFileBitmapSources.count; i++)
46 if (FontFileBitmapSources.fpe[i] == fpe)
48 if (FontFileBitmapSources.count == FontFileBitmapSources.size)
50 newsize = FontFileBitmapSources.size + 4;
51 new = realloc (FontFileBitmapSources.fpe, newsize * sizeof *new);
54 FontFileBitmapSources.size = newsize;
55 FontFileBitmapSources.fpe = new;
57 FontFileBitmapSources.fpe[FontFileBitmapSources.count++] = fpe;
62 FontFileUnregisterBitmapSource (FontPathElementPtr fpe)
66 for (i = 0; i < FontFileBitmapSources.count; i++)
67 if (FontFileBitmapSources.fpe[i] == fpe)
69 FontFileBitmapSources.count--;
70 if (FontFileBitmapSources.count == 0)
72 FontFileBitmapSources.size = 0;
73 free (FontFileBitmapSources.fpe);
74 FontFileBitmapSources.fpe = 0;
78 for (; i < FontFileBitmapSources.count; i++)
79 FontFileBitmapSources.fpe[i] = FontFileBitmapSources.fpe[i+1];
86 * Our set_path_hook: unregister all bitmap sources.
87 * This is necessary because already open fonts will keep their FPEs
88 * allocated, but they may not be on the new font path.
89 * The bitmap sources in the new path will be registered by the init_func.
92 FontFileEmptyBitmapSource(void)
94 if (FontFileBitmapSources.count == 0)
97 FontFileBitmapSources.count = 0;
98 FontFileBitmapSources.size = 0;
99 free (FontFileBitmapSources.fpe);
100 FontFileBitmapSources.fpe = 0;
104 FontFileMatchBitmapSource (FontPathElementPtr fpe,
109 FontScalablePtr vals,
110 fsBitmapFormat format,
111 fsBitmapFormatMask fmask,
116 FontBitmapEntryPtr bitmap;
118 FontDirectoryPtr dir;
119 FontScaledPtr scaled;
122 * Look through all the registered bitmap sources for
123 * the same zero name as ours; entries along that one
124 * can be scaled as desired.
127 for (source = 0; source < FontFileBitmapSources.count; source++)
129 if (FontFileBitmapSources.fpe[source] == fpe)
131 dir = (FontDirectoryPtr) FontFileBitmapSources.fpe[source]->private;
132 zero = FontFileFindNameInDir (&dir->scalable, zeroPat);
135 scaled = FontFileFindScaledInstance (zero, vals, noSpecificSize);
140 *pFont = scaled->pFont;
141 (*pFont)->fpe = FontFileBitmapSources.fpe[source];
144 else if (scaled->bitmap)
146 entry = scaled->bitmap;
147 bitmap = &entry->u.bitmap;
150 *pFont = bitmap->pFont;
151 (*pFont)->fpe = FontFileBitmapSources.fpe[source];
156 ret = FontFileOpenBitmap (
157 FontFileBitmapSources.fpe[source],
158 pFont, flags, entry, format, fmask);
159 if (ret == Successful && *pFont)
160 (*pFont)->fpe = FontFileBitmapSources.fpe[source];
163 else /* "cannot" happen */