summaryrefslogtreecommitdiff
path: root/src/fontfile
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-26 22:48:40 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-26 22:48:40 +0000
commit44999e526a31721b0ed75ad6047948da837be4e0 (patch)
treeafa2e6b416645bc84cbc07f017b26dafc69c14fa /src/fontfile
parent94817d4f3277d927bf96431c24033d8cd67d9a30 (diff)
merge latest (4.3.99.16) from XFree86 (vendor) branch
Diffstat (limited to 'src/fontfile')
-rw-r--r--src/fontfile/dirfile.c19
-rw-r--r--src/fontfile/ffcheck.c35
-rw-r--r--src/fontfile/fontdir.c36
-rw-r--r--src/fontfile/fontfile.c186
-rw-r--r--src/fontfile/printerfont.c36
5 files changed, 177 insertions, 135 deletions
diff --git a/src/fontfile/dirfile.c b/src/fontfile/dirfile.c
index 5f90501..bb7c339 100644
--- a/src/fontfile/dirfile.c
+++ b/src/fontfile/dirfile.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.15 2002/05/31 18:45:50 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/dirfile.c,v 3.16 2003/04/07 16:23:31 eich Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -90,6 +90,8 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
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);
@@ -106,6 +108,7 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
if (format[0] == '\0')
sprintf(format, "%%%ds %%%d[^\n]\n",
MAXFONTFILENAMELEN-1, MAXFONTNAMELEN-1);
+
while ((count = fscanf(file, format, file_name, font_name)) != EOF) {
#ifdef __UNIXOS2__
/* strip any existing trailing CR */
@@ -118,14 +121,16 @@ FontFileReadDirectory (char *directory, FontDirectoryPtr *pdir)
fclose(file);
return BadFontPath;
}
- if (!FontFileAddFontFile (dir, font_name, file_name))
- {
- FontFileFreeDir (dir);
- fclose(file);
- return BadFontPath;
- }
+ if (FontFileAddFontFile (dir, font_name, file_name))
+ found_font = TRUE;
+ }
+ if (!found_font) {
+ FontFileFreeDir (dir);
+ fclose(file);
+ return BadFontPath;
}
fclose(file);
+
} else if (errno != ENOENT) {
return BadFontPath;
}
diff --git a/src/fontfile/ffcheck.c b/src/fontfile/ffcheck.c
index 4de2a4b..5289b7f 100644
--- a/src/fontfile/ffcheck.c
+++ b/src/fontfile/ffcheck.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fontfile/ffcheck.c,v 1.15 2001/12/14 19:56:51 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/ffcheck.c,v 1.16 2003/05/27 22:26:49 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -115,9 +115,6 @@ FontFileCheckListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
return BadFontName;
}
-typedef int (*IntFunc) (void);
-static int font_file_check_type;
-
void
FontFileCheckRegisterFpeFunctions (void)
{
@@ -160,19 +157,19 @@ FontFileCheckRegisterFpeFunctions (void)
}
#endif
- font_file_check_type = RegisterFPEFunctions(FontFileNameCheck,
- FontFileInitFPE,
- FontFileFreeFPE,
- FontFileResetFPE,
- FontFileCheckOpenFont,
- FontFileCloseFont,
- FontFileCheckListFonts,
- FontFileCheckStartListFontsWithInfo,
- FontFileCheckListNextFontWithInfo,
- NULL,
- NULL,
- NULL,
- FontFileCheckStartListFontsAndAliases,
- FontFileCheckListNextFontOrAlias,
- FontFileEmptyBitmapSource);
+ RegisterFPEFunctions(FontFileNameCheck,
+ FontFileInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ FontFileCheckOpenFont,
+ FontFileCloseFont,
+ FontFileCheckListFonts,
+ FontFileCheckStartListFontsWithInfo,
+ FontFileCheckListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ FontFileCheckStartListFontsAndAliases,
+ FontFileCheckListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
}
diff --git a/src/fontfile/fontdir.c b/src/fontfile/fontdir.c
index a2bd411..28e58b6 100644
--- a/src/fontfile/fontdir.c
+++ b/src/fontfile/fontdir.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fontfile/fontdir.c,v 3.19 2002/05/31 18:45:50 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/fontdir.c,v 3.22 2003/07/07 16:40:11 eich Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -678,11 +678,10 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
#endif
if (!isscale || (vals.values_supplied & SIZE_SPECIFY_MASK))
{
- /* If the fontname says it is nonScalable, make sure that the
- * renderer supports OpenBitmap and GetInfoBitmap.
+ /*
+ * If the renderer doesn't support OpenBitmap, FontFileOpenFont
+ * will still do the right thing.
*/
- if (renderer->OpenBitmap && renderer->GetInfoBitmap)
- {
entry.type = FONT_ENTRY_BITMAP;
entry.u.bitmap.renderer = renderer;
entry.u.bitmap.pFont = NullFont;
@@ -693,7 +692,6 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
xfree (entry.u.bitmap.fileName);
return FALSE;
}
- }
}
/*
* Parse out scalable fields from XLFD names - a scalable name
@@ -701,11 +699,6 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
*/
if (isscale)
{
- /* If the fontname says it is scalable, make sure that the
- * renderer supports OpenScalable and GetInfoScalable.
- */
- if (renderer->OpenScalable && renderer->GetInfoScalable)
- {
if (vals.values_supplied & SIZE_SPECIFY_MASK)
{
bzero((char *)&zeroVals, sizeof(zeroVals));
@@ -728,10 +721,13 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
if (!(existing->u.scalable.fileName = FontFileSaveString (fileName)))
return FALSE;
}
- FontFileCompleteXLFD(&vals, &vals);
- FontFileAddScaledInstance (existing, &vals, NullFont,
- bitmap->name.name);
- return TRUE;
+ if(bitmap)
+ {
+ FontFileCompleteXLFD(&vals, &vals);
+ FontFileAddScaledInstance (existing, &vals, NullFont,
+ bitmap->name.name);
+ return TRUE;
+ }
}
}
if (!(entry.u.scalable.fileName = FontFileSaveString (fileName)))
@@ -795,11 +791,13 @@ FontFileAddFontFile (FontDirectoryPtr dir, char *fontName, char *fileName)
}
if (vals.values_supplied & SIZE_SPECIFY_MASK)
{
- FontFileCompleteXLFD(&vals, &vals);
- FontFileAddScaledInstance (scalable, &vals, NullFont,
- bitmap->name.name);
+ if(bitmap)
+ {
+ FontFileCompleteXLFD(&vals, &vals);
+ FontFileAddScaledInstance (scalable, &vals, NullFont,
+ bitmap->name.name);
+ }
}
- }
}
return TRUE;
}
diff --git a/src/fontfile/fontfile.c b/src/fontfile/fontfile.c
index 1e39413..6378c39 100644
--- a/src/fontfile/fontfile.c
+++ b/src/fontfile/fontfile.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.16 2002/05/31 18:45:50 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.19 2003/11/08 02:02:03 dawes Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -331,8 +331,7 @@ FontFileOpenFont (pointer client, FontPathElementPtr fpe, Mask flags,
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;
@@ -497,6 +496,8 @@ FontFileOpenBitmapNCF (FontPathElementPtr fpe, FontPtr *pFont,
dir = (FontDirectoryPtr) fpe->private;
bitmap = &entry->u.bitmap;
+ if(!bitmap || !bitmap->renderer->OpenBitmap)
+ return BadFontName;
strcpy (fileName, dir->directory);
strcat (fileName, bitmap->fileName);
ret = (*bitmap->renderer->OpenBitmap)
@@ -811,26 +812,112 @@ FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
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 */
+ 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))
@@ -883,13 +970,13 @@ FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
#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);
@@ -903,48 +990,11 @@ FontFileListOneFontWithInfo (pointer client, FontPathElementPtr fpe,
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;
}
@@ -1048,26 +1098,22 @@ FontFileListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
return ret;
}
-
-typedef int (*IntFunc) (void);
-static int font_file_type;
-
void
FontFileRegisterLocalFpeFunctions (void)
{
- font_file_type = RegisterFPEFunctions(FontFileNameCheck,
- FontFileInitFPE,
- FontFileFreeFPE,
- FontFileResetFPE,
- FontFileOpenFont,
- FontFileCloseFont,
- FontFileListFonts,
- FontFileStartListFontsWithInfo,
- FontFileListNextFontWithInfo,
- NULL,
- NULL,
- NULL,
- FontFileStartListFontsAndAliases,
- FontFileListNextFontOrAlias,
- FontFileEmptyBitmapSource);
+ RegisterFPEFunctions(FontFileNameCheck,
+ FontFileInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ FontFileOpenFont,
+ FontFileCloseFont,
+ FontFileListFonts,
+ FontFileStartListFontsWithInfo,
+ FontFileListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ FontFileStartListFontsAndAliases,
+ FontFileListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
}
diff --git a/src/fontfile/printerfont.c b/src/fontfile/printerfont.c
index 6759e91..112b1bc 100644
--- a/src/fontfile/printerfont.c
+++ b/src/fontfile/printerfont.c
@@ -25,7 +25,7 @@ used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
-/* $XFree86: xc/lib/font/fontfile/printerfont.c,v 1.5 2001/12/14 19:56:52 dawes Exp $ */
+/* $XFree86: xc/lib/font/fontfile/printerfont.c,v 1.6 2003/05/27 22:26:49 tsi Exp $ */
/*
* Author: Keith Packard, MIT X Consortium
@@ -154,26 +154,22 @@ PrinterFontListNextFontOrAlias(pointer client, FontPathElementPtr fpe,
return BadFontName;
}
-typedef int (*IntFunc) (void);
-static int printer_font_type;
-
void
PrinterFontRegisterFpeFunctions (void)
{
- /* what is the use of printer font type? */
- printer_font_type = RegisterFPEFunctions(PrinterFontNameCheck,
- PrinterFontInitFPE,
- FontFileFreeFPE,
- FontFileResetFPE,
- PrinterFontOpenFont,
- FontFileCloseFont,
- PrinterFontListFonts,
- PrinterFontStartListFontsWithInfo,
- PrinterFontListNextFontWithInfo,
- NULL,
- NULL,
- NULL,
- PrinterFontStartListFontsAndAliases,
- PrinterFontListNextFontOrAlias,
- FontFileEmptyBitmapSource);
+ RegisterFPEFunctions(PrinterFontNameCheck,
+ PrinterFontInitFPE,
+ FontFileFreeFPE,
+ FontFileResetFPE,
+ PrinterFontOpenFont,
+ FontFileCloseFont,
+ PrinterFontListFonts,
+ PrinterFontStartListFontsWithInfo,
+ PrinterFontListNextFontWithInfo,
+ NULL,
+ NULL,
+ NULL,
+ PrinterFontStartListFontsAndAliases,
+ PrinterFontListNextFontOrAlias,
+ FontFileEmptyBitmapSource);
}