2 * Adobe Font Metric (AFM) file parsing
3 * See http://partners.adobe.com/asn/developer/PDFS/TN/5004.AFM_Spec.pdf
5 * Copyright 1998 Huw D M Davies
10 #include <stdlib.h> /* qsort() & bsearch() */
13 #include <limits.h> /* INT_MIN */
14 #include <float.h> /* FLT_MAX */
15 #include "winnt.h" /* HEAP_ZERO_MEMORY */
18 #include "debugtools.h"
21 DEFAULT_DEBUG_CHANNEL(psdrv);
24 /* ptr to fonts for which we have afm files */
25 FONTFAMILY *PSDRV_AFMFontList = NULL;
27 /* qsort/bsearch callback functions */
28 typedef int (*compar_callback_fn) (const void *, const void *);
30 /*******************************************************************************
33 * Checks whether Unicode value is part of Microsoft code page 1252
36 static const INT ansiChars[21] =
38 0x0152, 0x0153, 0x0160, 0x0161, 0x0178, 0x017d, 0x017e, 0x0192, 0x02c6,
39 0x02c9, 0x02dc, 0x03bc, 0x2013, 0x2014, 0x2026, 0x2030, 0x2039, 0x203a,
40 0x20ac, 0x2122, 0x2219
43 static int cmpUV(const INT *a, const INT *b)
48 inline static BOOL IsWinANSI(INT uv)
50 if ((0x0020 <= uv && uv <= 0x007e) || (0x00a0 <= uv && uv <= 0x00ff) ||
51 (0x2018 <= uv && uv <= 0x201a) || (0x201c <= uv && uv <= 0x201e) ||
52 (0x2020 <= uv && uv <= 2022))
55 if (bsearch(&uv, ansiChars, 21, sizeof(INT),
56 (compar_callback_fn)cmpUV) != NULL)
62 /*******************************************************************************
65 * Check an AFMMETRICS structure to make sure all elements have been properly
66 * filled in. (Don't check UV or L.)
69 static const AFMMETRICS badMetrics =
75 { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX }, /* B */
79 inline static BOOL CheckMetrics(const AFMMETRICS *metrics)
81 if ( metrics->C == badMetrics.C ||
82 metrics->WX == badMetrics.WX ||
83 metrics->N == badMetrics.N ||
84 metrics->B.llx == badMetrics.B.llx ||
85 metrics->B.lly == badMetrics.B.lly ||
86 metrics->B.urx == badMetrics.B.urx ||
87 metrics->B.ury == badMetrics.B.ury )
93 /*******************************************************************************
96 * Free an AFM structure and any subsidiary objects that have been allocated.
97 * AFM must have been allocated with HEAP_ZERO_MEMORY.
100 static void FreeAFM(AFM *afm)
102 if (afm->FontName != NULL)
103 HeapFree(PSDRV_Heap, 0, afm->FontName);
104 if (afm->FullName != NULL)
105 HeapFree(PSDRV_Heap, 0, afm->FullName);
106 if (afm->FamilyName != NULL)
107 HeapFree(PSDRV_Heap, 0, afm->FamilyName);
108 if (afm->EncodingScheme != NULL)
109 HeapFree(PSDRV_Heap, 0, afm->EncodingScheme);
110 if (afm->Metrics != NULL)
111 HeapFree(PSDRV_Heap, 0, afm->Metrics);
113 HeapFree(PSDRV_Heap, 0, afm);
116 /***********************************************************
118 * PSDRV_AFMGetCharMetrics
120 * Parses CharMetric section of AFM file.
122 * Actually only collects the widths of numbered chars and puts then in
125 static BOOL PSDRV_AFMGetCharMetrics(AFM *afm, FILE *fp)
127 unsigned char line[256], valbuf[256];
128 unsigned char *cp, *item, *value, *curpos, *endpos;
132 afm->Metrics = metric = HeapAlloc( PSDRV_Heap, 0,
133 afm->NumofMetrics * sizeof(AFMMETRICS) );
137 for(i = 0; i < afm->NumofMetrics; i++, metric++) {
139 *metric = badMetrics;
142 if(!fgets(line, sizeof(line), fp)) {
143 ERR("Unexpected EOF\n");
144 HeapFree(PSDRV_Heap, 0, afm->Metrics);
148 cp = line + strlen(line);
152 } while(cp >= line && isspace(*cp));
158 while(isspace(*item))
160 value = strpbrk(item, " \t");
162 ERR("No whitespace found.\n");
163 HeapFree(PSDRV_Heap, 0, afm->Metrics);
167 while(isspace(*value))
169 cp = endpos = strchr(value, ';');
171 ERR("missing ;, failed. [%s]\n", line);
172 HeapFree(PSDRV_Heap, 0, afm->Metrics);
176 while(isspace(*--cp))
178 memcpy(valbuf, value, cp - value + 1);
179 valbuf[cp - value + 1] = '\0';
182 if(!strncmp(item, "C ", 2)) {
183 value = strchr(item, ' ');
184 sscanf(value, " %d", &metric->C);
186 } else if(!strncmp(item, "CH ", 3)) {
187 value = strrchr(item, ' ');
188 sscanf(value, " %x", &metric->C);
191 else if(!strncmp("WX ", item, 3) || !strncmp("W0X ", item, 4)) {
192 sscanf(value, "%f", &metric->WX);
193 if(metric->C >= 0 && metric->C <= 0xff)
194 afm->CharWidths[metric->C] = metric->WX;
197 else if(!strncmp("N ", item, 2)) {
198 metric->N = PSDRV_GlyphName(value);
201 else if(!strncmp("B ", item, 2)) {
202 sscanf(value, "%f%f%f%f", &metric->B.llx, &metric->B.lly,
203 &metric->B.urx, &metric->B.ury);
205 /* Store height of Aring to use as lfHeight */
206 if(metric->N && !strncmp(metric->N->sz, "Aring", 5))
207 afm->FullAscender = metric->B.ury;
210 /* Ligatures go here... */
215 if (CheckMetrics(metric) == FALSE) {
216 ERR("Error parsing character metrics\n");
217 HeapFree(PSDRV_Heap, 0, afm->Metrics);
222 TRACE("Metrics for '%s' WX = %f B = %f,%f - %f,%f\n",
223 metric->N->sz, metric->WX, metric->B.llx, metric->B.lly,
224 metric->B.urx, metric->B.ury);
230 /*******************************************************************************
233 * Builds a custom encoding vector if necessary. Leaves vector in the same
234 * order as the afm->Metrics array; see SortFontMetrics().
237 static BOOL BuildEncoding(AFM *afm)
243 if (strcmp(afm->EncodingScheme, "FontSpecific") != 0)
245 afm->Encoding = &PSDRV_AdobeGlyphList;
249 uv = HeapAlloc(PSDRV_Heap, 0, sizeof(UNICODEVECTOR) +
250 afm->NumofMetrics * sizeof(UNICODEGLYPH));
255 ug = (UNICODEGLYPH *)(uv + 1);
257 uv->size = afm->NumofMetrics;
259 for (i = 0; i < afm->NumofMetrics; ++i)
261 ug[i].name = afm->Metrics[i].N;
263 if (afm->Metrics[i].C < 0) /* unencoded glyph */
265 WARN("Glyph '%s' in font '%s' has no encoding\n", ug[i].name->sz,
271 ug[i].UV = afm->Metrics[i].C | 0xf000; /* private use area? */
279 /***********************************************************
283 * Fills out an AFM structure and associated substructures (see psdrv.h)
284 * for a given AFM file. All memory is allocated from the process heap.
285 * Returns a ptr to the AFM structure or NULL on error.
287 * This is not complete (we don't handle kerning yet) and not efficient
290 static AFM *PSDRV_AFMParse(char const *file)
293 unsigned char buf[256];
294 unsigned char *value;
300 TRACE("parsing '%s'\n", file);
302 if((fp = fopen(file, "r")) == NULL) {
303 MESSAGE("Can't open AFM file '%s'. Please check wine.conf .\n", file);
307 afm = HeapAlloc(PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(AFM));
314 while ( ( c = fgetc ( fp ) ) != EOF ) {
316 if ( *cp == '\r' || *cp == '\n' || cp - buf == sizeof(buf)-2 ) {
326 cp = buf + strlen(buf);
330 } while(cp > buf && isspace(*cp));
334 if ( afmfile == 0 && strncmp ( buf, "StartFontMetrics", 16 ) )
338 value = strchr(buf, ' ');
340 while(isspace(*value))
343 if(!strncmp("FontName", buf, 8)) {
344 afm->FontName = HEAP_strdupA(PSDRV_Heap, 0, value);
345 if (afm->FontName == NULL) {
353 if(!strncmp("FullName", buf, 8)) {
354 afm->FullName = HEAP_strdupA(PSDRV_Heap, 0, value);
355 if (afm->FullName == NULL) {
363 if(!strncmp("FamilyName", buf, 10)) {
364 afm->FamilyName = HEAP_strdupA(PSDRV_Heap, 0, value);
365 if (afm->FamilyName == NULL) {
373 if(!strncmp("Weight", buf, 6)) {
374 if(!strncmp("Roman", value, 5) || !strncmp("Medium", value, 6)
375 || !strncmp("Book", value, 4) || !strncmp("Regular", value, 7)
376 || !strncmp("Normal", value, 6))
377 afm->Weight = FW_NORMAL;
378 else if(!strncmp("Demi", value, 4))
379 afm->Weight = FW_DEMIBOLD;
380 else if(!strncmp("Bold", value, 4))
381 afm->Weight = FW_BOLD;
382 else if(!strncmp("Light", value, 5))
383 afm->Weight = FW_LIGHT;
384 else if(!strncmp("Black", value, 5))
385 afm->Weight = FW_BLACK;
387 WARN("%s specifies unknown Weight '%s'; treating as Roman\n",
389 afm->Weight = FW_NORMAL;
394 if(!strncmp("ItalicAngle", buf, 11)) {
395 sscanf(value, "%f", &(afm->ItalicAngle));
399 if(!strncmp("IsFixedPitch", buf, 12)) {
400 if(!strncasecmp("false", value, 5))
401 afm->IsFixedPitch = FALSE;
403 afm->IsFixedPitch = TRUE;
407 if(!strncmp("FontBBox", buf, 8)) {
408 sscanf(value, "%f %f %f %f", &(afm->FontBBox.llx),
409 &(afm->FontBBox.lly), &(afm->FontBBox.urx),
410 &(afm->FontBBox.ury) );
414 if(!strncmp("UnderlinePosition", buf, 17)) {
415 sscanf(value, "%f", &(afm->UnderlinePosition) );
419 if(!strncmp("UnderlineThickness", buf, 18)) {
420 sscanf(value, "%f", &(afm->UnderlineThickness) );
424 if(!strncmp("CapHeight", buf, 9)) {
425 sscanf(value, "%f", &(afm->CapHeight) );
429 if(!strncmp("XHeight", buf, 7)) {
430 sscanf(value, "%f", &(afm->XHeight) );
434 if(!strncmp("Ascender", buf, 8)) {
435 sscanf(value, "%f", &(afm->Ascender) );
439 if(!strncmp("Descender", buf, 9)) {
440 sscanf(value, "%f", &(afm->Descender) );
444 if(!strncmp("StartCharMetrics", buf, 16)) {
445 sscanf(value, "%d", &(afm->NumofMetrics) );
446 if (PSDRV_AFMGetCharMetrics(afm, fp) == FALSE) {
454 if(!strncmp("EncodingScheme", buf, 14)) {
455 afm->EncodingScheme = HEAP_strdupA(PSDRV_Heap, 0, value);
456 if (afm->EncodingScheme == NULL) {
468 HeapFree ( PSDRV_Heap, 0, afm );
472 if(afm->FontName == NULL) {
473 WARN("%s contains no FontName.\n", file);
474 afm->FontName = HEAP_strdupA(PSDRV_Heap, 0, "nofont");
475 if (afm->FontName == NULL) {
481 if(afm->FullName == NULL)
482 afm->FullName = HEAP_strdupA(PSDRV_Heap, 0, afm->FontName);
483 if(afm->FamilyName == NULL)
484 afm->FamilyName = HEAP_strdupA(PSDRV_Heap, 0, afm->FontName);
485 if (afm->FullName == NULL || afm->FamilyName == NULL) {
490 if(afm->Ascender == 0.0)
491 afm->Ascender = afm->FontBBox.ury;
492 if(afm->Descender == 0.0)
493 afm->Descender = afm->FontBBox.lly;
494 if(afm->FullAscender == 0.0)
495 afm->FullAscender = afm->Ascender;
497 afm->Weight = FW_NORMAL;
499 if (BuildEncoding(afm) == FALSE)
508 /***********************************************************
512 * Frees the family and afmlistentry structures in list head
514 void PSDRV_FreeAFMList( FONTFAMILY *head )
516 AFMLISTENTRY *afmle, *nexta;
517 FONTFAMILY *family, *nextf;
519 for(nextf = family = head; nextf; family = nextf) {
520 for(nexta = afmle = family->afmlist; nexta; afmle = nexta) {
522 HeapFree( PSDRV_Heap, 0, afmle );
524 nextf = family->next;
525 HeapFree( PSDRV_Heap, 0, family );
531 /***********************************************************
533 * PSDRV_FindAFMinList
534 * Returns ptr to an AFM if name (which is a PS font name) exists in list
537 AFM *PSDRV_FindAFMinList(FONTFAMILY *head, char *name)
542 for(family = head; family; family = family->next) {
543 for(afmle = family->afmlist; afmle; afmle = afmle->next) {
544 if(!strcmp(afmle->afm->FontName, name))
551 /***********************************************************
555 * Adds an afm to the list whose head is pointed to by head. Creates new
556 * family node if necessary and always creates a new AFMLISTENTRY.
558 BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, AFM *afm)
560 FONTFAMILY *family = *head;
561 FONTFAMILY **insert = head;
562 AFMLISTENTRY *tmpafmle, *newafmle;
564 newafmle = HeapAlloc(PSDRV_Heap, HEAP_ZERO_MEMORY,
566 if (newafmle == NULL)
572 if(!strcmp(family->FamilyName, afm->FamilyName))
574 insert = &(family->next);
575 family = family->next;
579 family = HeapAlloc(PSDRV_Heap, HEAP_ZERO_MEMORY,
581 if (family == NULL) {
582 HeapFree(PSDRV_Heap, 0, newafmle);
586 family->FamilyName = HEAP_strdupA(PSDRV_Heap, 0,
588 if (family->FamilyName == NULL) {
589 HeapFree(PSDRV_Heap, 0, family);
590 HeapFree(PSDRV_Heap, 0, newafmle);
593 family->afmlist = newafmle;
597 tmpafmle = family->afmlist;
599 if (!strcmp(tmpafmle->afm->FontName, afm->FontName)) {
600 WARN("Ignoring duplicate FontName '%s'\n", afm->FontName);
601 HeapFree(PSDRV_Heap, 0, newafmle);
602 return TRUE; /* not a fatal error */
604 tmpafmle = tmpafmle->next;
608 tmpafmle = family->afmlist;
609 while(tmpafmle->next)
610 tmpafmle = tmpafmle->next;
612 tmpafmle->next = newafmle;
617 /**********************************************************
619 * PSDRV_ReencodeCharWidths
621 * Re map the CharWidths field of the afm to correspond to an ANSI encoding
624 static void PSDRV_ReencodeCharWidths(AFM *afm)
629 for(i = 0; i < 256; i++) {
632 if(PSDRV_ANSIVector[i] == NULL) {
633 afm->CharWidths[i] = 0.0;
636 for (j = 0, metric = afm->Metrics; j < afm->NumofMetrics; j++, metric++) {
637 if(metric->N && !strcmp(metric->N->sz, PSDRV_ANSIVector[i])) {
638 afm->CharWidths[i] = metric->WX;
642 if(j == afm->NumofMetrics) {
643 WARN("Couldn't find glyph '%s' in font '%s'\n",
644 PSDRV_ANSIVector[i], afm->FontName);
645 afm->CharWidths[i] = 0.0;
652 /***********************************************************
657 static void PSDRV_DumpFontList(void)
662 for(family = PSDRV_AFMFontList; family; family = family->next) {
663 TRACE("Family '%s'\n", family->FamilyName);
664 for(afmle = family->afmlist; afmle; afmle = afmle->next)
668 TRACE("\tFontName '%s' (%i glyphs) - '%s' encoding:\n",
669 afmle->afm->FontName, afmle->afm->NumofMetrics,
670 afmle->afm->EncodingScheme);
672 for (i = 0; i < afmle->afm->NumofMetrics; ++i)
674 TRACE("\t\tU+%.4lX; C %i; N '%s'\n", afmle->afm->Metrics[i].UV,
675 afmle->afm->Metrics[i].C, afmle->afm->Metrics[i].N->sz);
682 /*******************************************************************************
685 * Initializes the UV member of each glyph's AFMMETRICS and sorts each font's
686 * Metrics by Unicode Value. If the font has a standard encoding (i.e. it is
687 * using the Adobe Glyph List encoding vector), look up each glyph's Unicode
688 * Value based on it's glyph name. If the font has a font-specific encoding,
689 * map the default PostScript encodings into the Unicode private use area.
692 static int UnicodeGlyphByNameIndex(const UNICODEGLYPH *a, const UNICODEGLYPH *b)
694 return a->name->index - b->name->index;
697 static int UnicodeGlyphByUV(const UNICODEGLYPH *a, const UNICODEGLYPH *b)
699 return a->UV - b->UV;
702 static int AFMMetricsByUV(const AFMMETRICS *a, const AFMMETRICS *b)
704 return a->UV - b->UV;
707 static BOOL SortFontMetrics()
709 UNICODEGLYPH *aglCopy = NULL;
710 FONTFAMILY *family = PSDRV_AFMFontList;
712 while (family != NULL)
714 AFMLISTENTRY *afmle = family->afmlist;
716 while (afmle != NULL)
718 AFM *afm = afmle->afm; /* should always be valid */
721 if (afm->Encoding == &PSDRV_AdobeGlyphList)
723 if (aglCopy == NULL) /* do this once, if necessary */
725 aglCopy = HeapAlloc(PSDRV_Heap, 0,
726 PSDRV_AdobeGlyphList.size * sizeof(UNICODEGLYPH));
730 memcpy(aglCopy, PSDRV_AdobeGlyphList.glyphs,
731 PSDRV_AdobeGlyphList.size * sizeof(UNICODEGLYPH));
733 qsort(aglCopy, PSDRV_AdobeGlyphList.size,
734 sizeof(UNICODEGLYPH),
735 (compar_callback_fn)UnicodeGlyphByNameIndex);
738 for (i = 0; i < afm->NumofMetrics; ++i)
740 UNICODEGLYPH ug, *pug;
742 ug.name = afm->Metrics[i].N;
745 pug = bsearch(&ug, aglCopy, PSDRV_AdobeGlyphList.size,
746 sizeof(UNICODEGLYPH),
747 (compar_callback_fn)UnicodeGlyphByNameIndex);
750 WARN("Glyph '%s' in font '%s' does not have a UV\n",
751 ug.name->sz, afm->FullName);
752 afm->Metrics[i].UV = -1;
756 afm->Metrics[i].UV = pug->UV;
760 else /* FontSpecific encoding or TrueType font */
762 for (i = 0; i < afm->NumofMetrics; ++i)
763 afm->Metrics[i].UV = afm->Encoding->glyphs[i].UV;
765 /* typecast avoids compiler warning */
766 qsort((void *)(afm->Encoding->glyphs), afm->Encoding->size,
767 sizeof(UNICODEGLYPH),
768 (compar_callback_fn)UnicodeGlyphByUV);
770 for (i = 0; i < afm->Encoding->size; ++i)
771 if (afm->Encoding->glyphs[i].UV >= 0)
774 afm->Encoding->size -= i; /* Ignore unencoded glyphs */
775 afm->Encoding->glyphs += i; /* from now on */
778 qsort(afm->Metrics, afm->NumofMetrics, sizeof(AFMMETRICS),
779 (compar_callback_fn)AFMMetricsByUV);
781 for (i = 0; i < afm->NumofMetrics; ++i)
782 if (afm->Metrics[i].UV >= 0)
785 afm->NumofMetrics -= i; /* Ignore unencoded glyphs here too */
791 family = family->next;
795 HeapFree(PSDRV_Heap, 0, aglCopy);
800 /*******************************************************************************
803 * Calculates several Windows-specific font metrics for each font. Relies on
804 * the fact that AFMs are allocated with HEAP_ZERO_MEMORY to distinguish
805 * TrueType fonts (when implemented), which already have these filled in.
808 static VOID CalcWindowsMetrics()
810 FONTFAMILY *family = PSDRV_AFMFontList;
812 while (family != NULL)
814 AFMLISTENTRY *afmle = family->afmlist;
816 while (afmle != NULL)
819 AFM *afm = afmle->afm; /* should always be valid */
822 if (afm->WinMetrics.usUnitsPerEm != 0)
823 continue; /* TrueType font */
825 wm.usUnitsPerEm = 1000; /* for PostScript fonts */
826 wm.sTypoAscender = (SHORT)(afm->Ascender + 0.5);
827 wm.sTypoDescender = (SHORT)(afm->Descender + 0.5);
829 wm.sTypoLineGap = 1200 - (wm.sTypoAscender - wm.sTypoDescender);
830 if (wm.sTypoLineGap < 0)
836 for (i = 0; i < afm->NumofMetrics; ++i)
838 if (IsWinANSI(afm->Metrics[i].UV) == FALSE)
841 if (afm->Metrics[i].B.ury > 0)
843 USHORT ascent = (USHORT)(afm->Metrics[i].B.ury + 0.5);
845 if (ascent > wm.usWinAscent)
846 wm.usWinAscent = ascent;
849 if (afm->Metrics[i].B.lly < 0)
851 USHORT descent = (USHORT)(-(afm->Metrics[i].B.lly) + 0.5);
853 if (descent > wm.usWinDescent)
854 wm.usWinDescent = descent;
858 if (wm.usWinAscent == 0 && afm->FontBBox.ury > 0)
859 wm.usWinAscent = (USHORT)(afm->FontBBox.ury + 0.5);
861 if (wm.usWinDescent == 0 && afm->FontBBox.lly < 0)
862 wm.usWinDescent = (USHORT)(-(afm->FontBBox.lly) + 0.5);
864 wm.sAscender = wm.usWinAscent;
865 wm.sDescender = -(wm.usWinDescent);
867 wm.sLineGap = 1150 - (wm.sAscender - wm.sDescender);
871 TRACE("Windows metrics for '%s':\n", afm->FullName);
872 TRACE("\tsAscender = %i\n", wm.sAscender);
873 TRACE("\tsDescender = %i\n", wm.sDescender);
874 TRACE("\tsLineGap = %i\n", wm.sLineGap);
875 TRACE("\tusUnitsPerEm = %u\n", wm.usUnitsPerEm);
876 TRACE("\tsTypoAscender = %i\n", wm.sTypoAscender);
877 TRACE("\tsTypoDescender = %i\n", wm.sTypoDescender);
878 TRACE("\tsTypoLineGap = %i\n", wm.sTypoLineGap);
879 TRACE("\tusWinAscent = %u\n", wm.usWinAscent);
880 TRACE("\tusWinDescent = %u\n", wm.usWinDescent);
882 afm->WinMetrics = wm;
884 /* See afm2c.c and mkagl.c for an explanation of this */
885 /* PSDRV_AFM2C(afm); */
890 family = family ->next;
895 /*******************************************************************************
900 static BOOL AddBuiltinAFMs()
904 while (PSDRV_BuiltinAFMs[i] != NULL)
906 if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, PSDRV_BuiltinAFMs[i])
916 /***********************************************************
918 * PSDRV_GetFontMetrics
920 * Parses all afm files listed in [afmfiles] and [afmdirs] of wine.conf
922 * If this function fails, PSDRV_Init will destroy PSDRV_Heap, so don't worry
923 * about freeing all the memory that's been allocated.
926 static BOOL PSDRV_ReadAFMDir(const char* afmdir) {
930 dir = opendir(afmdir);
933 while ((dent=readdir(dir))) {
934 if (strstr(dent->d_name,".afm")) {
937 afmfn=(char*)HeapAlloc(PSDRV_Heap,0,
938 strlen(afmdir)+strlen(dent->d_name)+2);
943 strcpy(afmfn,afmdir);
945 strcat(afmfn,dent->d_name);
946 TRACE("loading AFM %s\n",afmfn);
947 afm = PSDRV_AFMParse(afmfn);
949 if(afm->EncodingScheme &&
950 !strcmp(afm->EncodingScheme,"AdobeStandardEncoding")) {
951 PSDRV_ReencodeCharWidths(afm);
953 if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, afm) == FALSE) {
960 WARN("Error parsing %s\n", afmfn);
962 HeapFree(PSDRV_Heap,0,afmfn);
968 WARN("Error opening %s\n", afmdir);
974 BOOL PSDRV_GetFontMetrics(void)
980 if (PSDRV_GlyphListInit() != 0)
983 while (PROFILE_EnumWineIniString( "afmfiles", idx++, key, sizeof(key),
984 value, sizeof(value)))
986 AFM* afm = PSDRV_AFMParse(value);
989 if(afm->EncodingScheme &&
990 !strcmp(afm->EncodingScheme, "AdobeStandardEncoding")) {
991 PSDRV_ReencodeCharWidths(afm);
993 if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, afm) == FALSE) {
998 WARN("Error parsing %s\n", value);
1002 for (idx = 0; PROFILE_EnumWineIniString ("afmdirs", idx, key, sizeof (key),
1003 value, sizeof (value)); ++idx)
1004 if (PSDRV_ReadAFMDir (value) == FALSE)
1007 PSDRV_IndexGlyphList(); /* So SortFontMetrics will work */
1008 if (SortFontMetrics() == FALSE)
1010 CalcWindowsMetrics();
1011 if (AddBuiltinAFMs() == FALSE)
1014 #ifdef HAVE_FREETYPE
1015 if (PSDRV_GetTrueTypeMetrics() == FALSE)
1017 PSDRV_IndexGlyphList();
1020 PSDRV_DumpFontList();