rtoss

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/ @ 318  →  / @ 319
/bdf2ttf/src/main.c
@@ -14,6 +14,7 @@
#include "bdf.h"
#include "bdf2ttf.h"
#include "debug.h"
#include "version.h"
 
int
main(int argc, char** argv)
@@ -66,6 +67,7 @@
}
 
if (argc < 3) {
printf("bdf2ttf " VERSION "\n");
printf("Usage: %s [flags] {outname} {info} {infile} [infiles..]\n", progname);
goto FINISH;
}
/bdf2ttf/src/version.h
@@ -10,7 +10,7 @@
#define VERSION_H
 
#define COPYRIGHT "(C) 2003 KaoriYa";
#define VERSION "2.0"
#define VERSION "2.0.1"
#define TRADEMARK "KaoriYa"
#define VENDORID "KRN "
 
/bdf2ttf/src/bdf.c
@@ -52,6 +52,7 @@
{ "JISX0208", 2 },
{ "JISX0212", 2 },
{ "JISX0213", 2 },
{ "KSX1001", 2 },
{ NULL, 0 },
};
 
@@ -222,9 +223,9 @@
}
 
static char*
parse_FONT(char* cmd)
parse_FONT_backend(char* cmd, int c)
{
int c = 13;
/* int c = 13; */
int len;
 
while (c && *cmd)
@@ -261,6 +262,32 @@
return cmd;
}
 
static char*
parse_FONT(char* cmd)
{
return parse_FONT_backend(cmd, 13);
}
 
static char*
removeQuote(char* str)
{
size_t len;
char *noQuotes;
size_t i, j;
len = strlen(str);
j = 0;
noQuotes = (char*)malloc(str);
if(str[0] != '"') {
noQuotes[j++] = str[0];
}
for(i = 1; i < len; i++){
if(str[i] == '"' && str[i-1] != '\\')
continue;
noQuotes[j++] = str[i];
}
return noQuotes;
}
 
static ucsconv_t*
init_conv(char* encname, ucsconv_t** pconv)
{
@@ -357,7 +384,7 @@
{
width_table_t *p;
 
TRACE("bdf_load: encoding is %s\n", cmd);
TRACE("bdf_load: [#F] encoding is %s\n", cmd);
init_conv(cmd, &conv);
for (p = cell_width_table; p->name != NULL; ++p)
if (strcmp(p->name, cmd) == 0)
@@ -367,10 +394,35 @@
}
else if (conv)
{
ucsconv_close(conv);
conv = NULL;
TRACE("bdf_load: disable usc #F\n");
ucsconv_close(conv);
conv = NULL;
}
}
else if (cmd = iscmd(buf, "CHARSET_REGISTRY"))
{
char* charset_name = removeQuote(cmd);
TRACE("bdf_load: get CHARSET_REGISTRY = %s\n", charset_name);
if ((cmd = parse_FONT_backend(charset_name, 0)) && !conv)
{
width_table_t *p;
 
TRACE("bdf_load: [#CR] encoding is %s\n", cmd);
init_conv(cmd, &conv);
for (p = cell_width_table; p->name != NULL; ++p)
if (strcmp(p->name, cmd) == 0)
break;
if (p->name != NULL)
cell_width = p->width;
}
/*else if (conv)
{
TRACE("bdf_load: disable usc #CR\n");
ucsconv_close(conv);
conv = NULL;
}*/
free(charset_name);
}
else if (cmd = iscmd(buf, "FONT_ASCENT"))
font->ascent = atoi(cmd);
else if (cmd = iscmd(buf, "FONT_DESCENT"))
@@ -387,6 +439,7 @@
glyph_close(font->glyph[encnum]);
font->glyph[encnum] = ptmp;
//font->cell_width[encnum] = cell_width;
font->glyph_dwidth[encnum] = ptmp->dwidth.x;
font->cell_width[encnum] = ptmp->dwidth.x > (font->size / 2)
? 2 : 1;
}
@@ -421,6 +474,10 @@
if (conv)
{
int convnum = (int)ucsconv_toUCS(conv, (ucschar_t)encnum);
#if 0
TRACE("bdf_load: ucs %04x => %04x\n", encnum, convnum);
#endif
 
if (convnum)
encnum = convnum;
else
@@ -672,6 +729,11 @@
qsort((void*)font->sizelist, font->count, sizeof(int), numsort);
}
 
bdf = bdf2_get_bdf1(font, font->sizelist[0]);
font->bboxX = bdf->bbx.width;
for (i = 0; i < BDF_MAX_GLYPH; ++i)
font->glyph_dwidth[i] = bdf->glyph_dwidth[i];
 
#ifndef USE_FLEXIBLE_GLYPHWIDTH
/* Chech cell width */
for (i = 0; i < font->count; ++i)
@@ -777,6 +839,15 @@
return font->glyph_width[id];
}
 
unsigned char
bdf2_get_glyph_dwidth(bdf2_t* font, int id)
{
if (id < 0 || id >= BDF_MAX_GLYPH)
return 0;
else
return font->glyph_dwidth[id];
}
 
int
bdf2_is_glyph_available(bdf2_t* font, int id)
{
/bdf2ttf/src/bdf2ttf.cpp
@@ -536,11 +536,11 @@
int d = -bdf->descent;
#else
int a = width;
int d = height;
int d = 0;
#endif
int s = origsize;
add_sbitLineMetric(eblc, a, d, s, 1, 0, 0, 0, s, a, d, 0, 0);
//TRACE("w=%d h=%d ascent=%d descent=%d origsize=%d\n", width, height, bdf->ascent, bdf->descent, origsize);
TRACE("w=%d h=%d ascent=%d descent=%d origsize=%d\n", width, height, bdf->ascent, bdf->descent, origsize);
// sbitLineMetrics: vert
add_sbitLineMetric(eblc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
 
@@ -960,7 +960,7 @@
{
if (!bdf2_is_glyph_available(font, i))
continue;
tmp->addShort(emCalc(bdf2_get_glyph_width(font, i), 2));
tmp->addShort(emCalc(bdf2_get_glyph_dwidth(font, i), font->bboxX));
tmp->addShort(0);
}
tmp->calcSum();
/bdf2ttf/src/bdf.h
@@ -44,6 +44,7 @@
bdf_boundingbox_t bbx;
bdf_glyph_t* glyph[BDF_MAX_GLYPH];
unsigned char cell_width[BDF_MAX_GLYPH];
unsigned char glyph_dwidth[BDF_MAX_GLYPH];
 
int numGlyph;
int indexFirst;
@@ -97,6 +98,8 @@
int glyph_id[BDF_MAX_GLYPH];
unsigned char glyph_flag[BDF_MAX_GLYPH];
unsigned char glyph_width[BDF_MAX_GLYPH];
unsigned char glyph_dwidth[BDF_MAX_GLYPH];
int bboxX;
int numGlyph;
int indexFirst;
int indexLast;
@@ -121,6 +124,7 @@
int bdf2_get_glyph_id(bdf2_t* font, int id);
unsigned char bdf2_get_glyph_flag(bdf2_t* font, int id);
unsigned char bdf2_get_glyph_width(bdf2_t* font, int id);
unsigned char bdf2_get_glyph_dwidth(bdf2_t* font, int id);
int bdf2_is_glyph_available(bdf2_t* font, int id);
 
#ifdef __cplusplus
/bdf2ttf/src/ucsconv.c
@@ -85,6 +85,9 @@
int
ucsconv_load(ucsconv_t* conv, char *filename)
{
#if 0
printf("ucsconv: loading %s\n", filename);
#endif
if (conv)
{
FILE *fp = fopen((filename), "rt");