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
12 #include <stdlib.h> /* qsort() & bsearch() */
15 #include <limits.h> /* INT_MIN */
17 # include <float.h> /* FLT_MAX */
19 #include "winnt.h" /* HEAP_ZERO_MEMORY */
22 #include "debugtools.h"
25 DEFAULT_DEBUG_CHANNEL(psdrv);
28 /* ptr to fonts for which we have afm files */
29 FONTFAMILY *PSDRV_AFMFontList = NULL;
31 /* qsort/bsearch callback functions */
32 typedef int (*compar_callback_fn) (const void *, const void *);
34 /*******************************************************************************
37 * Checks whether Unicode value is part of Microsoft code page 1252
40 static const INT ansiChars[21] =
42 0x0152, 0x0153, 0x0160, 0x0161, 0x0178, 0x017d, 0x017e, 0x0192, 0x02c6,
43 0x02c9, 0x02dc, 0x03bc, 0x2013, 0x2014, 0x2026, 0x2030, 0x2039, 0x203a,
44 0x20ac, 0x2122, 0x2219
47 static int cmpUV(const INT *a, const INT *b)
52 inline static BOOL IsWinANSI(INT uv)
54 if ((0x0020 <= uv && uv <= 0x007e) || (0x00a0 <= uv && uv <= 0x00ff) ||
55 (0x2018 <= uv && uv <= 0x201a) || (0x201c <= uv && uv <= 0x201e) ||
56 (0x2020 <= uv && uv <= 2022))
59 if (bsearch(&uv, ansiChars, 21, sizeof(INT),
60 (compar_callback_fn)cmpUV) != NULL)
66 /*******************************************************************************
69 * Check an AFMMETRICS structure to make sure all elements have been properly
70 * filled in. (Don't check UV or L.)
73 static const AFMMETRICS badMetrics =
79 { FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX }, /* B */
83 inline static BOOL CheckMetrics(const AFMMETRICS *metrics)
85 if ( metrics->C == badMetrics.C ||
86 metrics->WX == badMetrics.WX ||
87 metrics->N == badMetrics.N ||
88 metrics->B.llx == badMetrics.B.llx ||
89 metrics->B.lly == badMetrics.B.lly ||
90 metrics->B.urx == badMetrics.B.urx ||
91 metrics->B.ury == badMetrics.B.ury )
97 /*******************************************************************************
100 * Free an AFM structure and any subsidiary objects that have been allocated.
101 * AFM must have been allocated with HEAP_ZERO_MEMORY.
104 static void FreeAFM(AFM *afm)
106 if (afm->FontName != NULL)
107 HeapFree(PSDRV_Heap, 0, afm->FontName);
108 if (afm->FullName != NULL)
109 HeapFree(PSDRV_Heap, 0, afm->FullName);
110 if (afm->FamilyName != NULL)
111 HeapFree(PSDRV_Heap, 0, afm->FamilyName);
112 if (afm->EncodingScheme != NULL)
113 HeapFree(PSDRV_Heap, 0, afm->EncodingScheme);
114 if (afm->Metrics != NULL)
115 HeapFree(PSDRV_Heap, 0, afm->Metrics);
117 HeapFree(PSDRV_Heap, 0, afm);
120 /***********************************************************
122 * PSDRV_AFMGetCharMetrics
124 * Parses CharMetric section of AFM file.
126 * Actually only collects the widths of numbered chars and puts then in
129 static BOOL PSDRV_AFMGetCharMetrics(AFM *afm, FILE *fp)
131 unsigned char line[256], valbuf[256];
132 unsigned char *cp, *item, *value, *curpos, *endpos;
136 afm->Metrics = metric = HeapAlloc( PSDRV_Heap, 0,
137 afm->NumofMetrics * sizeof(AFMMETRICS) );
141 for(i = 0; i < afm->NumofMetrics; i++, metric++) {
143 *metric = badMetrics;
146 if(!fgets(line, sizeof(line), fp)) {
147 ERR("Unexpected EOF\n");
148 HeapFree(PSDRV_Heap, 0, afm->Metrics);
152 cp = line + strlen(line);
156 } while(cp >= line && isspace(*cp));
162 while(isspace(*item))
164 value = strpbrk(item, " \t");
166 ERR("No whitespace found.\n");
167 HeapFree(PSDRV_Heap, 0, afm->Metrics);
171 while(isspace(*value))
173 cp = endpos = strchr(value, ';');
175 ERR("missing ;, failed. [%s]\n", line);
176 HeapFree(PSDRV_Heap, 0, afm->Metrics);
180 while(isspace(*--cp))
182 memcpy(valbuf, value, cp - value + 1);
183 valbuf[cp - value + 1] = '\0';
186 if(!strncmp(item, "C ", 2)) {
187 value = strchr(item, ' ');
188 sscanf(value, " %d", &metric->C);
190 } else if(!strncmp(item, "CH ", 3)) {
191 value = strrchr(item, ' ');
192 sscanf(value, " %x", &metric->C);
195 else if(!strncmp("WX ", item, 3) || !strncmp("W0X ", item, 4)) {
196 sscanf(value, "%f", &metric->WX);
197 if(metric->C >= 0 && metric->C <= 0xff)
198 afm->CharWidths[metric->C] = metric->WX;
201 else if(!strncmp("N ", item, 2)) {
202 metric->N = PSDRV_GlyphName(value);
205 else if(!strncmp("B ", item, 2)) {
206 sscanf(value, "%f%f%f%f", &metric->B.llx, &metric->B.lly,
207 &metric->B.urx, &metric->B.ury);
209 /* Store height of Aring to use as lfHeight */
210 if(metric->N && !strncmp(metric->N->sz, "Aring", 5))
211 afm->FullAscender = metric->B.ury;
214 /* Ligatures go here... */
219 if (CheckMetrics(metric) == FALSE) {
220 ERR("Error parsing character metrics\n");
221 HeapFree(PSDRV_Heap, 0, afm->Metrics);
226 TRACE("Metrics for '%s' WX = %f B = %f,%f - %f,%f\n",
227 metric->N->sz, metric->WX, metric->B.llx, metric->B.lly,
228 metric->B.urx, metric->B.ury);
234 /*******************************************************************************
237 * Builds a custom encoding vector if necessary. Leaves vector in the same
238 * order as the afm->Metrics array; see SortFontMetrics().
241 static BOOL BuildEncoding(AFM *afm)
247 if (strcmp(afm->EncodingScheme, "FontSpecific") != 0)
249 afm->Encoding = &PSDRV_AdobeGlyphList;
253 uv = HeapAlloc(PSDRV_Heap, 0, sizeof(UNICODEVECTOR) +
254 afm->NumofMetrics * sizeof(UNICODEGLYPH));
259 ug = (UNICODEGLYPH *)(uv + 1);
261 uv->size = afm->NumofMetrics;
263 for (i = 0; i < afm->NumofMetrics; ++i)
265 ug[i].name = afm->Metrics[i].N;
267 if (afm->Metrics[i].C < 0) /* unencoded glyph */
269 WARN("Glyph '%s' in font '%s' has no encoding\n", ug[i].name->sz,
275 ug[i].UV = afm->Metrics[i].C | 0xf000; /* private use area? */
283 /***********************************************************
287 * Fills out an AFM structure and associated substructures (see psdrv.h)
288 * for a given AFM file. All memory is allocated from the process heap.
289 * Returns a ptr to the AFM structure or NULL on error.
291 * This is not complete (we don't handle kerning yet) and not efficient
294 static AFM *PSDRV_AFMParse(char const *file)
297 unsigned char buf[256];
298 unsigned char *value;
304 TRACE("parsing '%s'\n", file);
306 if((fp = fopen(file, "r")) == NULL) {
307 MESSAGE("Can't open AFM file '%s'. Please check wine.conf .\n", file);
311 afm = HeapAlloc(PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(AFM));
318 while ( ( c = fgetc ( fp ) ) != EOF ) {
320 if ( *cp == '\r' || *cp == '\n' || cp - buf == sizeof(buf)-2 ) {
330 cp = buf + strlen(buf);
334 } while(cp > buf && isspace(*cp));
338 if ( afmfile == 0 && strncmp ( buf, "StartFontMetrics", 16 ) )
342 value = strchr(buf, ' ');
344 while(isspace(*value))
347 if(!strncmp("FontName", buf, 8)) {
348 afm->FontName = HEAP_strdupA(PSDRV_Heap, 0, value);
349 if (afm->FontName == NULL) {
357 if(!strncmp("FullName", buf, 8)) {
358 afm->FullName = HEAP_strdupA(PSDRV_Heap, 0, value);
359 if (afm->FullName == NULL) {
367 if(!strncmp("FamilyName", buf, 10)) {
368 afm->FamilyName = HEAP_strdupA(PSDRV_Heap, 0, value);
369 if (afm->FamilyName == NULL) {
377 if(!strncmp("Weight", buf, 6)) {
378 if(!strncmp("Roman", value, 5) || !strncmp("Medium", value, 6)
379 || !strncmp("Book", value, 4) || !strncmp("Regular", value, 7)
380 || !strncmp("Normal", value, 6))
381 afm->Weight = FW_NORMAL;
382 else if(!strncmp("Demi", value, 4))
383 afm->Weight = FW_DEMIBOLD;
384 else if(!strncmp("Bold", value, 4))
385 afm->Weight = FW_BOLD;
386 else if(!strncmp("Light", value, 5))
387 afm->Weight = FW_LIGHT;
388 else if(!strncmp("Black", value, 5))
389 afm->Weight = FW_BLACK;
391 WARN("%s specifies unknown Weight '%s'; treating as Roman\n",
393 afm->Weight = FW_NORMAL;
398 if(!strncmp("ItalicAngle", buf, 11)) {
399 sscanf(value, "%f", &(afm->ItalicAngle));
403 if(!strncmp("IsFixedPitch", buf, 12)) {
404 if(!strncasecmp("false", value, 5))
405 afm->IsFixedPitch = FALSE;
407 afm->IsFixedPitch = TRUE;
411 if(!strncmp("FontBBox", buf, 8)) {
412 sscanf(value, "%f %f %f %f", &(afm->FontBBox.llx),
413 &(afm->FontBBox.lly), &(afm->FontBBox.urx),
414 &(afm->FontBBox.ury) );
418 if(!strncmp("UnderlinePosition", buf, 17)) {
419 sscanf(value, "%f", &(afm->UnderlinePosition) );
423 if(!strncmp("UnderlineThickness", buf, 18)) {
424 sscanf(value, "%f", &(afm->UnderlineThickness) );
428 if(!strncmp("CapHeight", buf, 9)) {
429 sscanf(value, "%f", &(afm->CapHeight) );
433 if(!strncmp("XHeight", buf, 7)) {
434 sscanf(value, "%f", &(afm->XHeight) );
438 if(!strncmp("Ascender", buf, 8)) {
439 sscanf(value, "%f", &(afm->Ascender) );
443 if(!strncmp("Descender", buf, 9)) {
444 sscanf(value, "%f", &(afm->Descender) );
448 if(!strncmp("StartCharMetrics", buf, 16)) {
449 sscanf(value, "%d", &(afm->NumofMetrics) );
450 if (PSDRV_AFMGetCharMetrics(afm, fp) == FALSE) {
458 if(!strncmp("EncodingScheme", buf, 14)) {
459 afm->EncodingScheme = HEAP_strdupA(PSDRV_Heap, 0, value);
460 if (afm->EncodingScheme == NULL) {
472 HeapFree ( PSDRV_Heap, 0, afm );
476 if(afm->FontName == NULL) {
477 WARN("%s contains no FontName.\n", file);
478 afm->FontName = HEAP_strdupA(PSDRV_Heap, 0, "nofont");
479 if (afm->FontName == NULL) {
485 if(afm->FullName == NULL)
486 afm->FullName = HEAP_strdupA(PSDRV_Heap, 0, afm->FontName);
487 if(afm->FamilyName == NULL)
488 afm->FamilyName = HEAP_strdupA(PSDRV_Heap, 0, afm->FontName);
489 if (afm->FullName == NULL || afm->FamilyName == NULL) {
494 if(afm->Ascender == 0.0)
495 afm->Ascender = afm->FontBBox.ury;
496 if(afm->Descender == 0.0)
497 afm->Descender = afm->FontBBox.lly;
498 if(afm->FullAscender == 0.0)
499 afm->FullAscender = afm->Ascender;
501 afm->Weight = FW_NORMAL;
503 if (BuildEncoding(afm) == FALSE)
512 /***********************************************************
516 * Frees the family and afmlistentry structures in list head
518 void PSDRV_FreeAFMList( FONTFAMILY *head )
520 AFMLISTENTRY *afmle, *nexta;
521 FONTFAMILY *family, *nextf;
523 for(nextf = family = head; nextf; family = nextf) {
524 for(nexta = afmle = family->afmlist; nexta; afmle = nexta) {
526 HeapFree( PSDRV_Heap, 0, afmle );
528 nextf = family->next;
529 HeapFree( PSDRV_Heap, 0, family );
535 /***********************************************************
537 * PSDRV_FindAFMinList
538 * Returns ptr to an AFM if name (which is a PS font name) exists in list
541 AFM *PSDRV_FindAFMinList(FONTFAMILY *head, char *name)
546 for(family = head; family; family = family->next) {
547 for(afmle = family->afmlist; afmle; afmle = afmle->next) {
548 if(!strcmp(afmle->afm->FontName, name))
555 /***********************************************************
559 * Adds an afm to the list whose head is pointed to by head. Creates new
560 * family node if necessary and always creates a new AFMLISTENTRY.
562 BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, AFM *afm)
564 FONTFAMILY *family = *head;
565 FONTFAMILY **insert = head;
566 AFMLISTENTRY *tmpafmle, *newafmle;
568 newafmle = HeapAlloc(PSDRV_Heap, HEAP_ZERO_MEMORY,
570 if (newafmle == NULL)
576 if(!strcmp(family->FamilyName, afm->FamilyName))
578 insert = &(family->next);
579 family = family->next;
583 family = HeapAlloc(PSDRV_Heap, HEAP_ZERO_MEMORY,
585 if (family == NULL) {
586 HeapFree(PSDRV_Heap, 0, newafmle);
590 family->FamilyName = HEAP_strdupA(PSDRV_Heap, 0,
592 if (family->FamilyName == NULL) {
593 HeapFree(PSDRV_Heap, 0, family);
594 HeapFree(PSDRV_Heap, 0, newafmle);
597 family->afmlist = newafmle;
601 tmpafmle = family->afmlist;
603 if (!strcmp(tmpafmle->afm->FontName, afm->FontName)) {
604 WARN("Ignoring duplicate FontName '%s'\n", afm->FontName);
605 HeapFree(PSDRV_Heap, 0, newafmle);
606 return TRUE; /* not a fatal error */
608 tmpafmle = tmpafmle->next;
612 tmpafmle = family->afmlist;
613 while(tmpafmle->next)
614 tmpafmle = tmpafmle->next;
616 tmpafmle->next = newafmle;
621 /**********************************************************
623 * PSDRV_ReencodeCharWidths
625 * Re map the CharWidths field of the afm to correspond to an ANSI encoding
628 static void PSDRV_ReencodeCharWidths(AFM *afm)
633 for(i = 0; i < 256; i++) {
636 if(PSDRV_ANSIVector[i] == NULL) {
637 afm->CharWidths[i] = 0.0;
640 for (j = 0, metric = afm->Metrics; j < afm->NumofMetrics; j++, metric++) {
641 if(metric->N && !strcmp(metric->N->sz, PSDRV_ANSIVector[i])) {
642 afm->CharWidths[i] = metric->WX;
646 if(j == afm->NumofMetrics) {
647 WARN("Couldn't find glyph '%s' in font '%s'\n",
648 PSDRV_ANSIVector[i], afm->FontName);
649 afm->CharWidths[i] = 0.0;
656 /***********************************************************
661 static void PSDRV_DumpFontList(void)
666 for(family = PSDRV_AFMFontList; family; family = family->next) {
667 TRACE("Family '%s'\n", family->FamilyName);
668 for(afmle = family->afmlist; afmle; afmle = afmle->next)
672 TRACE("\tFontName '%s' (%i glyphs) - '%s' encoding:\n",
673 afmle->afm->FontName, afmle->afm->NumofMetrics,
674 afmle->afm->EncodingScheme);
676 for (i = 0; i < afmle->afm->NumofMetrics; ++i)
678 TRACE("\t\tU+%.4lX; C %i; N '%s'\n", afmle->afm->Metrics[i].UV,
679 afmle->afm->Metrics[i].C, afmle->afm->Metrics[i].N->sz);
686 /*******************************************************************************
689 * Initializes the UV member of each glyph's AFMMETRICS and sorts each font's
690 * Metrics by Unicode Value. If the font has a standard encoding (i.e. it is
691 * using the Adobe Glyph List encoding vector), look up each glyph's Unicode
692 * Value based on it's glyph name. If the font has a font-specific encoding,
693 * map the default PostScript encodings into the Unicode private use area.
696 static int UnicodeGlyphByNameIndex(const UNICODEGLYPH *a, const UNICODEGLYPH *b)
698 return a->name->index - b->name->index;
701 static int UnicodeGlyphByUV(const UNICODEGLYPH *a, const UNICODEGLYPH *b)
703 return a->UV - b->UV;
706 static int AFMMetricsByUV(const AFMMETRICS *a, const AFMMETRICS *b)
708 return a->UV - b->UV;
711 static BOOL SortFontMetrics()
713 UNICODEGLYPH *aglCopy = NULL;
714 FONTFAMILY *family = PSDRV_AFMFontList;
716 while (family != NULL)
718 AFMLISTENTRY *afmle = family->afmlist;
720 while (afmle != NULL)
722 AFM *afm = afmle->afm; /* should always be valid */
725 if (afm->Encoding == &PSDRV_AdobeGlyphList)
727 if (aglCopy == NULL) /* do this once, if necessary */
729 aglCopy = HeapAlloc(PSDRV_Heap, 0,
730 PSDRV_AdobeGlyphList.size * sizeof(UNICODEGLYPH));
734 memcpy(aglCopy, PSDRV_AdobeGlyphList.glyphs,
735 PSDRV_AdobeGlyphList.size * sizeof(UNICODEGLYPH));
737 qsort(aglCopy, PSDRV_AdobeGlyphList.size,
738 sizeof(UNICODEGLYPH),
739 (compar_callback_fn)UnicodeGlyphByNameIndex);
742 for (i = 0; i < afm->NumofMetrics; ++i)
744 UNICODEGLYPH ug, *pug;
746 ug.name = afm->Metrics[i].N;
749 pug = bsearch(&ug, aglCopy, PSDRV_AdobeGlyphList.size,
750 sizeof(UNICODEGLYPH),
751 (compar_callback_fn)UnicodeGlyphByNameIndex);
754 WARN("Glyph '%s' in font '%s' does not have a UV\n",
755 ug.name->sz, afm->FullName);
756 afm->Metrics[i].UV = -1;
760 afm->Metrics[i].UV = pug->UV;
764 else /* FontSpecific encoding or TrueType font */
766 for (i = 0; i < afm->NumofMetrics; ++i)
767 afm->Metrics[i].UV = afm->Encoding->glyphs[i].UV;
769 /* typecast avoids compiler warning */
770 qsort((void *)(afm->Encoding->glyphs), afm->Encoding->size,
771 sizeof(UNICODEGLYPH),
772 (compar_callback_fn)UnicodeGlyphByUV);
774 for (i = 0; i < afm->Encoding->size; ++i)
775 if (afm->Encoding->glyphs[i].UV >= 0)
778 afm->Encoding->size -= i; /* Ignore unencoded glyphs */
779 afm->Encoding->glyphs += i; /* from now on */
782 qsort(afm->Metrics, afm->NumofMetrics, sizeof(AFMMETRICS),
783 (compar_callback_fn)AFMMetricsByUV);
785 for (i = 0; i < afm->NumofMetrics; ++i)
786 if (afm->Metrics[i].UV >= 0)
789 afm->NumofMetrics -= i; /* Ignore unencoded glyphs here too */
795 family = family->next;
799 HeapFree(PSDRV_Heap, 0, aglCopy);
804 /*******************************************************************************
807 * Calculates several Windows-specific font metrics for each font. Relies on
808 * the fact that AFMs are allocated with HEAP_ZERO_MEMORY to distinguish
809 * TrueType fonts (when implemented), which already have these filled in.
812 static VOID CalcWindowsMetrics()
814 FONTFAMILY *family = PSDRV_AFMFontList;
816 while (family != NULL)
818 AFMLISTENTRY *afmle = family->afmlist;
820 while (afmle != NULL)
823 AFM *afm = afmle->afm; /* should always be valid */
826 if (afm->WinMetrics.usUnitsPerEm != 0)
827 continue; /* TrueType font */
829 wm.usUnitsPerEm = 1000; /* for PostScript fonts */
830 wm.sTypoAscender = (SHORT)(afm->Ascender + 0.5);
831 wm.sTypoDescender = (SHORT)(afm->Descender - 0.5);
833 wm.sTypoLineGap = 1200 - (wm.sTypoAscender - wm.sTypoDescender);
834 if (wm.sTypoLineGap < 0)
840 for (i = 0; i < afm->NumofMetrics; ++i)
842 if (IsWinANSI(afm->Metrics[i].UV) == FALSE)
845 if (afm->Metrics[i].B.ury > 0)
847 USHORT ascent = (USHORT)(afm->Metrics[i].B.ury + 0.5);
849 if (ascent > wm.usWinAscent)
850 wm.usWinAscent = ascent;
853 if (afm->Metrics[i].B.lly < 0)
855 USHORT descent = (USHORT)(-(afm->Metrics[i].B.lly) + 0.5);
857 if (descent > wm.usWinDescent)
858 wm.usWinDescent = descent;
862 if (wm.usWinAscent == 0 && afm->FontBBox.ury > 0)
863 wm.usWinAscent = (USHORT)(afm->FontBBox.ury + 0.5);
865 if (wm.usWinDescent == 0 && afm->FontBBox.lly < 0)
866 wm.usWinDescent = (USHORT)(-(afm->FontBBox.lly) + 0.5);
868 wm.sAscender = wm.usWinAscent;
869 wm.sDescender = -(wm.usWinDescent);
871 wm.sLineGap = 1150 - (wm.sAscender - wm.sDescender);
875 TRACE("Windows metrics for '%s':\n", afm->FullName);
876 TRACE("\tsAscender = %i\n", wm.sAscender);
877 TRACE("\tsDescender = %i\n", wm.sDescender);
878 TRACE("\tsLineGap = %i\n", wm.sLineGap);
879 TRACE("\tusUnitsPerEm = %u\n", wm.usUnitsPerEm);
880 TRACE("\tsTypoAscender = %i\n", wm.sTypoAscender);
881 TRACE("\tsTypoDescender = %i\n", wm.sTypoDescender);
882 TRACE("\tsTypoLineGap = %i\n", wm.sTypoLineGap);
883 TRACE("\tusWinAscent = %u\n", wm.usWinAscent);
884 TRACE("\tusWinDescent = %u\n", wm.usWinDescent);
886 afm->WinMetrics = wm;
888 /* See afm2c.c and mkagl.c for an explanation of this */
889 /* PSDRV_AFM2C(afm); */
894 family = family ->next;
899 /*******************************************************************************
904 static BOOL AddBuiltinAFMs()
908 while (PSDRV_BuiltinAFMs[i] != NULL)
910 if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, PSDRV_BuiltinAFMs[i])
920 /***********************************************************
922 * PSDRV_GetFontMetrics
924 * Parses all afm files listed in [afmfiles] and [afmdirs] of wine.conf
926 * If this function fails, PSDRV_Init will destroy PSDRV_Heap, so don't worry
927 * about freeing all the memory that's been allocated.
930 static BOOL PSDRV_ReadAFMDir(const char* afmdir) {
934 dir = opendir(afmdir);
937 while ((dent=readdir(dir))) {
938 if (strstr(dent->d_name,".afm")) {
941 afmfn=(char*)HeapAlloc(PSDRV_Heap,0,
942 strlen(afmdir)+strlen(dent->d_name)+2);
947 strcpy(afmfn,afmdir);
949 strcat(afmfn,dent->d_name);
950 TRACE("loading AFM %s\n",afmfn);
951 afm = PSDRV_AFMParse(afmfn);
953 if(afm->EncodingScheme &&
954 !strcmp(afm->EncodingScheme,"AdobeStandardEncoding")) {
955 PSDRV_ReencodeCharWidths(afm);
957 if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, afm) == FALSE) {
964 WARN("Error parsing %s\n", afmfn);
966 HeapFree(PSDRV_Heap,0,afmfn);
972 WARN("Error opening %s\n", afmdir);
978 BOOL PSDRV_GetFontMetrics(void)
984 if (PSDRV_GlyphListInit() != 0)
987 while (PROFILE_EnumWineIniString( "afmfiles", idx++, key, sizeof(key),
988 value, sizeof(value)))
990 AFM* afm = PSDRV_AFMParse(value);
993 if(afm->EncodingScheme &&
994 !strcmp(afm->EncodingScheme, "AdobeStandardEncoding")) {
995 PSDRV_ReencodeCharWidths(afm);
997 if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, afm) == FALSE) {
1002 WARN("Error parsing %s\n", value);
1006 for (idx = 0; PROFILE_EnumWineIniString ("afmdirs", idx, key, sizeof (key),
1007 value, sizeof (value)); ++idx)
1008 if (PSDRV_ReadAFMDir (value) == FALSE)
1011 PSDRV_IndexGlyphList(); /* So SortFontMetrics will work */
1012 if (SortFontMetrics() == FALSE)
1014 CalcWindowsMetrics();
1015 if (AddBuiltinAFMs() == FALSE)
1018 #ifdef HAVE_FREETYPE
1019 if (PSDRV_GetTrueTypeMetrics() == FALSE)
1021 PSDRV_IndexGlyphList();
1024 PSDRV_DumpFontList();