| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | #ifdef HAVE_CONFIG_H1 |
| 25 | #include <config.h> |
| 26 | #endif |
| 27 | #include <X11/fonts/fntfilst.h> |
| 28 | #include <X11/fonts/fontutil.h> |
| 29 | #include <X11/fonts/pcf.h> |
| 30 | #include "builtin.h" |
| 31 | |
| 32 | static int |
| 33 | BuiltinOpenBitmap (FontPathElementPtr fpe, FontPtr *ppFont, int flags, |
| 34 | FontEntryPtr entry, char *fileName, fsBitmapFormat format, |
| 35 | fsBitmapFormatMask fmask, FontPtr unused) |
| 36 | { |
| 37 | FontFilePtr file; |
| 38 | FontPtr pFont; |
| 39 | int ret; |
| 40 | int bit, |
| 41 | byte, |
| 42 | glyph, |
| 43 | scan, |
| 44 | image; |
| 45 | |
| 46 | file = BuiltinFileOpen (fileName); |
| 47 | if (!file) |
| 48 | return BadFontName83; |
| 49 | pFont = malloc(sizeof(FontRec)); |
| 50 | if (!pFont) { |
| 51 | BuiltinFileClose (file, 0); |
| 52 | return AllocError80; |
| 53 | } |
| 54 | |
| 55 | FontDefaultFormat(&bit, &byte, &glyph, &scan); |
| 56 | |
| 57 | ret = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image); |
| Value stored to 'ret' is never read |
| 58 | |
| 59 | |
| 60 | pFont->refcnt = 0; |
| 61 | pFont->maxPrivate = -1; |
| 62 | pFont->devPrivates = (pointer *) 0; |
| 63 | |
| 64 | ret = pcfReadFont (pFont, file, bit, byte, glyph, scan); |
| 65 | |
| 66 | BuiltinFileClose (file, 0); |
| 67 | if (ret != Successful85) |
| 68 | free(pFont); |
| 69 | else |
| 70 | *ppFont = pFont; |
| 71 | return ret; |
| 72 | } |
| 73 | |
| 74 | static int |
| 75 | BuiltinGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo, |
| 76 | FontEntryPtr entry, char *fileName) |
| 77 | { |
| 78 | FontFilePtr file; |
| 79 | int ret; |
| 80 | |
| 81 | file = BuiltinFileOpen (fileName); |
| 82 | if (!file) |
| 83 | return BadFontName83; |
| 84 | ret = pcfReadFontInfo (pFontInfo, file); |
| 85 | BuiltinFileClose (file, 0); |
| 86 | return ret; |
| 87 | } |
| 88 | |
| 89 | static int |
| 90 | BuiltinOpenScalable (FontPathElementPtr fpe, |
| 91 | FontPtr *pFont, |
| 92 | int flags, |
| 93 | FontEntryPtr entry, |
| 94 | char *fileName, |
| 95 | FontScalablePtr vals, |
| 96 | fsBitmapFormat format, |
| 97 | fsBitmapFormatMask fmask, |
| 98 | FontPtr non_cachable_font) |
| 99 | { |
| 100 | return BadFontName83; |
| 101 | } |
| 102 | |
| 103 | static int |
| 104 | BuiltinGetInfoScalable (FontPathElementPtr fpe, |
| 105 | FontInfoPtr pFontInfo, |
| 106 | FontEntryPtr entry, |
| 107 | FontNamePtr fontName, |
| 108 | char *fileName, |
| 109 | FontScalablePtr vals) |
| 110 | { |
| 111 | return BadFontName83; |
| 112 | } |
| 113 | |
| 114 | static FontRendererRec renderers[] = { |
| 115 | { ".builtin", 8, |
| 116 | BuiltinOpenBitmap, |
| 117 | BuiltinOpenScalable, |
| 118 | BuiltinGetInfoBitmap, |
| 119 | BuiltinGetInfoScalable, |
| 120 | 0 } |
| 121 | }; |
| 122 | |
| 123 | #define numRenderers(sizeof renderers / sizeof renderers[0]) (sizeof renderers / sizeof renderers[0]) |
| 124 | |
| 125 | void |
| 126 | BuiltinRegisterFontFileFunctions(void) |
| 127 | { |
| 128 | int i; |
| 129 | for (i = 0; i < numRenderers(sizeof renderers / sizeof renderers[0]); i++) |
| 130 | FontFileRegisterRenderer ((FontRendererRec *) &renderers[i]); |
| 131 | } |
| 132 | |