1 /* $TOG: fontfile.c /main/29 1997/05/23 16:36:56 barstow $ */
5 Copyright (c) 1991 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
29 /* $XFree86: xc/lib/font/fontfile/fontfile.c,v 3.3.4.2 1997/07/05 15:55:36 dawes Exp $ */
32 * Author: Keith Packard, MIT X Consortium
34 /* $NCDId: @(#)fontfile.c,v 1.6 1991/07/02 17:00:46 lemke Exp $ */
39 * Map FPE functions to renderer functions
43 FontFileNameCheck (name)
48 /* OS/2 uses D:/... as a path name for fonts, so accept this as a valid
49 * path if it starts with a letter and a colon
51 if (isalpha(*name) && name[1]==':')
56 return ((strcmp(name, "built-ins") == 0) || (*name == '/'));
62 FontPathElementPtr fpe;
67 status = FontFileReadDirectory (fpe->name, &dir);
68 if (status == Successful)
70 if (dir->nonScalable.used > 0)
71 if (!FontFileRegisterBitmapSource (fpe))
73 FontFileFreeFPE (fpe);
76 fpe->private = (pointer) dir;
83 FontFileResetFPE (fpe)
84 FontPathElementPtr fpe;
88 dir = (FontDirectoryPtr) fpe->private;
90 * The reset must fail for bitmap fonts because they get cleared when
93 if (FontFileDirectoryChanged (dir))
95 /* can't do it, so tell the caller to close and re-open */
96 return FPEResetFailed;
100 if (dir->nonScalable.used > 0)
101 if (!FontFileRegisterBitmapSource (fpe))
103 return FPEResetFailed;
110 FontFileFreeFPE (fpe)
111 FontPathElementPtr fpe;
113 FontFileUnregisterBitmapSource (fpe);
114 FontFileFreeDir ((FontDirectoryPtr) fpe->private);
119 transfer_values_to_alias(entryname, entrynamelength, resolvedname,
125 FontScalablePtr vals;
127 static char aliasname[MAXFONTNAMELEN];
129 char lowerName[MAXFONTNAMELEN];
131 *aliasName = resolvedname;
132 if ((len = strlen(*aliasName)) <= MAXFONTNAMELEN &&
133 FontFileCountDashes (*aliasName, len) == 14)
135 FontScalableRec tmpVals;
136 FontScalableRec tmpVals2;
140 /* If we're aliasing a scalable name, transfer values
141 from the name into the destination alias, multiplying
142 by matrices that appear in the alias. */
144 CopyISOLatin1Lowered (lowerName, entryname,
146 lowerName[entrynamelength] = '\0';
148 if (FontParseXLFDName(lowerName, &tmpVals,
149 FONT_XLFD_REPLACE_NONE) &&
150 !tmpVals.values_supplied &&
151 FontParseXLFDName(*aliasName, &tmpVals,
152 FONT_XLFD_REPLACE_NONE))
154 double *matrix = 0, tempmatrix[4];
156 /* Use a matrix iff exactly one is defined */
157 if ((tmpVals.values_supplied & PIXELSIZE_MASK) ==
159 !(tmpVals.values_supplied & POINTSIZE_MASK))
160 matrix = tmpVals.pixel_matrix;
161 else if ((tmpVals.values_supplied & POINTSIZE_MASK) ==
163 !(tmpVals.values_supplied & PIXELSIZE_MASK))
164 matrix = tmpVals.point_matrix;
166 /* If matrix given in the alias, compute new point
167 and/or pixel matrices */
170 /* Complete the XLFD name to avoid potential
172 if (FontFileCompleteXLFD(&tmpVals2, &tmpVals2))
176 matrix[0] * tmpVals2.point_matrix[0] +
177 matrix[1] * tmpVals2.point_matrix[2];
179 matrix[0] * tmpVals2.point_matrix[1] +
180 matrix[1] * tmpVals2.point_matrix[3];
182 matrix[2] * tmpVals2.point_matrix[0] +
183 matrix[3] * tmpVals2.point_matrix[2];
185 matrix[2] * tmpVals2.point_matrix[1] +
186 matrix[3] * tmpVals2.point_matrix[3];
187 tmpVals2.point_matrix[0] = tempmatrix[0];
188 tmpVals2.point_matrix[1] = tempmatrix[1];
189 tmpVals2.point_matrix[2] = tempmatrix[2];
190 tmpVals2.point_matrix[3] = tempmatrix[3];
193 matrix[0] * tmpVals2.pixel_matrix[0] +
194 matrix[1] * tmpVals2.pixel_matrix[2];
196 matrix[0] * tmpVals2.pixel_matrix[1] +
197 matrix[1] * tmpVals2.pixel_matrix[3];
199 matrix[2] * tmpVals2.pixel_matrix[0] +
200 matrix[3] * tmpVals2.pixel_matrix[2];
202 matrix[2] * tmpVals2.pixel_matrix[1] +
203 matrix[3] * tmpVals2.pixel_matrix[3];
204 tmpVals2.pixel_matrix[0] = tempmatrix[0];
205 tmpVals2.pixel_matrix[1] = tempmatrix[1];
206 tmpVals2.pixel_matrix[2] = tempmatrix[2];
207 tmpVals2.pixel_matrix[3] = tempmatrix[3];
209 tmpVals2.values_supplied =
210 (tmpVals2.values_supplied &
211 ~(PIXELSIZE_MASK | POINTSIZE_MASK)) |
212 PIXELSIZE_ARRAY | POINTSIZE_ARRAY;
218 CopyISOLatin1Lowered (aliasname, *aliasName, len + 1);
219 if (nameok && FontParseXLFDName(aliasname, &tmpVals2,
220 FONT_XLFD_REPLACE_VALUE))
221 /* Return a version of the aliasname that has
222 had the vals stuffed into it. To avoid
223 memory leak, this alias name lives in a
224 static buffer. The caller needs to be done
225 with this buffer before this procedure is
226 called again to avoid reentrancy problems. */
227 *aliasName = aliasname;
235 FontFileOpenFont (client, fpe, flags, name, namelen, format, fmask,
236 id, pFont, aliasName, non_cachable_font)
238 FontPathElementPtr fpe;
242 fsBitmapFormat format;
243 fsBitmapFormatMask fmask;
247 FontPtr non_cachable_font;
249 FontDirectoryPtr dir;
250 char lowerName[MAXFONTNAMELEN];
251 char fileName[MAXFONTFILENAMELEN*2 + 1];
254 FontScalableRec vals;
255 FontScalableEntryPtr scalable;
256 FontScaledPtr scaled;
257 FontBitmapEntryPtr bitmap;
264 if (namelen >= MAXFONTNAMELEN)
266 dir = (FontDirectoryPtr) fpe->private;
268 /* Match non-scalable pattern */
269 CopyISOLatin1Lowered (lowerName, name, namelen);
270 lowerName[namelen] = '\0';
271 ranges = FontParseRanges(lowerName, &nranges);
272 tmpName.name = lowerName;
273 tmpName.length = namelen;
274 tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
275 if (!FontParseXLFDName(lowerName, &vals, FONT_XLFD_REPLACE_NONE))
276 bzero(&vals, sizeof(vals));
277 if (!(entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName)) &&
278 tmpName.ndashes == 14 &&
279 FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO))
281 tmpName.length = strlen(lowerName);
282 entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName);
288 switch (entry->type) {
289 case FONT_ENTRY_BITMAP:
290 bitmap = &entry->u.bitmap;
293 *pFont = bitmap->pFont;
299 ret = FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format,
300 fmask, non_cachable_font);
301 if (ret == Successful && *pFont)
305 case FONT_ENTRY_ALIAS:
306 vals.nranges = nranges;
307 vals.ranges = ranges;
308 transfer_values_to_alias(entry->name.name, entry->name.length,
309 entry->u.alias.resolved, aliasName, &vals);
316 ret = (*scalable->renderer->OpenScalable)
317 (fpe, pFont, flags, entry, &bc->vals, format, fmask,
319 if (ret == Successful && *pFont)
332 if (ret != BadFontName)
334 if (ranges) xfree(ranges);
338 /* Match XLFD patterns */
339 CopyISOLatin1Lowered (lowerName, name, namelen);
340 lowerName[namelen] = '\0';
341 tmpName.name = lowerName;
342 tmpName.length = namelen;
343 tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
344 if (!FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO) ||
345 !(tmpName.length = strlen (lowerName),
346 entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName,
349 CopyISOLatin1Lowered (lowerName, name, namelen);
350 lowerName[namelen] = '\0';
351 tmpName.name = lowerName;
352 tmpName.length = namelen;
353 tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
354 entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
357 strcpy(lowerName, entry->name.name);
358 tmpName.name = lowerName;
359 tmpName.length = entry->name.length;
360 tmpName.ndashes = entry->name.ndashes;
365 noSpecificSize = FALSE; /* TRUE breaks XLFD enhancements */
366 if (entry->type == FONT_ENTRY_SCALABLE &&
367 FontFileCompleteXLFD (&vals, &entry->u.scalable.extra->defaults))
369 scalable = &entry->u.scalable;
370 if ((vals.values_supplied & PIXELSIZE_MASK) == PIXELSIZE_ARRAY ||
371 (vals.values_supplied & POINTSIZE_MASK) == POINTSIZE_ARRAY ||
372 (vals.values_supplied &
373 ~SIZE_SPECIFY_MASK & ~CHARSUBSET_SPECIFIED))
376 scaled = FontFileFindScaledInstance (entry, &vals,
379 * A scaled instance can occur one of two ways:
381 * Either the font has been scaled to this
382 * size already, in which case scaled->pFont
383 * will point at that font.
385 * Or a bitmap instance in this size exists,
386 * which is handled as if we got a pattern
387 * matching the bitmap font name.
393 *pFont = scaled->pFont;
397 else if (scaled->bitmap)
399 entry = scaled->bitmap;
400 bitmap = &entry->u.bitmap;
403 *pFont = bitmap->pFont;
409 ret = FontFileOpenBitmapNCF (fpe, pFont, flags, entry,
412 if (ret == Successful && *pFont)
416 else /* "cannot" happen */
423 ret = FontFileMatchBitmapSource (fpe, pFont, flags, entry, &tmpName, &vals, format, fmask, noSpecificSize);
424 if (ret != Successful)
426 char origName[MAXFONTNAMELEN];
428 CopyISOLatin1Lowered (origName, name, namelen);
429 origName[namelen] = '\0';
431 /* Pass the original XLFD name in the vals
432 structure; the rasterizer is free to examine it
433 for hidden meanings. This information will not
434 be saved in the scaled-instances table. */
436 vals.xlfdName = origName;
437 vals.ranges = ranges;
438 vals.nranges = nranges;
440 strcpy (fileName, dir->directory);
441 strcat (fileName, scalable->fileName);
442 ret = (*scalable->renderer->OpenScalable) (fpe, pFont,
443 flags, entry, fileName, &vals, format, fmask,
446 /* In case rasterizer does something bad because of
447 charset subsetting... */
448 if (ret == Successful &&
449 ((*pFont)->info.firstCol > (*pFont)->info.lastCol ||
450 (*pFont)->info.firstRow > (*pFont)->info.lastRow))
452 (*(*pFont)->unload_font)(*pFont);
455 /* Save the instance */
456 if (ret == Successful)
458 if (FontFileAddScaledInstance (entry, &vals,
462 (*pFont)->fpePrivate = (pointer) 0;
478 FontFileCloseFont (fpe, pFont)
479 FontPathElementPtr fpe;
484 if (entry = (FontEntryPtr) pFont->fpePrivate) {
485 switch (entry->type) {
486 case FONT_ENTRY_SCALABLE:
487 FontFileRemoveScaledInstance (entry, pFont);
489 case FONT_ENTRY_BITMAP:
490 entry->u.bitmap.pFont = 0;
493 /* "cannot" happen */
496 pFont->fpePrivate = 0;
498 (*pFont->unload_font) (pFont);
502 FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format, fmask,
504 FontPathElementPtr fpe;
508 FontPtr non_cachable_font;
510 FontBitmapEntryPtr bitmap;
511 char fileName[MAXFONTFILENAMELEN*2+1];
513 FontDirectoryPtr dir;
515 dir = (FontDirectoryPtr) fpe->private;
516 bitmap = &entry->u.bitmap;
517 strcpy (fileName, dir->directory);
518 strcat (fileName, bitmap->fileName);
519 ret = (*bitmap->renderer->OpenBitmap)
520 (fpe, pFont, flags, entry, fileName, format, fmask,
522 if (ret == Successful)
524 bitmap->pFont = *pFont;
525 (*pFont)->fpePrivate = (pointer) entry;
531 FontFileOpenBitmap (fpe, pFont, flags, entry, format, fmask)
532 FontPathElementPtr fpe;
537 return FontFileOpenBitmapNCF (fpe, pFont, flags, entry, format, fmask,
541 FontFileGetInfoBitmap (fpe, pFontInfo, entry)
542 FontPathElementPtr fpe;
543 FontInfoPtr pFontInfo;
546 FontBitmapEntryPtr bitmap;
547 char fileName[MAXFONTFILENAMELEN*2+1];
549 FontDirectoryPtr dir;
551 dir = (FontDirectoryPtr) fpe->private;
552 bitmap = &entry->u.bitmap;
553 strcpy (fileName, dir->directory);
554 strcat (fileName, bitmap->fileName);
555 ret = (*bitmap->renderer->GetInfoBitmap) (fpe, pFontInfo, entry, fileName);
560 _FontFileAddScalableNames(names, scaleNames, nameptr, zeroChars, vals, ranges,
563 FontNamesPtr scaleNames;
564 FontNamePtr *nameptr;
566 FontScalablePtr vals;
572 FontScalableRec zeroVals, tmpVals;
573 for (i = 0; i < scaleNames->nnames; i++)
575 char nameChars[MAXFONTNAMELEN];
578 FontParseXLFDName (scaleNames->names[i], &zeroVals,
579 FONT_XLFD_REPLACE_NONE);
581 if (FontFileCompleteXLFD (&tmpVals, &zeroVals))
585 strcpy (nameChars, scaleNames->names[i]);
586 if ((vals->values_supplied & PIXELSIZE_MASK) ||
587 !(vals->values_supplied & PIXELSIZE_WILDCARD) ||
590 tmpVals.values_supplied =
591 (tmpVals.values_supplied & ~PIXELSIZE_MASK) |
592 (vals->values_supplied & PIXELSIZE_MASK);
593 tmpVals.pixel_matrix[0] = vals->pixel_matrix[0];
594 tmpVals.pixel_matrix[1] = vals->pixel_matrix[1];
595 tmpVals.pixel_matrix[2] = vals->pixel_matrix[2];
596 tmpVals.pixel_matrix[3] = vals->pixel_matrix[3];
598 if ((vals->values_supplied & POINTSIZE_MASK) ||
599 !(vals->values_supplied & POINTSIZE_WILDCARD) ||
602 tmpVals.values_supplied =
603 (tmpVals.values_supplied & ~POINTSIZE_MASK) |
604 (vals->values_supplied & POINTSIZE_MASK);
605 tmpVals.point_matrix[0] = vals->point_matrix[0];
606 tmpVals.point_matrix[1] = vals->point_matrix[1];
607 tmpVals.point_matrix[2] = vals->point_matrix[2];
608 tmpVals.point_matrix[3] = vals->point_matrix[3];
610 if (vals->width <= 0)
616 tmpVals.ranges = ranges;
617 tmpVals.nranges = nranges;
618 FontParseXLFDName (nameChars, &tmpVals,
619 FONT_XLFD_REPLACE_VALUE);
620 /* If we're marking aliases with negative lengths, we
621 need to concoct a valid target name to follow it.
622 Otherwise we're done. */
623 if (scaleNames->length[i] >= 0)
625 (void) AddFontNamesName (names, nameChars,
627 /* If our original pattern matches the name from
628 the table and that name doesn't duplicate what
629 we just added, add the name from the table */
630 if (strcmp(nameChars, scaleNames->names[i]) &&
631 FontFileMatchName(scaleNames->names[i],
632 scaleNames->length[i],
637 (void) AddFontNamesName (names, scaleNames->names[i],
638 scaleNames->length[i]);
644 vals->ranges = ranges;
645 vals->nranges = nranges;
646 if (transfer_values_to_alias(zeroChars,
648 scaleNames->names[++i],
651 (void) AddFontNamesName (names, nameChars,
653 names->length[names->nnames - 1] =
654 -names->length[names->nnames - 1];
655 (void) AddFontNamesName (names, aliasName,
657 /* If our original pattern matches the name from
658 the table and that name doesn't duplicate what
659 we just added, add the name from the table */
660 if (strcmp(nameChars, scaleNames->names[i - 1]) &&
661 FontFileMatchName(scaleNames->names[i - 1],
662 -scaleNames->length[i - 1],
667 (void) AddFontNamesName (names,
668 scaleNames->names[i - 1],
669 -scaleNames->length[i - 1]);
670 names->length[names->nnames - 1] =
671 -names->length[names->nnames - 1];
672 (void) AddFontNamesName (names, aliasName,
683 _FontFileListFonts (client, fpe, pat, len, max, names, mark_aliases)
685 FontPathElementPtr fpe;
692 FontDirectoryPtr dir;
693 char lowerChars[MAXFONTNAMELEN], zeroChars[MAXFONTNAMELEN];
694 FontNameRec lowerName;
695 FontNameRec zeroName;
696 FontNamesPtr scaleNames;
697 FontScalableRec vals;
701 int result = BadFontName;
703 if (len >= MAXFONTNAMELEN)
705 dir = (FontDirectoryPtr) fpe->private;
706 CopyISOLatin1Lowered (lowerChars, pat, len);
707 lowerChars[len] = '\0';
708 lowerName.name = lowerChars;
709 lowerName.length = len;
710 lowerName.ndashes = FontFileCountDashes (lowerChars, len);
712 /* Match XLFD patterns */
714 strcpy (zeroChars, lowerChars);
715 if (lowerName.ndashes == 14 &&
716 FontParseXLFDName (zeroChars, &vals, FONT_XLFD_REPLACE_ZERO))
718 ranges = FontParseRanges(lowerChars, &nranges);
719 result = FontFileFindNamesInScalableDir (&dir->nonScalable,
720 &lowerName, max, names,
723 LIST_ALIASES_AND_TARGET_NAMES :
724 NORMAL_ALIAS_BEHAVIOR) |
725 IGNORE_SCALABLE_ALIASES,
727 zeroName.name = zeroChars;
728 zeroName.length = strlen (zeroChars);
729 zeroName.ndashes = lowerName.ndashes;
731 /* Look for scalable names and aliases, adding scaled instances of
732 them to the output */
734 /* Scalable names... */
735 scaleNames = MakeFontNamesRecord (0);
738 if (ranges) xfree(ranges);
741 FontFileFindNamesInScalableDir (&dir->scalable, &zeroName, max,
744 LIST_ALIASES_AND_TARGET_NAMES :
745 NORMAL_ALIAS_BEHAVIOR, (int *)0);
746 _FontFileAddScalableNames(names, scaleNames, &lowerName,
747 zeroChars, &vals, ranges, nranges,
749 FreeFontNames (scaleNames);
751 /* Scalable aliases... */
752 scaleNames = MakeFontNamesRecord (0);
755 if (ranges) xfree(ranges);
758 FontFileFindNamesInScalableDir (&dir->nonScalable, &zeroName,
759 max, scaleNames, &vals,
761 LIST_ALIASES_AND_TARGET_NAMES :
762 NORMAL_ALIAS_BEHAVIOR, (int *)0);
763 _FontFileAddScalableNames(names, scaleNames, &lowerName,
764 zeroChars, &vals, ranges, nranges,
766 FreeFontNames (scaleNames);
768 if (ranges) xfree(ranges);
772 result = FontFileFindNamesInScalableDir (&dir->nonScalable,
773 &lowerName, max, names,
776 LIST_ALIASES_AND_TARGET_NAMES :
777 NORMAL_ALIAS_BEHAVIOR,
779 if (result == Successful)
780 result = FontFileFindNamesInScalableDir (&dir->scalable,
781 &lowerName, max, names,
784 LIST_ALIASES_AND_TARGET_NAMES :
785 NORMAL_ALIAS_BEHAVIOR, (int *)0);
790 typedef struct _LFWIData {
793 } LFWIDataRec, *LFWIDataPtr;
795 FontFileListFonts (client, fpe, pat, len, max, names)
797 FontPathElementPtr fpe;
803 return _FontFileListFonts (client, fpe, pat, len, max, names, 0);
806 FontFileStartListFontsWithInfo(client, fpe, pat, len, max, privatep)
808 FontPathElementPtr fpe;
817 data = (LFWIDataPtr) xalloc (sizeof *data);
820 data->names = MakeFontNamesRecord (0);
826 ret = FontFileListFonts (client, fpe, pat, len, max, data->names);
827 if (ret != Successful)
829 FreeFontNames (data->names);
834 *privatep = (pointer) data;
840 FontFileListOneFontWithInfo (client, fpe, namep, namelenp, pFontInfo)
842 FontPathElementPtr fpe;
845 FontInfoPtr *pFontInfo;
847 FontDirectoryPtr dir;
848 char lowerName[MAXFONTNAMELEN];
849 char fileName[MAXFONTFILENAMELEN*2 + 1];
852 FontScalableRec vals;
853 FontScalableEntryPtr scalable;
854 FontScaledPtr scaled;
855 FontBitmapEntryPtr bitmap;
856 FontAliasEntryPtr alias;
859 int namelen = *namelenp;
862 if (namelen >= MAXFONTNAMELEN)
864 dir = (FontDirectoryPtr) fpe->private;
865 CopyISOLatin1Lowered (lowerName, name, namelen);
866 lowerName[namelen] = '\0';
867 tmpName.name = lowerName;
868 tmpName.length = namelen;
869 tmpName.ndashes = FontFileCountDashes (lowerName, namelen);
870 /* Match XLFD patterns */
871 if (tmpName.ndashes == 14 &&
872 FontParseXLFDName (lowerName, &vals, FONT_XLFD_REPLACE_ZERO))
874 tmpName.length = strlen (lowerName);
875 entry = FontFileFindNameInScalableDir (&dir->scalable, &tmpName, &vals);
876 noSpecificSize = FALSE; /* TRUE breaks XLFD enhancements */
877 if (entry && entry->type == FONT_ENTRY_SCALABLE &&
878 FontFileCompleteXLFD (&vals, &entry->u.scalable.extra->defaults))
880 scalable = &entry->u.scalable;
881 scaled = FontFileFindScaledInstance (entry, &vals, noSpecificSize);
883 * A scaled instance can occur one of two ways:
885 * Either the font has been scaled to this
886 * size already, in which case scaled->pFont
887 * will point at that font.
889 * Or a bitmap instance in this size exists,
890 * which is handled as if we got a pattern
891 * matching the bitmap font name.
897 *pFontInfo = &scaled->pFont->info;
900 else if (scaled->bitmap)
902 entry = scaled->bitmap;
903 bitmap = &entry->u.bitmap;
906 *pFontInfo = &bitmap->pFont->info;
911 ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry);
914 else /* "cannot" happen */
922 /* no special case yet */
923 ret = FontFileMatchBitmapSource (fpe, pFont, flags, entry, &vals, format, fmask, noSpecificSize);
924 if (ret != Successful)
927 char origName[MAXFONTNAMELEN];
930 CopyISOLatin1Lowered (origName, name, namelen);
931 origName[namelen] = '\0';
932 vals.xlfdName = origName;
933 vals.ranges = FontParseRanges(origName, &vals.nranges);
934 ranges = vals.ranges;
935 /* Make a new scaled instance */
936 strcpy (fileName, dir->directory);
937 strcat (fileName, scalable->fileName);
938 ret = (*scalable->renderer->GetInfoScalable)
939 (fpe, *pFontInfo, entry, &tmpName, fileName, &vals);
940 if (ranges) xfree(ranges);
943 if (ret == Successful) return ret;
945 CopyISOLatin1Lowered (lowerName, name, namelen);
946 tmpName.length = namelen;
948 /* Match non XLFD pattern */
949 if (entry = FontFileFindNameInDir (&dir->nonScalable, &tmpName))
951 switch (entry->type) {
952 case FONT_ENTRY_BITMAP:
953 bitmap = &entry->u.bitmap;
956 *pFontInfo = &bitmap->pFont->info;
961 ret = FontFileGetInfoBitmap (fpe, *pFontInfo, entry);
964 case FONT_ENTRY_ALIAS:
965 alias = &entry->u.alias;
966 *(char **)pFontInfo = name;
967 *namelenp = strlen (*namep = alias->resolved);
972 /* no LFWI for this yet */
975 /* Make a new scaled instance */
976 strcpy (fileName, dir->directory);
977 strcat (fileName, scalable->fileName);
978 ret = (*scalable->renderer->GetInfoScalable)
979 (fpe, *pFontInfo, entry, tmpName, fileName, &bc->vals);
993 FontFileListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo,
996 FontPathElementPtr fpe;
999 FontInfoPtr *pFontInfo;
1003 LFWIDataPtr data = (LFWIDataPtr) private;
1008 if (data->current == data->names->nnames)
1010 FreeFontNames (data->names);
1014 name = data->names->names[data->current];
1015 namelen = data->names->length[data->current];
1016 ret = FontFileListOneFontWithInfo (client, fpe, &name, &namelen, pFontInfo);
1017 if (ret == BadFontName)
1020 *namelenp = namelen;
1022 *numFonts = data->names->nnames - data->current;
1027 FontFileStartListFontsAndAliases(client, fpe, pat, len, max, privatep)
1029 FontPathElementPtr fpe;
1038 data = (LFWIDataPtr) xalloc (sizeof *data);
1041 data->names = MakeFontNamesRecord (0);
1047 ret = _FontFileListFonts (client, fpe, pat, len, max, data->names, 1);
1048 if (ret != Successful)
1050 FreeFontNames (data->names);
1055 *privatep = (pointer) data;
1060 FontFileListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp,
1061 resolvedlenp, private)
1063 FontPathElementPtr fpe;
1070 LFWIDataPtr data = (LFWIDataPtr) private;
1075 if (data->current == data->names->nnames)
1077 FreeFontNames (data->names);
1081 name = data->names->names[data->current];
1082 namelen = data->names->length[data->current];
1084 /* If this is a real font name... */
1088 *namelenp = namelen;
1091 /* Else if an alias */
1094 /* Tell the caller that this is an alias... let him resolve it to
1095 see if it's valid */
1097 *namelenp = -namelen;
1098 *resolvedp = data->names->names[++data->current];
1099 *resolvedlenp = data->names->length[data->current];
1100 ret = FontNameAlias;
1108 extern void FontFileEmptyBitmapSource();
1109 typedef int (*IntFunc) ();
1110 static int font_file_type;
1112 FontFileRegisterLocalFpeFunctions ()
1114 font_file_type = RegisterFPEFunctions(FontFileNameCheck,
1121 FontFileStartListFontsWithInfo,
1122 FontFileListNextFontWithInfo,
1126 FontFileStartListFontsAndAliases,
1127 FontFileListNextFontOrAlias,
1128 FontFileEmptyBitmapSource);