2002-03-10 00:29:33 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2001 Ian Pilcher
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*/
|
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The array of glyph information
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int UV;
|
|
|
|
int index; /* in PSDRV_AGLGlyphNames */
|
|
|
|
const char *name;
|
|
|
|
const char *comment;
|
|
|
|
|
|
|
|
} GLYPHINFO;
|
|
|
|
|
|
|
|
static GLYPHINFO glyphs[1500];
|
|
|
|
static int num_glyphs = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Functions to search and sort the array
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
static int cmp_by_UV(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
return ((const GLYPHINFO *)a)->UV - ((const GLYPHINFO *)b)->UV;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cmp_by_name(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
return strcmp(((const GLYPHINFO *)a)->name, ((const GLYPHINFO *)b)->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static void sort_by_UV()
|
|
|
|
{
|
|
|
|
qsort(glyphs, num_glyphs, sizeof(GLYPHINFO), cmp_by_UV);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static void sort_by_name()
|
|
|
|
{
|
|
|
|
qsort(glyphs, num_glyphs, sizeof(GLYPHINFO), cmp_by_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static GLYPHINFO *search_by_name(const char *name)
|
|
|
|
{
|
|
|
|
GLYPHINFO gi;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
gi.name = name;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
return (GLYPHINFO *)bsearch(&gi, glyphs, num_glyphs, sizeof(GLYPHINFO),
|
|
|
|
cmp_by_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Use the 'optimal' combination of tabs and spaces to position the cursor
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
inline static void fcpto(FILE *f, int newpos, int curpos)
|
|
|
|
{
|
|
|
|
int newtpos = newpos & ~7;
|
|
|
|
int curtpos = curpos & ~7;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
while (curtpos < newtpos)
|
|
|
|
{
|
|
|
|
fputc('\t', f);
|
|
|
|
curtpos += 8;
|
|
|
|
curpos = curtpos;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
while (curpos < newpos)
|
|
|
|
{
|
|
|
|
fputc(' ', f);
|
|
|
|
++curpos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static void cpto(int newpos, int curpos)
|
|
|
|
{
|
|
|
|
fcpto(stdout, newpos, curpos);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make main() look "purty"
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
inline static void double_space(FILE *f)
|
|
|
|
{
|
|
|
|
fputc('\n', f);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static void triple_space(FILE *f)
|
|
|
|
{
|
|
|
|
fputc('\n', f); fputc('\n', f);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the Adobe Glyph List from 'glyphlist.txt'
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
static void read_agl()
|
|
|
|
{
|
|
|
|
FILE *f = fopen("glyphlist.txt", "r");
|
|
|
|
char linebuf[256], namebuf[128], commbuf[128];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (f == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error opening glyphlist.txt\n");
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
while (fgets(linebuf, sizeof(linebuf), f) != NULL)
|
|
|
|
{
|
|
|
|
unsigned int UV;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (linebuf[0] == '#')
|
|
|
|
continue;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
sscanf(linebuf, "%X;%[^;];%[^\n]", &UV, namebuf, commbuf);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
glyphs[num_glyphs].UV = (int)UV;
|
|
|
|
glyphs[num_glyphs].name = strdup(namebuf);
|
|
|
|
glyphs[num_glyphs].comment = strdup(commbuf);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (glyphs[num_glyphs].name == NULL ||
|
|
|
|
glyphs[num_glyphs].comment == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Memory allocation failure\n");
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
++num_glyphs;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
fclose(f);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (num_glyphs != 1051)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Read %i glyphs\n", num_glyphs);
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read glyph names from all AFM files in current directory
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
static void read_afms(FILE *f_c, FILE *f_h)
|
2001-05-30 00:06:10 +02:00
|
|
|
{
|
|
|
|
DIR *d = opendir(".");
|
|
|
|
struct dirent *de;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
fputs( "/*\n"
|
|
|
|
" * Built-in font metrics\n"
|
|
|
|
" */\n"
|
|
|
|
"\n"
|
2001-07-24 23:40:15 +02:00
|
|
|
"const AFM *const PSDRV_BuiltinAFMs[] =\n"
|
2001-07-23 01:43:51 +02:00
|
|
|
"{\n", f_c);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (d == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error opening current directory\n");
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
while ((de = readdir(d)) != NULL)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char *cp, linebuf[256], font_family[128];
|
|
|
|
int i, num_metrics;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
cp = strrchr(de->d_name, '.'); /* Does it end in */
|
|
|
|
if (cp == NULL || strcasecmp(cp, ".afm") != 0) /* .afm or .AFM? */
|
|
|
|
continue;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
f = fopen(de->d_name, "r");
|
|
|
|
if (f == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error opening %s\n", de->d_name);
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (fgets(linebuf, sizeof(linebuf), f) == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "FontName not found in %s\n", de->d_name);
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
if (strncmp(linebuf, "FontName ", 9) == 0)
|
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
sscanf(linebuf, "FontName %[^\r\n]", font_family);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
for (i = 0; font_family[i] != '\0'; ++i)
|
|
|
|
if (font_family[i] == '-')
|
|
|
|
font_family[i] = '_';
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-24 23:40:15 +02:00
|
|
|
fprintf(f_h, "extern const AFM PSDRV_%s;\n", font_family);
|
2001-07-23 01:43:51 +02:00
|
|
|
fprintf(f_c, " &PSDRV_%s,\n", font_family);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (fgets(linebuf, sizeof(linebuf), f) == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "FamilyName not found in %s\n", de->d_name);
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (strncmp(linebuf, "FamilyName ", 11) == 0)
|
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
sscanf(linebuf, "FamilyName %[^\r\n]", font_family);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (fgets(linebuf, sizeof(linebuf), f) == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "StartCharMetrics not found in %s\n",
|
|
|
|
de->d_name);
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (strncmp(linebuf, "StartCharMetrics ", 17) == 0)
|
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
sscanf(linebuf, "StartCharMetrics %i", &num_metrics);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
for (i = 0; i < num_metrics; ++i)
|
|
|
|
{
|
|
|
|
char namebuf[128];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (fgets(linebuf, sizeof(linebuf), f) == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Unexpected EOF after %i glyphs in %s\n", i,
|
|
|
|
de->d_name);
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
cp = strchr(linebuf, 'N');
|
|
|
|
if (cp == NULL || strlen(cp) < 3)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Parse error after %i glyphs in %s\n", i,
|
|
|
|
de->d_name);
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
sscanf(cp, "N %s", namebuf);
|
|
|
|
if (search_by_name(namebuf) != NULL)
|
|
|
|
continue;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
sprintf(linebuf, "FONT FAMILY;%s", font_family);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
glyphs[num_glyphs].UV = -1;
|
|
|
|
glyphs[num_glyphs].name = strdup(namebuf);
|
|
|
|
glyphs[num_glyphs].comment = strdup(linebuf);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (glyphs[num_glyphs].name == NULL ||
|
|
|
|
glyphs[num_glyphs].comment == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Memory allocation failure\n");
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
++num_glyphs;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
sort_by_name();
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
fclose(f);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
closedir(d);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
fputs(" NULL\n};\n", f_c);
|
2001-05-30 00:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write opening comments, etc.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
static void write_header(FILE *f)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
fputc('/', f);
|
|
|
|
for (i = 0; i < 79; ++i)
|
|
|
|
fputc('*', f);
|
|
|
|
fputs("\n"
|
|
|
|
" *\n"
|
2001-07-23 01:43:51 +02:00
|
|
|
" *\tFont and glyph data for the Wine PostScript driver\n"
|
2001-05-30 00:06:10 +02:00
|
|
|
" *\n"
|
|
|
|
" *\tCopyright 2001 Ian Pilcher\n"
|
|
|
|
" *\n"
|
|
|
|
" *\n"
|
|
|
|
" *\tThis data is derived from the Adobe Glyph list at\n"
|
|
|
|
" *\n"
|
|
|
|
" *\t "
|
|
|
|
"http://partners.adobe.com/asn/developer/type/glyphlist.txt\n"
|
|
|
|
" *\n"
|
|
|
|
" *\tand the Adobe Font Metrics files at\n"
|
|
|
|
" *\n"
|
|
|
|
" *\t "
|
|
|
|
"ftp://ftp.adobe.com/pub/adobe/type/win/all/afmfiles/base35/\n"
|
|
|
|
" *\n"
|
|
|
|
" *\twhich are Copyright 1985-1998 Adobe Systems Incorporated.\n"
|
|
|
|
" *\n"
|
|
|
|
" */\n"
|
|
|
|
"\n"
|
2001-07-23 01:43:51 +02:00
|
|
|
"#include \"psdrv.h\"\n"
|
|
|
|
"#include \"data/agl.h\"\n", f);
|
2001-05-30 00:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-07-23 01:43:51 +02:00
|
|
|
* Write the array of glyph names (also populates indexes)
|
2001-05-30 00:06:10 +02:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
static void write_glyph_names(FILE *f_c, FILE *f_h)
|
2001-05-30 00:06:10 +02:00
|
|
|
{
|
2001-07-23 19:48:51 +02:00
|
|
|
int i, num_names = 0, index = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
for (i = 0; i < num_glyphs; ++i)
|
|
|
|
if (i == 0 || strcmp(glyphs[i - 1].name, glyphs[i].name) != 0)
|
|
|
|
++num_names;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
fputs( "/*\n"
|
2001-07-23 01:43:51 +02:00
|
|
|
" * Every glyph name in the AGL and the 35 core PostScript fonts\n"
|
2001-05-30 00:06:10 +02:00
|
|
|
" */\n"
|
2001-07-23 01:43:51 +02:00
|
|
|
"\n", f_c);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
fprintf(f_c, "const INT PSDRV_AGLGlyphNamesSize = %i;\n\n", num_names);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
fprintf(f_c, "GLYPHNAME PSDRV_AGLGlyphNames[%i] =\n{\n", num_names);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
for (i = 0; i < num_glyphs - 1; ++i)
|
|
|
|
{
|
|
|
|
int cp = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (i == 0 || strcmp(glyphs[i - 1].name, glyphs[i].name) != 0)
|
|
|
|
{
|
2001-07-23 01:43:51 +02:00
|
|
|
fcpto(f_h, 32, fprintf(f_h, "#define GN_%s", glyphs[i].name));
|
|
|
|
fprintf(f_h, "(PSDRV_AGLGlyphNames + %i)\n", index);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 19:48:51 +02:00
|
|
|
cp = fprintf(f_c, " { %4i, \"%s\" },", index, glyphs[i].name);
|
2001-05-30 00:06:10 +02:00
|
|
|
glyphs[i].index = index;
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-23 01:43:51 +02:00
|
|
|
glyphs[i].index = glyphs[i - 1].index;
|
2001-05-30 00:06:10 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 19:48:51 +02:00
|
|
|
fcpto(f_c, 40, cp);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
fprintf(f_c, "/* %s */\n", glyphs[i].comment);
|
2001-05-30 00:06:10 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
fcpto(f_h, 32, fprintf(f_h, "#define GN_%s", glyphs[i].name));
|
|
|
|
fprintf(f_h, "(PSDRV_AGLGlyphNames + %i)\n", index);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
glyphs[i].index = index;
|
2001-07-23 19:48:51 +02:00
|
|
|
fcpto(f_c, 40, fprintf(f_c, " { %4i, \"%s\" }", index, glyphs[i].name));
|
2001-07-23 01:43:51 +02:00
|
|
|
fprintf(f_c, "/* %s */\n};\n", glyphs[i].comment);
|
2001-05-30 00:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2001-07-23 01:43:51 +02:00
|
|
|
* Write the AGL encoding vector, sorted by glyph name
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void write_encoding_by_name(FILE *f)
|
|
|
|
{
|
|
|
|
int i, size = 0, even = 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
for (i = 0; i < num_glyphs; ++i)
|
|
|
|
if (glyphs[i].UV != -1 &&
|
|
|
|
(i == 0 || strcmp(glyphs[i - 1].name, glyphs[i].name) != 0))
|
|
|
|
++size; /* should be 1039 */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
fputs( "/*\n"
|
|
|
|
" * The AGL encoding vector, sorted by glyph name - "
|
|
|
|
"duplicates omitted\n"
|
|
|
|
" */\n"
|
|
|
|
"\n", f);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
fprintf(f, "const INT PSDRV_AGLbyNameSize = %i;\n\n", size);
|
2002-06-01 01:06:46 +02:00
|
|
|
fprintf(f, "const UNICODEGLYPH PSDRV_AGLbyName[%i] =\n{\n", size);
|
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
for (i = 0; i < num_glyphs - 1; ++i)
|
|
|
|
{
|
|
|
|
int cp;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
if (glyphs[i].UV == -1)
|
|
|
|
continue;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
if (i != 0 && strcmp(glyphs[i - 1].name, glyphs[i].name) == 0)
|
|
|
|
continue;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
cp = fprintf(f, " { 0x%.4x, GN_%s },", glyphs[i].UV, glyphs[i].name);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
even = !even;
|
|
|
|
if (even)
|
|
|
|
fputc('\n', f);
|
|
|
|
else
|
|
|
|
fcpto(f, 40, cp);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
fprintf(f, " { 0x%.4x, GN_%s }\n};\n", glyphs[i].UV, glyphs[i].name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write the AGL encoding vector, sorted by Unicode value
|
2001-05-30 00:06:10 +02:00
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
static void write_encoding_by_UV(FILE *f)
|
2001-05-30 00:06:10 +02:00
|
|
|
{
|
2001-07-23 01:43:51 +02:00
|
|
|
int i, size = 0, even = 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
for (i = 0; i < num_glyphs; ++i)
|
|
|
|
if (glyphs[i].UV != -1)
|
|
|
|
++size; /* better be 1051! */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
sort_by_UV();
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
fputs( "/*\n"
|
2001-07-23 01:43:51 +02:00
|
|
|
" * The AGL encoding vector, sorted by Unicode value - "
|
|
|
|
"duplicates included\n"
|
2001-05-30 00:06:10 +02:00
|
|
|
" */\n"
|
|
|
|
"\n", f);
|
2001-07-23 01:43:51 +02:00
|
|
|
|
|
|
|
fprintf(f, "const INT PSDRV_AGLbyUVSize = %i;\n\n", size);
|
2002-06-01 01:06:46 +02:00
|
|
|
fprintf(f, "const UNICODEGLYPH PSDRV_AGLbyUV[%i] =\n{\n", size);
|
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
for (i = 0; i < num_glyphs - 1; ++i)
|
|
|
|
{
|
2001-07-23 01:43:51 +02:00
|
|
|
int cp;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
if (glyphs[i].UV == -1)
|
|
|
|
continue;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
cp = fprintf(f, " { 0x%.4x, GN_%s },", glyphs[i].UV, glyphs[i].name);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
even = !even;
|
|
|
|
if (even)
|
|
|
|
fputc('\n', f);
|
|
|
|
else
|
|
|
|
fcpto(f, 40, cp);
|
2001-05-30 00:06:10 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
fprintf(f, " { 0x%.4x, GN_%s }\n};\n", glyphs[i].UV, glyphs[i].name);
|
2001-05-30 00:06:10 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Do it!
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2001-07-23 01:43:51 +02:00
|
|
|
FILE *f_c, *f_h;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
if (argc < 3)
|
2001-05-30 00:06:10 +02:00
|
|
|
{
|
2001-07-23 01:43:51 +02:00
|
|
|
fprintf(stderr, "Usage: %s <C file> <header file>\n", argv[0]);
|
|
|
|
exit(__LINE__);
|
2001-05-30 00:06:10 +02:00
|
|
|
}
|
2001-07-23 01:43:51 +02:00
|
|
|
|
|
|
|
f_c = fopen(argv[1], "w");
|
|
|
|
if (f_c == NULL)
|
2001-05-30 00:06:10 +02:00
|
|
|
{
|
2001-07-23 01:43:51 +02:00
|
|
|
fprintf(stderr, "Error opening %s for writing\n", argv[1]);
|
|
|
|
exit(__LINE__);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
f_h = fopen(argv[2], "w");
|
|
|
|
if (f_h == NULL)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Error opening %s for writing\n", argv[2]);
|
|
|
|
exit(__LINE__);
|
2001-05-30 00:06:10 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-07-23 01:43:51 +02:00
|
|
|
write_header(f_c);
|
|
|
|
triple_space(f_c);
|
|
|
|
read_agl();
|
|
|
|
read_afms(f_c, f_h); /* also writes font list */
|
|
|
|
triple_space(f_c);
|
|
|
|
write_glyph_names(f_c, f_h);
|
|
|
|
triple_space(f_c);
|
|
|
|
write_encoding_by_name(f_c);
|
|
|
|
triple_space(f_c);
|
|
|
|
write_encoding_by_UV(f_c);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-05-30 00:06:10 +02:00
|
|
|
return 0;
|
|
|
|
}
|