Index: xc/lib/font/fontfile/dirfile.c =================================================================== RCS file: /cvs/xprint/xprint/src/xprint_main/xc/lib/font/fontfile/dirfile.c,v retrieving revision 1.2 diff -u -r1.2 dirfile.c --- xc/lib/font/fontfile/dirfile.c 13 Feb 2004 05:42:31 -0000 1.2 +++ xc/lib/font/fontfile/dirfile.c 16 Feb 2004 12:21:05 -0000 @@ -25,6 +25,7 @@ in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.18 2004/02/11 21:11:18 dawes Exp $ */ /* * Author: Keith Packard, MIT X Consortium @@ -41,20 +42,23 @@ #include #include #include -#ifdef X_NOT_STDC_ENV -extern int errno; -#endif -static int ReadFontAlias(); +static Bool AddFileNameAliases ( FontDirectoryPtr dir ); +static int ReadFontAlias ( char *directory, Bool isFile, + FontDirectoryPtr *pdir ); +static int lexAlias ( FILE *file, char **lexToken ); +static int lexc ( FILE *file ); int -FontFileReadDirectory (directory, pdir) - char *directory; - FontDirectoryPtr *pdir; +FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir) { char file_name[MAXFONTFILENAMELEN]; char font_name[MAXFONTNAMELEN]; char dir_file[MAXFONTFILENAMELEN]; +#ifdef FONTDIRATTRIB + char dir_path[MAXFONTFILENAMELEN]; + char *ptr; +#endif FILE *file; int count, i, @@ -64,12 +68,33 @@ FontDirectoryPtr dir = NullFontDirectory; + if (strlen(directory) + 1 + sizeof(FontDirFile) > sizeof(dir_file)) + return BadFontPath; + +#ifdef FONTDIRATTRIB + /* Check for font directory attributes */ +#ifndef __UNIXOS2__ + if ((ptr = strchr(directory, ':'))) { +#else + /* OS/2 path might start with a drive letter, don't clip this */ + if (ptr = strchr(directory+2, ':')) { +#endif + strncpy(dir_path, directory, ptr - directory); + dir_path[ptr - directory] = '\0'; + } else { + strcpy(dir_path, directory); + } + strcpy(dir_file, dir_path); +#else strcpy(dir_file, directory); - if (directory[strlen(directory) - 1] != '/') +#endif + if (dir_file[strlen(dir_file) - 1] != '/') strcat(dir_file, "/"); strcat(dir_file, FontDirFile); file = fopen(dir_file, "r"); if (file) { + Bool found_font = FALSE; + if (fstat (fileno(file), &statb) == -1) return BadFontPath; count = fscanf(file, "%d\n", &i); @@ -85,25 +110,38 @@ dir->dir_mtime = statb.st_mtime; if (format[0] == '\0') sprintf(format, "%%%ds %%%d[^\n]\n", - MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1); + MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1); + while ((count = fscanf(file, format, file_name, font_name)) != EOF) { - if (count != 2) { - FontFileFreeDir (dir); - fclose(file); - return BadFontPath; +#ifdef __UNIXOS2__ + /* strip any existing trailing CR */ + for (i=0; idirectory) + sizeof(FontDirFile) > sizeof(dir_file)) + return FALSE; + strcpy (dir_file, dir->directory); strcat (dir_file, FontDirFile); if (stat (dir_file, &statb) == -1) @@ -153,11 +193,10 @@ */ static Bool -AddFileNameAliases(dir) - FontDirectoryPtr dir; +AddFileNameAliases(FontDirectoryPtr dir) { int i; - char copy[MAXFONTNAMELEN]; + char copy[MAXFONTFILENAMELEN]; char *fileName; FontTablePtr table; FontRendererPtr renderer; @@ -174,6 +213,8 @@ continue; len = strlen (fileName) - renderer->fileSuffixLen; + if (len >= sizeof(copy)) + continue; CopyISOLatin1Lowered (copy, fileName, len); copy[len] = '\0'; name.name = copy; @@ -198,29 +239,24 @@ * "font name \"With Double Quotes\" \\ and \\ back-slashes" * works just fine. * - * A line beginning with a # denotes a newline-terminated comment. + * A line beginning with a ! denotes a newline-terminated comment. */ /* * token types */ -static int lexAlias(), lexc(); - #define NAME 0 #define NEWLINE 1 #define DONE 2 #define EALLOC 3 static int -ReadFontAlias(directory, isFile, pdir) - char *directory; - Bool isFile; - FontDirectoryPtr *pdir; +ReadFontAlias(char *directory, Bool isFile, FontDirectoryPtr *pdir) { char alias[MAXFONTNAMELEN]; char font_name[MAXFONTNAMELEN]; - char alias_file[MAXFONTNAMELEN]; + char alias_file[MAXFONTFILENAMELEN]; FILE *file; FontDirectoryPtr dir; int token; @@ -228,9 +264,13 @@ int status = Successful; struct stat statb; + if (strlen(directory) >= sizeof(alias_file)) + return BadFontPath; dir = *pdir; strcpy(alias_file, directory); if (!isFile) { + if (strlen(directory) + 1 + sizeof(FontAliasFile) > sizeof(alias_file)) + return BadFontPath; if (directory[strlen(directory) - 1] != '/') strcat(alias_file, "/"); strcat(alias_file, FontAliasFile); @@ -263,10 +303,10 @@ status = AllocError; break; case NAME: - if (strlen(lexToken) >= sizeof alias) { - status = BadFontPath; - break; - } + if (strlen(lexToken) >= sizeof(alias)) { + status = BadFontPath; + break; + } strcpy(alias, lexToken); token = lexAlias(file, &lexToken); switch (token) { @@ -283,12 +323,12 @@ status = AllocError; break; case NAME: - CopyISOLatin1Lowered((unsigned char *) alias, - (unsigned char *) alias, - strlen(alias)); - CopyISOLatin1Lowered((unsigned char *) font_name, - (unsigned char *) lexToken, - strlen(lexToken)); + if (strlen(lexToken) >= sizeof(font_name)) { + status = BadFontPath; + break; + } + CopyISOLatin1Lowered(alias, alias, strlen(alias)); + CopyISOLatin1Lowered(font_name, lexToken, strlen(lexToken)); if (!FontFileAddFontAlias (dir, alias, font_name)) status = AllocError; break; @@ -309,9 +349,7 @@ static int charClass; static int -lexAlias(file, lexToken) - FILE *file; - char **lexToken; +lexAlias(FILE *file, char **lexToken) { int c; char *t; @@ -374,6 +412,8 @@ break; case Comment: continue; + default: + break; } *t++ = c; ++count; @@ -409,8 +449,7 @@ } static int -lexc(file) - FILE *file; +lexc(FILE *file) { int c; @@ -433,6 +472,7 @@ case '\t': charClass = WHITE; break; + case '\r': case '\n': charClass = NL; break; Index: xc/lib/font/fontfile/encparse.c =================================================================== RCS file: /cvs/xprint/xprint/src/xprint_main/xc/lib/font/fontfile/encparse.c,v retrieving revision 1.1 diff -u -r1.1 encparse.c --- xc/lib/font/fontfile/encparse.c 16 Oct 2002 21:14:43 -0000 1.1 +++ xc/lib/font/fontfile/encparse.c 16 Feb 2004 12:21:05 -0000 @@ -20,7 +20,7 @@ THE SOFTWARE. */ -/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.18 2001/11/02 03:06:40 dawes Exp $ */ +/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.20 2004/02/11 21:11:19 dawes Exp $ */ /* Parser for encoding files */ @@ -32,6 +32,10 @@ #include #include +#ifdef SCO325 +#include +#endif + #ifndef FONTENC_NO_LIBFONT #include "fntfilio.h" @@ -833,6 +837,7 @@ char file_name[MAXFONTFILENAMELEN], encoding_name[MAXFONTNAMELEN], buf[MAXFONTFILENAMELEN]; int count, n; + static char format[24] = ""; /* As we don't really expect to open encodings that often, we don't take the trouble of caching encodings directories. */ @@ -848,8 +853,12 @@ } encoding = NULL; + if (!format[0]) { + sprintf(format, "%%%ds %%%d[^\n]\n", sizeof(encoding_name) - 1, + sizeof(file_name) - 1); + } for(;;) { - count = fscanf(file, "%s %[^\n]\n", encoding_name, file_name); + count = fscanf(file, format, encoding_name, file_name); if(count == EOF) break; if(count != 2) Index: xc/lib/font/fontfile/fontfile.c =================================================================== RCS file: /cvs/xprint/xprint/src/xprint_main/xc/lib/font/fontfile/fontfile.c,v retrieving revision 1.2 diff -u -r1.2 fontfile.c --- xc/lib/font/fontfile/fontfile.c 1 Nov 2002 09:11:42 -0000 1.2 +++ xc/lib/font/fontfile/fontfile.c 16 Feb 2004 12:21:05 -0000 @@ -25,11 +25,12 @@ in this Software without prior written authorization from The Open Group. */ +/* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.22 2004/02/11 21:11:20 dawes Exp $ */ /* * Author: Keith Packard, MIT X Consortium */ -/* $NCDId: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */ +/* $NCDXorg: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */ #include "fntfilst.h" @@ -37,11 +38,23 @@ * Map FPE functions to renderer functions */ +static int FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont, + int flags, FontEntryPtr entry, + fsBitmapFormat format, + fsBitmapFormatMask fmask, + FontPtr non_cachable_font); + int -FontFileNameCheck (name) - char *name; +FontFileNameCheck (char *name) { #ifndef NCD +#ifdef __UNIXOS2__ + /* OS/2 uses D:/... as a path name for fonts, so accept this as a valid + * path if it starts with a letter and a colon + */ + if (isalpha(*name) && name[1]==':') + return TRUE; +#endif return *name == '/'; #else return ((strcmp(name, "built-ins") == 0) || (*name == '/')); @@ -49,8 +62,7 @@ } int -FontFileInitFPE (fpe) - FontPathElementPtr fpe; +FontFileInitFPE (FontPathElementPtr fpe) { int status; FontDirectoryPtr dir; @@ -71,12 +83,15 @@ /* ARGSUSED */ int -FontFileResetFPE (fpe) - FontPathElementPtr fpe; +FontFileResetFPE (FontPathElementPtr fpe) { FontDirectoryPtr dir; dir = (FontDirectoryPtr) fpe->private; + /* + * The reset must fail for bitmap fonts because they get cleared when + * the path is set. + */ if (FontFileDirectoryChanged (dir)) { /* can't do it, so tell the caller to close and re-open */ @@ -94,8 +109,7 @@ } int -FontFileFreeFPE (fpe) - FontPathElementPtr fpe; +FontFileFreeFPE (FontPathElementPtr fpe) { FontFileUnregisterBitmapSource (fpe); FontFileFreeDir ((FontDirectoryPtr) fpe->private); @@ -103,13 +117,9 @@ } static int -transfer_values_to_alias(entryname, entrynamelength, resolvedname, - aliasName, vals) - char *entryname; - int entrynamelength; - char *resolvedname; - char **aliasName; - FontScalablePtr vals; +transfer_values_to_alias(char *entryname, int entrynamelength, + char *resolvedname, + char **aliasName, FontScalablePtr vals) { static char aliasname[MAXFONTNAMELEN]; int nameok = 1, len; @@ -117,6 +127,7 @@ *aliasName = resolvedname; if ((len = strlen(*aliasName)) <= MAXFONTNAMELEN && + (entrynamelength < MAXFONTNAMELEN) && FontFileCountDashes (*aliasName, len) == 14) { FontScalableRec tmpVals; @@ -158,7 +169,6 @@ gotchas */ if (FontFileCompleteXLFD(&tmpVals2, &tmpVals2)) { - double hypot(); tempmatrix[0] = matrix[0] * tmpVals2.point_matrix[0] + matrix[1] * tmpVals2.point_matrix[2]; @@ -219,19 +229,11 @@ /* ARGSUSED */ int -FontFileOpenFont (client, fpe, flags, name, namelen, format, fmask, - id, pFont, aliasName, non_cachable_font) - pointer client; - FontPathElementPtr fpe; - Mask flags; - char *name; - int namelen; - fsBitmapFormat format; - fsBitmapFormatMask fmask; - XID id; - FontPtr *pFont; - char **aliasName; - FontPtr non_cachable_font; +FontFileOpenFont (pointer client, FontPathElementPtr fpe, Mask flags, + char *name, int namelen, + fsBitmapFormat format, fsBitmapFormatMask fmask, + XID id, FontPtr *pFont, char **aliasName, + FontPtr non_cachable_font) { FontDirectoryPtr dir; char lowerName[MAXFONTNAMELEN]; @@ -329,8 +331,7 @@ if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) || !(tmpName.length = strlen (lowerName), entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, - &vals))) - { + &vals))) { CopyISOLatin1Lowered (lowerName, name, namelen); lowerName[namelen] = '\0'; tmpName.name = lowerName; @@ -422,11 +423,16 @@ vals.ranges = ranges; vals.nranges = nranges; - strcpy (fileName, dir->directory); - strcat (fileName, scalable->fileName); - ret = (*scalable->renderer->OpenScalable) (fpe, pFont, + if (strlen(dir->directory) + strlen(scalable->fileName) >= + sizeof(fileName)) { + ret = BadFontName; + } else { + strcpy (fileName, dir->directory); + strcat (fileName, scalable->fileName); + ret = (*scalable->renderer->OpenScalable) (fpe, pFont, flags, entry, fileName, &vals, format, fmask, non_cachable_font); + } /* In case rasterizer does something bad because of charset subsetting... */ @@ -461,9 +467,7 @@ /* ARGSUSED */ void -FontFileCloseFont (fpe, pFont) - FontPathElementPtr fpe; - FontPtr pFont; +FontFileCloseFont (FontPathElementPtr fpe, FontPtr pFont) { FontEntryPtr entry; @@ -484,14 +488,11 @@ (*pFont->unload_font) (pFont); } -int -FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format, fmask, - non_cachable_font) - FontPathElementPtr fpe; - int flags; - FontEntryPtr entry; - FontPtr *pFont; - FontPtr non_cachable_font; +static int +FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont, + int flags, FontEntryPtr entry, + fsBitmapFormat format, fsBitmapFormatMask fmask, + FontPtr non_cachable_font) { FontBitmapEntryPtr bitmap; char fileName[MAXFONTFILENAMELEN*2+1]; @@ -500,6 +501,10 @@ dir = (FontDirectoryPtr) fpe->private; bitmap = &entry->u.bitmap; + if(!bitmap || !bitmap->renderer->OpenBitmap) + return BadFontName; + if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName)) + return BadFontName; strcpy (fileName, dir->directory); strcat (fileName, bitmap->fileName); ret = (*bitmap->renderer->OpenBitmap) @@ -514,23 +519,17 @@ } int -FontFileOpenBitmap (fpe, pFont, flags, entry, format, fmask) - FontPathElementPtr fpe; - FontPtr *pFont; - int flags; - FontEntryPtr entry; - fsBitmapFormat format; - fsBitmapFormatMask fmask; +FontFileOpenBitmap (FontPathElementPtr fpe, FontPtr *pFont, + int flags, FontEntryPtr entry, + fsBitmapFormat format, fsBitmapFormatMask fmask) { return FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format, fmask, (FontPtr)0); } -int -FontFileGetInfoBitmap (fpe, pFontInfo, entry) - FontPathElementPtr fpe; - FontInfoPtr pFontInfo; - FontEntryPtr entry; +static int +FontFileGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo, + FontEntryPtr entry) { FontBitmapEntryPtr bitmap; char fileName[MAXFONTFILENAMELEN*2+1]; @@ -539,6 +538,10 @@ dir = (FontDirectoryPtr) fpe->private; bitmap = &entry->u.bitmap; + if (!bitmap || !bitmap->renderer->GetInfoBitmap) + return BadFontName; + if (strlen(dir->directory) + strlen(bitmap->fileName) >= sizeof(fileName)) + return BadFontName; strcpy (fileName, dir->directory); strcat (fileName, bitmap->fileName); ret = (*bitmap->renderer->GetInfoBitmap) (fpe, pFontInfo, entry, fileName); @@ -546,16 +549,10 @@ } static void -_FontFileAddScalableNames(names, scaleNames, nameptr, zeroChars, vals, ranges, - nranges, max) - FontNamesPtr names; - FontNamesPtr scaleNames; - FontNamePtr nameptr; - char *zeroChars; - FontScalablePtr vals; - fsRange *ranges; - int nranges; - int *max; +_FontFileAddScalableNames(FontNamesPtr names, FontNamesPtr scaleNames, + FontNamePtr nameptr, char *zeroChars, + FontScalablePtr vals, fsRange *ranges, + int nranges, int *max) { int i; FontScalableRec zeroVals, tmpVals; @@ -669,14 +666,9 @@ /* ARGSUSED */ static int -_FontFileListFonts (client, fpe, pat, len, max, names, mark_aliases) - pointer client; - FontPathElementPtr fpe; - char *pat; - int len; - int max; - FontNamesPtr names; - int mark_aliases; +_FontFileListFonts (pointer client, FontPathElementPtr fpe, + char *pat, int len, int max, FontNamesPtr names, + int mark_aliases) { FontDirectoryPtr dir; char lowerChars[MAXFONTNAMELEN], zeroChars[MAXFONTNAMELEN]; @@ -781,25 +773,16 @@ } LFWIDataRec, *LFWIDataPtr; int -FontFileListFonts (client, fpe, pat, len, max, names) - pointer client; - FontPathElementPtr fpe; - char *pat; - int len; - int max; - FontNamesPtr names; +FontFileListFonts (pointer client, FontPathElementPtr fpe, char *pat, + int len, int max, FontNamesPtr names) { return _FontFileListFonts (client, fpe, pat, len, max, names, 0); } int -FontFileStartListFontsWithInfo(client, fpe, pat, len, max, privatep) - pointer client; - FontPathElementPtr fpe; - char *pat; - int len; - int max; - pointer *privatep; +FontFileStartListFontsWithInfo(pointer client, FontPathElementPtr fpe, + char *pat, int len, int max, + pointer *privatep) { LFWIDataPtr data; int ret; @@ -827,12 +810,9 @@ /* ARGSUSED */ static int -FontFileListOneFontWithInfo (client, fpe, namep, namelenp, pFontInfo) - pointer client; - FontPathElementPtr fpe; - char **namep; - int *namelenp; - FontInfoPtr *pFontInfo; +FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe, + char **namep, int *namelenp, + FontInfoPtr *pFontInfo) { FontDirectoryPtr dir; char lowerName[MAXFONTNAMELEN]; @@ -843,26 +823,117 @@ FontScalableEntryPtr scalable; FontScaledPtr scaled; FontBitmapEntryPtr bitmap; - FontAliasEntryPtr alias; int ret; + Bool noSpecificSize; + int nranges; + fsRange *ranges; + char *name = *namep; int namelen = *namelenp; - Bool noSpecificSize; if (namelen >= MAXFONTNAMELEN) return AllocError; dir = (FontDirectoryPtr) fpe->private; + + /* Match non-scalable pattern */ CopyISOLatin1Lowered (lowerName, name, namelen); lowerName[namelen] = '\0'; + ranges = FontParseRanges(lowerName, &nranges); tmpName.name = lowerName; tmpName.length = namelen; tmpName.ndashes = FontFileCountDashes (lowerName, namelen); - /* Match XLFD patterns */ - if (tmpName.ndashes == 14 && + if (!FontParseXLFDName(lowerName, &vals, FONT_XLFD_REPLACE_NONE)) + bzero(&vals, sizeof(vals)); + if (!(entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName)) && + tmpName.ndashes == 14 && FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO)) { - tmpName.length = strlen (lowerName); + tmpName.length = strlen(lowerName); + entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName); + } + + if (entry) + { + switch (entry->type) { + case FONT_ENTRY_BITMAP: + bitmap = &entry->u.bitmap; + if (bitmap->pFont) + { + *pFontInfo = &bitmap->pFont->info; + ret = Successful; + } + else + { + ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry); + } + break; + case FONT_ENTRY_ALIAS: + vals.nranges = nranges; + vals.ranges = ranges; + transfer_values_to_alias(entry->name.name, entry->name.length, + entry->u.alias.resolved, namep, &vals); + *namelenp = strlen (*namep); + ret = FontNameAlias; + break; +#ifdef NOTYET + case FONT_ENTRY_BC: + /* no LFWI for this yet */ + bc = &entry->u.bc; + entry = bc->entry; + /* Make a new scaled instance */ + if (strlen(dir->directory) + strlen(scalable->fileName) >= + sizeof(fileName)) { + ret = BadFontName; + } else { + strcpy (fileName, dir->directory); + strcat (fileName, scalable->fileName); + ret = (*scalable->renderer->GetInfoScalable) + (fpe, *pFontInfo, entry, tmpName, fileName, &bc->vals); + } + break; +#endif + default: + ret = BadFontName; + } + } + else + { + ret = BadFontName; + } + + if (ret != BadFontName) + { + if (ranges) xfree(ranges); + return ret; + } + + /* Match XLFD patterns */ + CopyISOLatin1Lowered (lowerName, name, namelen); + lowerName[namelen] = '\0'; + tmpName.name = lowerName; + tmpName.length = namelen; + tmpName.ndashes = FontFileCountDashes (lowerName, namelen); + if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) || + !(tmpName.length = strlen (lowerName), + entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, + &vals))) { + CopyISOLatin1Lowered (lowerName, name, namelen); + lowerName[namelen] = '\0'; + tmpName.name = lowerName; + tmpName.length = namelen; + tmpName.ndashes = FontFileCountDashes (lowerName, namelen); entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals); + if (entry) + { + strcpy(lowerName, entry->name.name); + tmpName.name = lowerName; + tmpName.length = entry->name.length; + tmpName.ndashes = entry->name.ndashes; + } + } + + if (entry) + { noSpecificSize = FALSE; /* TRUE breaks XLFD enhancements */ if (entry && entry->type == FONT_ENTRY_SCALABLE && FontFileCompleteXLFD (&vals, &entry->u.scalable.extra->defaults)) @@ -915,18 +986,23 @@ #endif { char origName[MAXFONTNAMELEN]; - fsRange *ranges; CopyISOLatin1Lowered (origName, name, namelen); origName[namelen] = '\0'; vals.xlfdName = origName; - vals.ranges = FontParseRanges(origName, &vals.nranges); - ranges = vals.ranges; + vals.ranges = ranges; + vals.nranges = nranges; + /* Make a new scaled instance */ - strcpy (fileName, dir->directory); - strcat (fileName, scalable->fileName); - ret = (*scalable->renderer->GetInfoScalable) - (fpe, *pFontInfo, entry, &tmpName, fileName, &vals); + if (strlen(dir->directory) + strlen(scalable->fileName) >= + sizeof(fileName)) { + ret = BadFontName; + } else { + strcpy (fileName, dir->directory); + strcat (fileName, scalable->fileName); + ret = (*scalable->renderer->GetInfoScalable) + (fpe, *pFontInfo, entry, &tmpName, fileName, &vals); + } if (ranges) xfree(ranges); } } @@ -935,61 +1011,19 @@ CopyISOLatin1Lowered (lowerName, name, namelen); tmpName.length = namelen; } - /* Match non XLFD pattern */ - if ((entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName))) - { - switch (entry->type) { - case FONT_ENTRY_BITMAP: - bitmap = &entry->u.bitmap; - if (bitmap->pFont) - { - *pFontInfo = &bitmap->pFont->info; - ret = Successful; - } - else - { - ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry); - } - break; - case FONT_ENTRY_ALIAS: - alias = &entry->u.alias; - *(char **)pFontInfo = name; - *namelenp = strlen (*namep = alias->resolved); - ret = FontNameAlias; - break; -#ifdef NOTYET - case FONT_ENTRY_BC: - /* no LFWI for this yet */ - bc = &entry->u.bc; - entry = bc->entry; - /* Make a new scaled instance */ - strcpy (fileName, dir->directory); - strcat (fileName, scalable->fileName); - ret = (*scalable->renderer->GetInfoScalable) - (fpe, *pFontInfo, entry, tmpName, fileName, &bc->vals); - break; -#endif - default: - ret = BadFontName; - } - } else - { ret = BadFontName; - } + + if (ranges) + xfree(ranges); return ret; } int -FontFileListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo, - numFonts, private) - pointer client; - FontPathElementPtr fpe; - char **namep; - int *namelenp; - FontInfoPtr *pFontInfo; - int *numFonts; - pointer private; +FontFileListNextFontWithInfo(pointer client, FontPathElementPtr fpe, + char **namep, int *namelenp, + FontInfoPtr *pFontInfo, + int *numFonts, pointer private) { LFWIDataPtr data = (LFWIDataPtr) private; int ret; @@ -1015,13 +1049,9 @@ } int -FontFileStartListFontsAndAliases(client, fpe, pat, len, max, privatep) - pointer client; - FontPathElementPtr fpe; - char *pat; - int len; - int max; - pointer *privatep; +FontFileStartListFontsAndAliases(pointer client, FontPathElementPtr fpe, + char *pat, int len, int max, + pointer *privatep) { LFWIDataPtr data; int ret; @@ -1048,15 +1078,9 @@ } int -FontFileListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp, - resolvedlenp, private) - pointer client; - FontPathElementPtr fpe; - char **namep; - int *namelenp; - char **resolvedp; - int *resolvedlenp; - pointer private; +FontFileListNextFontOrAlias(pointer client, FontPathElementPtr fpe, + char **namep, int *namelenp, char **resolvedp, + int *resolvedlenp, pointer private) { LFWIDataPtr data = (LFWIDataPtr) private; int ret; @@ -1095,27 +1119,22 @@ return ret; } - -extern void FontFileEmptyBitmapSource(); -typedef int (*IntFunc) (); -static int font_file_type; - void -FontFileRegisterLocalFpeFunctions () +FontFileRegisterLocalFpeFunctions (void) { - font_file_type = RegisterFPEFunctions(FontFileNameCheck, - FontFileInitFPE, - FontFileFreeFPE, - FontFileResetFPE, - FontFileOpenFont, - FontFileCloseFont, - FontFileListFonts, - FontFileStartListFontsWithInfo, - FontFileListNextFontWithInfo, - (IntFunc) 0, - (IntFunc) 0, - (IntFunc) 0, - FontFileStartListFontsAndAliases, - FontFileListNextFontOrAlias, - FontFileEmptyBitmapSource); + RegisterFPEFunctions(FontFileNameCheck, + FontFileInitFPE, + FontFileFreeFPE, + FontFileResetFPE, + FontFileOpenFont, + FontFileCloseFont, + FontFileListFonts, + FontFileStartListFontsWithInfo, + FontFileListNextFontWithInfo, + NULL, + NULL, + NULL, + FontFileStartListFontsAndAliases, + FontFileListNextFontOrAlias, + FontFileEmptyBitmapSource); }