fprintf (out, "end readonly def\n");
fprintf (out, "FontName currentdict end definefont pop\n");
}
-
-void
-printAFM (FILE * afm, struct HeadTable *ht,
- char **strings, int nglyphs, int postType,
- struct PostTable *pt, struct GlyphName *gnt,
- struct Box *bbox, struct HheaTable *hhea, longHorMetric * hmtx,
- int nkern, int *nke, struct KernEntry0 **ke)
-{
- fprintf (afm, "StartFontMetrics 3.0\n");
- fprintf (afm, "Comment Automatically generated by ttfps -- do not edit\n");
- printAFMHeader (afm, ht, strings, pt);
- printAFMMetrics (afm, ht, nglyphs, postType, gnt, bbox, hhea, hmtx);
- printAFMKerning (afm, ht, postType, gnt, nkern, nke, ke);
- fprintf (afm, "EndFontMetrics\n");
-}
-
-void
-printAFMHeader (FILE * afm, struct HeadTable *ht,
- char **strings, struct PostTable *pt)
-{
- fprintf (afm, "FontName %s\n", strings[6] ? strings[6] : "Unknown");
- if (strings[4])
- fprintf (afm, "FullName %s\n", strings[4]);
- if (strings[1])
- fprintf (afm, "FamilyName %s\n", strings[1]);
- fprintf (afm, "IsFixedPitch %s\n", pt->isFixedPitch ? "true" : "false");
- fprintf (afm, "FontBBox %ld %ld %ld %ld\n",
- ht->xMin * 1000L / ht->unitsPerEm,
- ht->yMin * 1000L / ht->unitsPerEm,
- ht->xMax * 1000L / ht->unitsPerEm,
- ht->yMax * 1000L / ht->unitsPerEm);
- fprintf (afm, "UnderlinePosition %ld\n",
- pt->underlinePosition * 1000L / ht->unitsPerEm);
- fprintf (afm, "UnderlineThickness %ld\n",
- pt->underlineThickness * 1000L / ht->unitsPerEm);
- fprintf (afm, "Version %d.%u\n", ht->fontRevision.mantissa,
- ht->fontRevision.fraction);
- if (strings[0])
- fprintf (afm, "Notice %s\n", strings[0]);
- fprintf (afm, "EncodingScheme AdobeStandardEncoding\n");
- /* fprintf(afm,"CapHeight %d\n");
- fprintf(afm,"XHeight %d\n");
- fprintf(afm,"Ascender %d\n");
- fprintf(afm,"Descender %d\n"); */
-}
-
-void
-printAFMMetrics (FILE * afm, struct HeadTable *ht,
- int nglyphs, int postType, struct GlyphName *gnt,
- struct Box *bbox,
- struct HheaTable *hhea, longHorMetric * hmtx)
-{
- int i, j;
- char *name;
- struct hashtable *table;
- char *already_done;
-
- /* Hash all the character names */
- table = make_hashtable (nglyphs / 3 + 1);
- for (i = 0; i < nglyphs; i++)
- {
- name = NAMEOF (i);
- if (name)
- puthash (table, name, i);
- }
-
- already_done = mycalloc (nglyphs, sizeof (char));
-
- fprintf (afm, "StartCharMetrics %d\n", nglyphs);
- /* First, print out the encoded glyphs */
- for (i = 0; i < 256; i++)
- {
- if (adobeStandardEncoding[i])
- {
- j = gethash (table, adobeStandardEncoding[i]);
- if (j >= 0)
- {
- printOneAFMMetric (afm, j, i, adobeStandardEncoding[i],
- ht, bbox, hhea, hmtx);
- already_done[j] = 1;
- }
- }
- }
- /* Now, print out the others */
- for (j = 0; j < nglyphs; j++)
- {
- if (!already_done[j])
- {
- name = NAMEOF (j);
- printOneAFMMetric (afm, j, -1, name, ht, bbox, hhea, hmtx);
- }
- }
- fprintf (afm, "EndCharMetrics\n");
-}
-
-void
-printOneAFMMetric (FILE * afm,
- int index, int code, char *name,
- struct HeadTable *ht,
- struct Box *bbox,
- struct HheaTable *hhea, longHorMetric * hmtx)
-{
- if (name)
- {
- fprintf (afm, "C %d ;", code);
- if (hhea && hmtx)
- fprintf (afm, " WX %ld ;",
- index < hhea->numberOfHMetrics ?
- hmtx[index].advanceWidth * 1000L / ht->unitsPerEm :
- hmtx[hhea->numberOfHMetrics -
- 1].advanceWidth * 1000L / ht->unitsPerEm);
- fprintf (afm, " N %s ;", name);
- if (bbox)
- fprintf (afm, " B %ld %ld %ld %ld ;",
- bbox[index].xMin * 1000L / ht->unitsPerEm,
- bbox[index].yMin * 1000L / ht->unitsPerEm,
- bbox[index].xMax * 1000L / ht->unitsPerEm,
- bbox[index].yMax * 1000L / ht->unitsPerEm);
- fprintf (afm, "\n");
- }
-}
-
-void
-printAFMKerning (FILE * afm, struct HeadTable *ht,
- int postType, struct GlyphName *gnt,
- int nkern, int *nke, struct KernEntry0 **ke)
-{
- int i, j, n;
-
- for (n = i = 0; i < nkern; i++)
- n += nke[i];
- if (n == 0)
- return;
-
- fprintf (afm, "StartKernData\nStartKernPairs %d\n", n);
-
- for (i = 0; i < nkern; i++)
- for (j = 0; j < nke[i]; j++)
- fprintf (afm, "KPX %s %s %ld\n",
- NAMEOF (ke[i][j].left),
- NAMEOF (ke[i][j].right),
- ke[i][j].value * 1000L / ht->unitsPerEm);
- fprintf (afm, "EndKernPairs\nEndKernData\n");
-}