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);
235 /***********************************************************
239 * Fills out an AFM structure and associated substructures (see psdrv.h)
240 * for a given AFM file. All memory is allocated from the process heap.
241 * Returns a ptr to the AFM structure or NULL on error.
243 * This is not complete (we don't handle kerning yet) and not efficient
246 static AFM *PSDRV_AFMParse(char const *file)
249 unsigned char buf[256];
250 unsigned char *value;
256 TRACE("parsing '%s'\n", file);
258 if((fp = fopen(file, "r")) == NULL) {
259 MESSAGE("Can't open AFM file '%s'. Please check wine.conf .\n", file);
263 afm = HeapAlloc(PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(AFM));
270 while ( ( c = fgetc ( fp ) ) != EOF ) {
272 if ( *cp == '\r' || *cp == '\n' || cp - buf == sizeof(buf)-2 ) {
282 cp = buf + strlen(buf);
286 } while(cp > buf && isspace(*cp));
290 if ( afmfile == 0 && strncmp ( buf, "StartFontMetrics", 16 ) )
294 value = strchr(buf, ' ');
296 while(isspace(*value))
299 if(!strncmp("FontName", buf, 8)) {
300 afm->FontName = HEAP_strdupA(PSDRV_Heap, 0, value);
301 if (afm->FontName == NULL) {
309 if(!strncmp("FullName", buf, 8)) {
310 afm->FullName = HEAP_strdupA(PSDRV_Heap, 0, value);
311 if (afm->FullName == NULL) {
319 if(!strncmp("FamilyName", buf, 10)) {
320 afm->FamilyName = HEAP_strdupA(PSDRV_Heap, 0, value);
321 if (afm->FamilyName == NULL) {
329 if(!strncmp("Weight", buf, 6)) {
330 if(!strncmp("Roman", value, 5) || !strncmp("Medium", value, 6)
331 || !strncmp("Book", value, 4) || !strncmp("Regular", value, 7)
332 || !strncmp("Normal", value, 6))
333 afm->Weight = FW_NORMAL;
334 else if(!strncmp("Demi", value, 4))
335 afm->Weight = FW_DEMIBOLD;
336 else if(!strncmp("Bold", value, 4))
337 afm->Weight = FW_BOLD;
338 else if(!strncmp("Light", value, 5))
339 afm->Weight = FW_LIGHT;
340 else if(!strncmp("Black", value, 5))
341 afm->Weight = FW_BLACK;
343 WARN("%s specifies unknown Weight '%s'; treating as Roman\n",
345 afm->Weight = FW_NORMAL;
350 if(!strncmp("ItalicAngle", buf, 11)) {
351 sscanf(value, "%f", &(afm->ItalicAngle));
355 if(!strncmp("IsFixedPitch", buf, 12)) {
356 if(!strncasecmp("false", value, 5))
357 afm->IsFixedPitch = FALSE;
359 afm->IsFixedPitch = TRUE;
363 if(!strncmp("FontBBox", buf, 8)) {
364 sscanf(value, "%f %f %f %f", &(afm->FontBBox.llx),
365 &(afm->FontBBox.lly), &(afm->FontBBox.urx),
366 &(afm->FontBBox.ury) );
370 if(!strncmp("UnderlinePosition", buf, 17)) {
371 sscanf(value, "%f", &(afm->UnderlinePosition) );
375 if(!strncmp("UnderlineThickness", buf, 18)) {
376 sscanf(value, "%f", &(afm->UnderlineThickness) );
380 if(!strncmp("CapHeight", buf, 9)) {
381 sscanf(value, "%f", &(afm->CapHeight) );
385 if(!strncmp("XHeight", buf, 7)) {
386 sscanf(value, "%f", &(afm->XHeight) );
390 if(!strncmp("Ascender", buf, 8)) {
391 sscanf(value, "%f", &(afm->Ascender) );
395 if(!strncmp("Descender", buf, 9)) {
396 sscanf(value, "%f", &(afm->Descender) );
400 if(!strncmp("StartCharMetrics", buf, 16)) {
401 sscanf(value, "%d", &(afm->NumofMetrics) );
402 if (PSDRV_AFMGetCharMetrics(afm, fp) == FALSE) {
410 if(!strncmp("EncodingScheme", buf, 14)) {
411 afm->EncodingScheme = HEAP_strdupA(PSDRV_Heap, 0, value);
412 if (afm->EncodingScheme == NULL) {
424 HeapFree ( PSDRV_Heap, 0, afm );
428 if(afm->FontName == NULL) {
429 WARN("%s contains no FontName.\n", file);
430 afm->FontName = HEAP_strdupA(PSDRV_Heap, 0, "nofont");
431 if (afm->FontName == NULL) {
437 if(afm->FullName == NULL)
438 afm->FullName = HEAP_strdupA(PSDRV_Heap, 0, afm->FontName);
439 if(afm->FamilyName == NULL)
440 afm->FamilyName = HEAP_strdupA(PSDRV_Heap, 0, afm->FontName);
441 if (afm->FullName == NULL || afm->FamilyName == NULL) {
446 if(afm->Ascender == 0.0)
447 afm->Ascender = afm->FontBBox.ury;
448 if(afm->Descender == 0.0)
449 afm->Descender = afm->FontBBox.lly;
450 if(afm->FullAscender == 0.0)
451 afm->FullAscender = afm->Ascender;
453 afm->Weight = FW_NORMAL;
458 /***********************************************************
462 * Frees the family and afmlistentry structures in list head
464 void PSDRV_FreeAFMList( FONTFAMILY *head )
466 AFMLISTENTRY *afmle, *nexta;
467 FONTFAMILY *family, *nextf;
469 for(nextf = family = head; nextf; family = nextf) {
470 for(nexta = afmle = family->afmlist; nexta; afmle = nexta) {
472 HeapFree( PSDRV_Heap, 0, afmle );
474 nextf = family->next;
475 HeapFree( PSDRV_Heap, 0, family );
481 /***********************************************************
483 * PSDRV_FindAFMinList
484 * Returns ptr to an AFM if name (which is a PS font name) exists in list
487 AFM *PSDRV_FindAFMinList(FONTFAMILY *head, char *name)
492 for(family = head; family; family = family->next) {
493 for(afmle = family->afmlist; afmle; afmle = afmle->next) {
494 if(!strcmp(afmle->afm->FontName, name))
501 /***********************************************************
505 * Adds an afm to the list whose head is pointed to by head. Creates new
506 * family node if necessary and always creates a new AFMLISTENTRY.
508 BOOL PSDRV_AddAFMtoList(FONTFAMILY **head, AFM *afm)
510 FONTFAMILY *family = *head;
511 FONTFAMILY **insert = head;
512 AFMLISTENTRY *tmpafmle, *newafmle;
514 newafmle = HeapAlloc(PSDRV_Heap, HEAP_ZERO_MEMORY,
516 if (newafmle == NULL)
522 if(!strcmp(family->FamilyName, afm->FamilyName))
524 insert = &(family->next);
525 family = family->next;
529 family = HeapAlloc(PSDRV_Heap, HEAP_ZERO_MEMORY,
531 if (family == NULL) {
532 HeapFree(PSDRV_Heap, 0, newafmle);
536 family->FamilyName = HEAP_strdupA(PSDRV_Heap, 0,
538 if (family->FamilyName == NULL) {
539 HeapFree(PSDRV_Heap, 0, family);
540 HeapFree(PSDRV_Heap, 0, newafmle);
543 family->afmlist = newafmle;
547 tmpafmle = family->afmlist;
549 if (!strcmp(tmpafmle->afm->FontName, afm->FontName)) {
550 WARN("Ignoring duplicate FontName '%s'\n", afm->FontName);
551 HeapFree(PSDRV_Heap, 0, newafmle);
552 return TRUE; /* not a fatal error */
554 tmpafmle = tmpafmle->next;
558 tmpafmle = family->afmlist;
559 while(tmpafmle->next)
560 tmpafmle = tmpafmle->next;
562 tmpafmle->next = newafmle;
567 /**********************************************************
569 * PSDRV_ReencodeCharWidths
571 * Re map the CharWidths field of the afm to correspond to an ANSI encoding
574 static void PSDRV_ReencodeCharWidths(AFM *afm)
579 for(i = 0; i < 256; i++) {
582 if(PSDRV_ANSIVector[i] == NULL) {
583 afm->CharWidths[i] = 0.0;
586 for (j = 0, metric = afm->Metrics; j < afm->NumofMetrics; j++, metric++) {
587 if(metric->N && !strcmp(metric->N->sz, PSDRV_ANSIVector[i])) {
588 afm->CharWidths[i] = metric->WX;
592 if(j == afm->NumofMetrics) {
593 WARN("Couldn't find glyph '%s' in font '%s'\n",
594 PSDRV_ANSIVector[i], afm->FontName);
595 afm->CharWidths[i] = 0.0;
602 /***********************************************************
607 static void PSDRV_DumpFontList(void)
612 for(family = PSDRV_AFMFontList; family; family = family->next) {
613 TRACE("Family '%s'\n", family->FamilyName);
614 for(afmle = family->afmlist; afmle; afmle = afmle->next)
618 TRACE("\tFontName '%s' (%i glyphs) - '%s' encoding:\n",
619 afmle->afm->FontName, afmle->afm->NumofMetrics,
620 afmle->afm->EncodingScheme);
622 for (i = 0; i < afmle->afm->NumofMetrics; ++i)
624 TRACE("\t\tU+%.4lX; C %i; N '%s'\n", afmle->afm->Metrics[i].UV,
625 afmle->afm->Metrics[i].C, afmle->afm->Metrics[i].N->sz);
632 /*******************************************************************************
635 * Initializes the UV member of each glyph's AFMMETRICS and sorts each font's
636 * Metrics by Unicode Value. If the font has a standard encoding (i.e. it is
637 * using the Adobe Glyph List encoding vector), look up each glyph's Unicode
638 * Value based on it's glyph name. If the font has a font-specific encoding,
639 * map the default PostScript encodings into the Unicode private use area.
642 static int UnicodeGlyphByNameIndex(const UNICODEGLYPH *a, const UNICODEGLYPH *b)
644 return a->name->index - b->name->index;
647 static int AFMMetricsByUV(const AFMMETRICS *a, const AFMMETRICS *b)
649 return a->UV - b->UV;
652 static BOOL SortFontMetrics()
654 FONTFAMILY *family = PSDRV_AFMFontList;
656 while (family != NULL)
658 AFMLISTENTRY *afmle = family->afmlist;
660 while (afmle != NULL)
662 AFM *afm = afmle->afm; /* should always be valid */
665 if (strcmp(afm->EncodingScheme, "FontSpecific") != 0)
667 PSDRV_IndexGlyphList(); /* enable searching by name index */
669 for (i = 0; i < afm->NumofMetrics; ++i)
671 UNICODEGLYPH ug, *pug;
673 ug.name = afm->Metrics[i].N;
676 pug = bsearch(&ug, PSDRV_AGLbyName, PSDRV_AGLbyNameSize,
677 sizeof(UNICODEGLYPH),
678 (compar_callback_fn)UnicodeGlyphByNameIndex);
681 WARN("Glyph '%s' in font '%s' does not have a UV\n",
682 ug.name->sz, afm->FullName);
683 afm->Metrics[i].UV = -1;
687 afm->Metrics[i].UV = pug->UV;
691 else /* FontSpecific encoding */
693 for (i = 0; i < afm->NumofMetrics; ++i)
694 afm->Metrics[i].UV = afm->Metrics[i].C;
697 qsort(afm->Metrics, afm->NumofMetrics, sizeof(AFMMETRICS),
698 (compar_callback_fn)AFMMetricsByUV);
700 for (i = 0; i < afm->NumofMetrics; ++i)
701 if (afm->Metrics[i].UV >= 0)
704 afm->NumofMetrics -= i; /* Ignore unencoded glyphs */
710 family = family->next;
716 /*******************************************************************************
717 * PSDRV_CalcAvgCharWidth
719 * Calculate WinMetrics.sAvgCharWidth for a Type 1 font. Can also be used on
720 * TrueType fonts, if font designer set OS/2:xAvgCharWidth to zero.
722 * Tries to use formula in TrueType specification; falls back to simple mean
723 * if any lowercase latin letter (or space) is not present.
725 inline static SHORT MeanCharWidth(const AFM *afm)
730 for (i = 0; i < afm->NumofMetrics; ++i)
731 w += afm->Metrics[i].WX;
733 w /= afm->NumofMetrics;
735 return (SHORT)(w + 0.5);
738 static const struct { LONG UV; int weight; } UVweight[27] =
740 { 0x0061, 64 }, { 0x0062, 14 }, { 0x0063, 27 }, { 0x0064, 35 },
741 { 0x0065, 100 }, { 0x0066, 20 }, { 0x0067, 14 }, { 0x0068, 42 },
742 { 0x0069, 63 }, { 0x006a, 3 }, { 0x006b, 6 }, { 0x006c, 35 },
743 { 0x006d, 20 }, { 0x006e, 56 }, { 0x006f, 56 }, { 0x0070, 17 },
744 { 0x0071, 4 }, { 0x0072, 49 }, { 0x0073, 56 }, { 0x0074, 71 },
745 { 0x0075, 31 }, { 0x0076, 10 }, { 0x0077, 18 }, { 0x0078, 3 },
746 { 0x0079, 18 }, { 0x007a, 2 }, { 0x0020, 166 }
749 SHORT PSDRV_CalcAvgCharWidth(const AFM *afm)
754 for (i = 0; i < 27; ++i)
756 const AFMMETRICS *afmm;
758 afmm = PSDRV_UVMetrics(UVweight[i].UV, afm);
759 if (afmm->UV != UVweight[i].UV) /* UVMetrics returns first glyph */
760 return MeanCharWidth(afm); /* in font if UV is missing */
762 w += afmm->WX * (float)(UVweight[i].weight);
767 return (SHORT)(w + 0.5);
770 /*******************************************************************************
773 * Calculates several Windows-specific font metrics for each font. Relies on
774 * the fact that AFMs are allocated with HEAP_ZERO_MEMORY to distinguish
775 * TrueType fonts (when implemented), which already have these filled in.
778 static VOID CalcWindowsMetrics()
780 FONTFAMILY *family = PSDRV_AFMFontList;
782 while (family != NULL)
784 AFMLISTENTRY *afmle = family->afmlist;
786 while (afmle != NULL)
789 AFM *afm = afmle->afm; /* should always be valid */
792 if (afm->WinMetrics.usUnitsPerEm != 0)
793 continue; /* TrueType font */
795 wm.usUnitsPerEm = 1000; /* for PostScript fonts */
796 wm.sTypoAscender = (SHORT)(afm->Ascender + 0.5);
797 wm.sTypoDescender = (SHORT)(afm->Descender - 0.5);
799 wm.sTypoLineGap = 1200 - (wm.sTypoAscender - wm.sTypoDescender);
800 if (wm.sTypoLineGap < 0)
806 for (i = 0; i < afm->NumofMetrics; ++i)
808 if (IsWinANSI(afm->Metrics[i].UV) == FALSE)
811 if (afm->Metrics[i].B.ury > 0)
813 USHORT ascent = (USHORT)(afm->Metrics[i].B.ury + 0.5);
815 if (ascent > wm.usWinAscent)
816 wm.usWinAscent = ascent;
819 if (afm->Metrics[i].B.lly < 0)
821 USHORT descent = (USHORT)(-(afm->Metrics[i].B.lly) + 0.5);
823 if (descent > wm.usWinDescent)
824 wm.usWinDescent = descent;
828 if (wm.usWinAscent == 0 && afm->FontBBox.ury > 0)
829 wm.usWinAscent = (USHORT)(afm->FontBBox.ury + 0.5);
831 if (wm.usWinDescent == 0 && afm->FontBBox.lly < 0)
832 wm.usWinDescent = (USHORT)(-(afm->FontBBox.lly) + 0.5);
834 wm.sAscender = wm.usWinAscent;
835 wm.sDescender = -(wm.usWinDescent);
837 wm.sLineGap = 1150 - (wm.sAscender - wm.sDescender);
841 wm.sAvgCharWidth = PSDRV_CalcAvgCharWidth(afm);
843 TRACE("Windows metrics for '%s':\n", afm->FullName);
844 TRACE("\tsAscender = %i\n", wm.sAscender);
845 TRACE("\tsDescender = %i\n", wm.sDescender);
846 TRACE("\tsLineGap = %i\n", wm.sLineGap);
847 TRACE("\tusUnitsPerEm = %u\n", wm.usUnitsPerEm);
848 TRACE("\tsTypoAscender = %i\n", wm.sTypoAscender);
849 TRACE("\tsTypoDescender = %i\n", wm.sTypoDescender);
850 TRACE("\tsTypoLineGap = %i\n", wm.sTypoLineGap);
851 TRACE("\tusWinAscent = %u\n", wm.usWinAscent);
852 TRACE("\tusWinDescent = %u\n", wm.usWinDescent);
853 TRACE("\tsAvgCharWidth = %i\n", wm.sAvgCharWidth);
855 afm->WinMetrics = wm;
857 /* See afm2c.c and mkagl.c for an explanation of this */
858 /* PSDRV_AFM2C(afm); */
863 family = family ->next;
868 /*******************************************************************************
873 static BOOL AddBuiltinAFMs()
877 while (PSDRV_BuiltinAFMs[i] != NULL)
879 if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, PSDRV_BuiltinAFMs[i])
889 /***********************************************************
891 * PSDRV_GetFontMetrics
893 * Parses all afm files listed in [afmfiles] and [afmdirs] of wine.conf
895 * If this function fails, PSDRV_Init will destroy PSDRV_Heap, so don't worry
896 * about freeing all the memory that's been allocated.
899 static BOOL PSDRV_ReadAFMDir(const char* afmdir) {
903 dir = opendir(afmdir);
906 while ((dent=readdir(dir))) {
907 if (strstr(dent->d_name,".afm")) {
910 afmfn=(char*)HeapAlloc(PSDRV_Heap,0,
911 strlen(afmdir)+strlen(dent->d_name)+2);
916 strcpy(afmfn,afmdir);
918 strcat(afmfn,dent->d_name);
919 TRACE("loading AFM %s\n",afmfn);
920 afm = PSDRV_AFMParse(afmfn);
922 if(afm->EncodingScheme &&
923 !strcmp(afm->EncodingScheme,"AdobeStandardEncoding")) {
924 PSDRV_ReencodeCharWidths(afm);
926 if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, afm) == FALSE) {
933 WARN("Error parsing %s\n", afmfn);
935 HeapFree(PSDRV_Heap,0,afmfn);
941 WARN("Error opening %s\n", afmdir);
947 BOOL PSDRV_GetFontMetrics(void)
953 DWORD type, key_len, value_len;
955 if (PSDRV_GlyphListInit() != 0)
958 if(RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\afmfiles",
963 key_len = sizeof(key);
964 value_len = sizeof(value);
965 while(!RegEnumValueA(hkey, idx++, key, &key_len, NULL, &type, value, &value_len))
967 AFM* afm = PSDRV_AFMParse(value);
970 if(afm->EncodingScheme &&
971 !strcmp(afm->EncodingScheme, "AdobeStandardEncoding")) {
972 PSDRV_ReencodeCharWidths(afm);
974 if (PSDRV_AddAFMtoList(&PSDRV_AFMFontList, afm) == FALSE) {
980 WARN("Error parsing %s\n", value);
983 /* initialize lengths for new iteration */
984 key_len = sizeof(key);
985 value_len = sizeof(value);
991 if(RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\afmdirs",
996 key_len = sizeof(key);
997 value_len = sizeof(value);
998 while(!RegEnumValueA(hkey, idx++, key, &key_len, NULL, &type, value, &value_len))
1000 if (PSDRV_ReadAFMDir (value) == FALSE)
1006 /* initialize lengths for new iteration */
1007 key_len = sizeof(key);
1008 value_len = sizeof(value);
1014 if (SortFontMetrics() == FALSE)
1016 CalcWindowsMetrics();
1017 if (AddBuiltinAFMs() == FALSE)
1020 #ifdef HAVE_FREETYPE
1021 if (PSDRV_GetTrueTypeMetrics() == FALSE)
1023 PSDRV_IndexGlyphList();
1026 PSDRV_DumpFontList();