exit (1); \
} while (0)
+char *registry;
+
void
dump_header (FT_Face face, char *foundry, int nchars, int pixel_size)
{
int y = face->bbox.yMin * pixel_size / face->units_per_EM;
printf ("STARTFONT 2.1\n");
- printf ("FONT -%s-%s-%s-R-Normal--%d-%d-72-72-C-%d-ISO10646-1\n",
+ printf ("FONT -%s-%s-%s-R-Normal--%d-%d-72-72-C-%d-%s\n",
foundry, face->family_name, face->style_name,
- pixel_size, pixel_size * 10, pixel_size * 10);
+ pixel_size, pixel_size * 10, pixel_size * 10, registry);
printf ("SIZE %d 72 72\n", pixel_size);
printf ("FONTBOUNDINGBOX %d %d %d %d\n", width, height, x, y);
printf ("STARTPROPERTIES 2\n");
int err;
int i;
int pixel_size = DEFAULT_PIXEL_SIZE;
- FT_UInt unicode_table[0x10000];
+ FT_UInt code_table[0x10000];
int nchars;
+ char *filename;
+ int platform_id, encoding_id;
- if (argc != 2)
- FATAL_ERROR ("%s\n", "Usage: otfimage [ X-OPTION ... ] OTF-FILE");
+ if (argc < 1)
+ FATAL_ERROR ("Usage: %s ENCODING OTF-FILE\n", argv[0]);
+ if (sscanf (argv[1], "%d-%d", &platform_id, &encoding_id) != 2)
+ {
+ platform_id = -1;
+ filename = argv[1];
+ }
+ else
+ filename = argv[2];
if ((err = FT_Init_FreeType (&library)))
FATAL_ERROR ("%s\n", "FT_Init_FreeType: error");
- err = FT_New_Face (library, argv[1], 0, &face);
+ err = FT_New_Face (library, filename, 0, &face);
if (err == FT_Err_Unknown_File_Format)
FATAL_ERROR ("%s\n", "FT_New_Face: unknown file format");
else if (err)
FATAL_ERROR ("%s\n", "FT_New_Face: unknown error");
+ if (platform_id >= 0)
+ {
+ for (i = 0; i < face->num_charmaps; i++)
+ if (face->charmaps[i]->platform_id == platform_id
+ && face->charmaps[i]->encoding_id == encoding_id)
+ break;
+ if (i == face->num_charmaps)
+ FATAL_ERROR ("Unknown ENCODING: %s\n", argv[1]);
+ FT_Set_Charmap (face, face->charmaps[i]);
+ if (platform_id == 0)
+ {
+ if (encoding_id == 3)
+ registry = "iso10646-1";
+ else if (face->charmaps[i]->encoding_id == 4)
+ registry = "iso10646-full";
+ }
+ else if (face->charmaps[i]->platform_id == 3)
+ {
+ if (face->charmaps[i]->encoding_id == 1)
+ registry = "iso10646-1";
+ else if (face->charmaps[i]->encoding_id == 10)
+ registry = "iso10646-full";
+ }
+ else
+ {
+ registry = alloca (256);
+ sprintf (registry, "%d-%d", platform_id, encoding_id);
+ }
+ }
+ else
+ {
+ registry = "raw-glyph";
+ }
+
{
char *str = getenv ("PIXEL_SIZE");
nchars++;
*/
for (i = 0; i < 0x10000; i++)
- if ((unicode_table[i] = FT_Get_Char_Index (face, (FT_ULong) i)))
- {
- if (! FT_Load_Glyph (face, unicode_table[i],
- FT_LOAD_RENDER | FT_LOAD_MONOCHROME)
- && face->glyph->bitmap.rows * face->glyph->bitmap.width)
- nchars++;
- else
- unicode_table[i] = 0;
- }
-
- dump_header (face, "SuperSoft", nchars, pixel_size);
- for (i = 0; i < 0x10000; i++)
- if (unicode_table[i])
- dump_image (pixel_size, unicode_table[i], i, 1);
- /*
+ {
+ if (platform_id >= 0)
+ {
+ code_table[i] = FT_Get_Char_Index (face, (FT_ULong) i);
+ if (! code_table[i])
+ {
+ code_table[i] = -1;
+ continue;
+ }
+ }
+ else
+ {
+ code_table[i] = i;
+ }
+ if (! FT_Load_Glyph (face, code_table[i],
+ FT_LOAD_RENDER | FT_LOAD_MONOCHROME)
+ && face->glyph->bitmap.rows * face->glyph->bitmap.width)
+ nchars++;
+ else
+ code_table[i] = -1;
+ }
+
+ dump_header (face, "unknown", nchars, pixel_size);
for (i = 0; i < 0x10000; i++)
- dump_image (pixel_size, i, 0xE000 + i, 0);
- */
+ if (code_table[i] >= 0)
+ dump_image (pixel_size, code_table[i], i, 1);
dump_tailer ();
exit (0);