Commit a9eae850 authored by Ian Pilcher's avatar Ian Pilcher Committed by Alexandre Julliard

Remove redundant data structure from font metrics.

parent 3f46d3d6
......@@ -231,54 +231,6 @@ static BOOL PSDRV_AFMGetCharMetrics(AFM *afm, FILE *fp)
return TRUE;
}
/*******************************************************************************
* BuildEncoding
*
* Builds a custom encoding vector if necessary. Leaves vector in the same
* order as the afm->Metrics array; see SortFontMetrics().
*
*/
static BOOL BuildEncoding(AFM *afm)
{
UNICODEVECTOR *uv;
UNICODEGLYPH *ug;
int i;
if (strcmp(afm->EncodingScheme, "FontSpecific") != 0)
{
afm->Encoding = &PSDRV_AdobeGlyphList;
return TRUE;
}
uv = HeapAlloc(PSDRV_Heap, 0, sizeof(UNICODEVECTOR) +
afm->NumofMetrics * sizeof(UNICODEGLYPH));
if (uv == NULL)
return FALSE;
afm->Encoding = uv;
ug = (UNICODEGLYPH *)(uv + 1);
uv->glyphs = ug;
uv->size = afm->NumofMetrics;
for (i = 0; i < afm->NumofMetrics; ++i)
{
ug[i].name = afm->Metrics[i].N;
if (afm->Metrics[i].C < 0) /* unencoded glyph */
{
WARN("Glyph '%s' in font '%s' has no encoding\n", ug[i].name->sz,
afm->FullName);
ug[i].UV = -1;
}
else
{
ug[i].UV = afm->Metrics[i].C | 0xf000; /* private use area? */
}
}
return TRUE;
}
/***********************************************************
*
......@@ -500,12 +452,6 @@ static AFM *PSDRV_AFMParse(char const *file)
if(afm->Weight == 0)
afm->Weight = FW_NORMAL;
if (BuildEncoding(afm) == FALSE)
{
FreeAFM(afm);
return NULL;
}
return afm;
}
......@@ -698,11 +644,6 @@ static int UnicodeGlyphByNameIndex(const UNICODEGLYPH *a, const UNICODEGLYPH *b)
return a->name->index - b->name->index;
}
static int UnicodeGlyphByUV(const UNICODEGLYPH *a, const UNICODEGLYPH *b)
{
return a->UV - b->UV;
}
static int AFMMetricsByUV(const AFMMETRICS *a, const AFMMETRICS *b)
{
return a->UV - b->UV;
......@@ -722,7 +663,7 @@ static BOOL SortFontMetrics()
AFM *afm = afmle->afm; /* should always be valid */
INT i;
if (afm->Encoding == &PSDRV_AdobeGlyphList)
if (strcmp(afm->EncodingScheme, "FontSpecific") != 0)
{
if (aglCopy == NULL) /* do this once, if necessary */
{
......@@ -761,22 +702,10 @@ static BOOL SortFontMetrics()
}
}
}
else /* FontSpecific encoding or TrueType font */
else /* FontSpecific encoding */
{
for (i = 0; i < afm->NumofMetrics; ++i)
afm->Metrics[i].UV = afm->Encoding->glyphs[i].UV;
/* typecast avoids compiler warning */
qsort((void *)(afm->Encoding->glyphs), afm->Encoding->size,
sizeof(UNICODEGLYPH),
(compar_callback_fn)UnicodeGlyphByUV);
for (i = 0; i < afm->Encoding->size; ++i)
if (afm->Encoding->glyphs[i].UV >= 0)
break;
afm->Encoding->size -= i; /* Ignore unencoded glyphs */
afm->Encoding->glyphs += i; /* from now on */
afm->Metrics[i].UV = afm->Metrics[i].C;
}
qsort(afm->Metrics, afm->NumofMetrics, sizeof(AFMMETRICS),
......@@ -786,7 +715,7 @@ static BOOL SortFontMetrics()
if (afm->Metrics[i].UV >= 0)
break;
afm->NumofMetrics -= i; /* Ignore unencoded glyphs here too */
afm->NumofMetrics -= i; /* Ignore unencoded glyphs */
afm->Metrics += i;
afmle = afmle->next;
......
......@@ -1014,6 +1014,5 @@ AFM PSDRV_AvantGarde_Book =
0 /* CharWidths[255] */
},
228, /* NumofMetrics */
met_AvantGarde_Book, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_AvantGarde_Book /* Metrics */
};
......@@ -1014,6 +1014,5 @@ AFM PSDRV_AvantGarde_BookOblique =
0 /* CharWidths[255] */
},
228, /* NumofMetrics */
met_AvantGarde_BookOblique, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_AvantGarde_BookOblique /* Metrics */
};
......@@ -1014,6 +1014,5 @@ AFM PSDRV_AvantGarde_Demi =
0 /* CharWidths[255] */
},
228, /* NumofMetrics */
met_AvantGarde_Demi, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_AvantGarde_Demi /* Metrics */
};
......@@ -1015,5 +1015,4 @@ AFM PSDRV_AvantGarde_DemiOblique =
},
228, /* NumofMetrics */
met_AvantGarde_DemiOblique, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Bookman_Demi =
620, 940, 660, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Bookman_Demi, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Bookman_Demi /* Metrics */
};
......@@ -1014,6 +1014,5 @@ AFM PSDRV_Bookman_DemiItalic =
0 /* CharWidths[255] */
},
228, /* NumofMetrics */
met_Bookman_DemiItalic, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Bookman_DemiItalic /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Bookman_Light =
560, 900, 660, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Bookman_Light, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Bookman_Light /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Bookman_LightItalic =
540, 900, 620, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Bookman_LightItalic, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Bookman_LightItalic /* Metrics */
};
......@@ -1073,6 +1073,5 @@ AFM PSDRV_Courier =
600, 0, 0, 0, 0 /* CharWidths[251] - CharWidths[255] */
},
243, /* NumofMetrics */
met_Courier, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Courier /* Metrics */
};
......@@ -1073,6 +1073,5 @@ AFM PSDRV_Courier_Bold =
600, 0, 0, 0, 0 /* CharWidths[251] - CharWidths[255] */
},
243, /* NumofMetrics */
met_Courier_Bold, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Courier_Bold /* Metrics */
};
......@@ -1073,6 +1073,5 @@ AFM PSDRV_Courier_BoldOblique =
600, 0, 0, 0, 0 /* CharWidths[251] - CharWidths[255] */
},
243, /* NumofMetrics */
met_Courier_BoldOblique, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Courier_BoldOblique /* Metrics */
};
......@@ -1073,6 +1073,5 @@ AFM PSDRV_Courier_Oblique =
600, 0, 0, 0, 0 /* CharWidths[251] - CharWidths[255] */
},
243, /* NumofMetrics */
met_Courier_Oblique, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Courier_Oblique /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Helvetica =
611, 944, 611, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Helvetica, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Helvetica /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Helvetica_Bold =
611, 944, 611, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Helvetica_Bold, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Helvetica_Bold /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Helvetica_BoldOblique =
611, 944, 611, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Helvetica_BoldOblique, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Helvetica_BoldOblique /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Helvetica_Narrow =
501, 0, 0, 0, 0 /* CharWidths[251] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Helvetica_Narrow, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Helvetica_Narrow /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Helvetica_Narrow_Bold =
501, 0, 0, 0, 0 /* CharWidths[251] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Helvetica_Narrow_Bold, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Helvetica_Narrow_Bold /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Helvetica_Narrow_BoldOblique =
501, 0, 0, 0, 0 /* CharWidths[251] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Helvetica_Narrow_BoldOblique, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Helvetica_Narrow_BoldOblique /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Helvetica_Narrow_Oblique =
501, 0, 0, 0, 0 /* CharWidths[251] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Helvetica_Narrow_Oblique, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Helvetica_Narrow_Oblique /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Helvetica_Oblique =
611, 944, 611, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Helvetica_Oblique, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Helvetica_Oblique /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_NewCenturySchlbk_Bold =
611, 907, 611, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_NewCenturySchlbk_Bold, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_NewCenturySchlbk_Bold /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_NewCenturySchlbk_BoldItalic =
574, 852, 574, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_NewCenturySchlbk_BoldItalic, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_NewCenturySchlbk_BoldItalic /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_NewCenturySchlbk_Italic =
500, 778, 556, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_NewCenturySchlbk_Italic, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_NewCenturySchlbk_Italic /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_NewCenturySchlbk_Roman =
500, 833, 574, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_NewCenturySchlbk_Roman, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_NewCenturySchlbk_Roman /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Palatino_Bold =
556, 833, 611, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Palatino_Bold, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Palatino_Bold /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Palatino_BoldItalic =
556, 778, 556, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Palatino_BoldItalic, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Palatino_BoldItalic /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Palatino_Italic =
444, 669, 500, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Palatino_Italic, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Palatino_Italic /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Palatino_Roman =
556, 827, 556, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Palatino_Roman, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Palatino_Roman /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Times_Bold =
500, 722, 556, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Times_Bold, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Times_Bold /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Times_BoldItalic =
500, 722, 500, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Times_BoldItalic, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Times_BoldItalic /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Times_Italic =
500, 0, 0, 0, 0 /* CharWidths[251] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Times_Italic, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Times_Italic /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_Times_Roman =
500, 722, 500, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_Times_Roman, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_Times_Roman /* Metrics */
};
......@@ -1013,6 +1013,5 @@ AFM PSDRV_ZapfChancery_MediumItalic =
440, 560, 420, 0, 0, 0, 0 /* CharWidths[249] - CharWidths[255] */
},
228, /* NumofMetrics */
met_ZapfChancery_MediumItalic, /* Metrics */
&PSDRV_AdobeGlyphList /* Encoding */
met_ZapfChancery_MediumItalic /* Metrics */
};
......@@ -85,7 +85,6 @@ typedef struct _tagAFM {
float CharWidths[256];
int NumofMetrics;
AFMMETRICS *Metrics;
UNICODEVECTOR *Encoding;
} AFM; /* CharWidths is a shortcut to the WX values of numbered glyphs */
/* Note no 'next' in AFM. Use AFMLISTENTRY as a container. This allow more than
......
......@@ -267,8 +267,6 @@ static void FreeAFM(AFM *afm)
HeapFree(PSDRV_Heap, 0, afm->EncodingScheme);
if (afm->Metrics != NULL)
HeapFree(PSDRV_Heap, 0, afm->Metrics);
if (afm->Encoding != NULL)
HeapFree(PSDRV_Heap, 0, afm->Encoding);
HeapFree(PSDRV_Heap, 0, afm);
}
......@@ -339,14 +337,12 @@ static BOOL ReadMetricsTables(AFM *afm)
*
* Reads metrics for each glyph in a TrueType font. Since FreeAFM will try to
* free afm->Metrics and afm->Encoding if they are non-NULL, don't free them
* in the event of an error. (FreeAFM depends on the fact that afm->Encoding
* and its associated array of UNICODEGLYPHs are allocated as a single object.)
* in the event of an error.
*
*/
static BOOL ReadCharMetrics(AFM *afm)
{
FT_ULong charcode, index;
UNICODEGLYPH *glyphs;
/*
* There does not seem to be an easy way to get the number of characters
......@@ -361,15 +357,9 @@ static BOOL ReadCharMetrics(AFM *afm)
afm->NumofMetrics = index;
afm->Metrics = HeapAlloc(PSDRV_Heap, 0, index * sizeof(AFMMETRICS));
afm->Encoding = HeapAlloc(PSDRV_Heap, 0, sizeof(UNICODEVECTOR) +
index * sizeof(UNICODEGLYPH));
if (afm->Metrics == NULL || afm->Encoding == NULL)
if (afm->Metrics == NULL)
return FALSE;
glyphs = (UNICODEGLYPH *)(afm->Encoding + 1);
afm->Encoding->size = index;
afm->Encoding->glyphs = glyphs;
for (charcode = 0, index = 0; charcode <= 65536; ++charcode)
{
FT_UInt glyph_index = FT_Get_Char_Index(face, charcode);
......@@ -423,9 +413,6 @@ static BOOL ReadCharMetrics(AFM *afm)
afm->Metrics[index].B.llx, afm->Metrics[index].B.lly,
afm->Metrics[index].B.urx, afm->Metrics[index].B.ury);
glyphs[index].UV = charcode;
glyphs[index].name = afm->Metrics[index].N;
if (charcode == 0x0048) /* 'H' */
afm->CapHeight = PSUnits(bbox.yMax);
if (charcode == 0x0078) /* 'x' */
......@@ -535,7 +522,7 @@ static BOOL ReadTrueTypeFile(LPCSTR filename)
return FALSE;
}
if (afm->Encoding == NULL) /* last element to be set */
if (afm->Metrics == NULL) /* last element to be set */
{
FreeAFM(afm);
return TRUE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment