mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-07-08 19:00:33 +00:00
working on width for CID fonts
This commit is contained in:
parent
cf1c1a2108
commit
1aebc73818
|
@ -177,16 +177,24 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
|
||||||
*iter = tolower(*iter);
|
*iter = tolower(*iter);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
* TODO
|
||||||
* if parm->tounicode is 0, try the provided tounicode map first
|
* if parm->tounicode is 0, try the provided tounicode map first
|
||||||
*/
|
*/
|
||||||
info.use_tounicode = (is_truetype_suffix(suffix) || (param->tounicode >= 0));
|
info.use_tounicode = (is_truetype_suffix(suffix) || (param->tounicode > 0));
|
||||||
info.has_space = false;
|
info.has_space = false;
|
||||||
|
|
||||||
const char * used_map = nullptr;
|
const char * used_map = nullptr;
|
||||||
|
|
||||||
ffw_metric(&info.ascent, &info.descent, &info.em_size);
|
ffw_metric(&info.ascent, &info.descent, &info.em_size);
|
||||||
if(!get_metric_only)
|
|
||||||
|
if(param->debug)
|
||||||
{
|
{
|
||||||
|
cerr << "Ascent: " << info.ascent << " Descent: " << info.descent << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(get_metric_only)
|
||||||
|
return;
|
||||||
|
|
||||||
used_map = font_preprocessor.get_code_map(hash_ref(font->getID()));
|
used_map = font_preprocessor.get_code_map(hash_ref(font->getID()));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -300,7 +308,7 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
|
||||||
|
|
||||||
auto ctu = font->getToUnicode();
|
auto ctu = font->getToUnicode();
|
||||||
memset(cur_mapping, -1, 0x10000 * sizeof(*cur_mapping));
|
memset(cur_mapping, -1, 0x10000 * sizeof(*cur_mapping));
|
||||||
memset(width_list, -1, 0x1000 * sizeof(*width_list));
|
memset(width_list, -1, 0x10000 * sizeof(*width_list));
|
||||||
|
|
||||||
if(code2GID)
|
if(code2GID)
|
||||||
maxcode = min(maxcode, code2GID_len - 1);
|
maxcode = min(maxcode, code2GID_len - 1);
|
||||||
|
@ -380,7 +388,6 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
|
||||||
if(ctu)
|
if(ctu)
|
||||||
ctu->decRefCnt();
|
ctu->decRefCnt();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto fn = str_fmt("%s/f%llx%s",
|
auto fn = str_fmt("%s/f%llx%s",
|
||||||
|
@ -392,11 +399,11 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
|
||||||
|
|
||||||
ffw_save((char*)fn);
|
ffw_save((char*)fn);
|
||||||
ffw_close();
|
ffw_close();
|
||||||
}
|
|
||||||
|
|
||||||
if(param->debug)
|
ffw_load_font((char*)fn);
|
||||||
{
|
ffw_metric(&info.ascent, &info.descent, &info.em_size);
|
||||||
cerr << "Ascent: " << info.ascent << " Descent: " << info.descent << endl;
|
ffw_save((char*)fn);
|
||||||
|
ffw_close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
57
src/ffw.c
57
src/ffw.c
|
@ -107,10 +107,6 @@ void ffw_load_font(const char * filename)
|
||||||
assert(font->fv);
|
assert(font->fv);
|
||||||
|
|
||||||
cur_fv = font->fv;
|
cur_fv = font->fv;
|
||||||
|
|
||||||
SFDefaultOS2Info(&font->pfminfo, font, font->fontname);
|
|
||||||
font->pfminfo.pfmset = 1;
|
|
||||||
font->changed = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ffw_do_reencode(Encoding * encoding, int force)
|
static void ffw_do_reencode(Encoding * encoding, int force)
|
||||||
|
@ -222,16 +218,18 @@ void ffw_close(void)
|
||||||
void ffw_metric(double * ascent, double * descent, int * em_size)
|
void ffw_metric(double * ascent, double * descent, int * em_size)
|
||||||
{
|
{
|
||||||
SplineFont * sf = cur_fv->sf;
|
SplineFont * sf = cur_fv->sf;
|
||||||
|
struct pfminfo * info = &sf->pfminfo;
|
||||||
|
|
||||||
|
SFDefaultOS2Info(info, sf, sf->fontname);
|
||||||
|
info->pfmset = 1;
|
||||||
|
sf->changed = 1;
|
||||||
|
|
||||||
DBounds bb;
|
DBounds bb;
|
||||||
SplineFontFindBounds(sf, &bb);
|
SplineFontFindBounds(sf, &bb);
|
||||||
|
|
||||||
struct pfminfo * info = &sf->pfminfo;
|
|
||||||
|
|
||||||
*em_size = sf->ascent + sf->descent;
|
*em_size = sf->ascent + sf->descent;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
//debug
|
|
||||||
printf("bb %lf %lf\n", bb.maxy, bb.miny);
|
printf("bb %lf %lf\n", bb.maxy, bb.miny);
|
||||||
printf("_ %d %d\n", sf->ascent, sf->descent);
|
printf("_ %d %d\n", sf->ascent, sf->descent);
|
||||||
printf("win %d %d\n", info->os2_winascent, info->os2_windescent);
|
printf("win %d %d\n", info->os2_winascent, info->os2_windescent);
|
||||||
|
@ -254,22 +252,28 @@ void ffw_metric(double * ascent, double * descent, int * em_size)
|
||||||
*ascent = *descent = 0;
|
*ascent = *descent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sf->ascent = min(floor(bb.maxy+0.5), em);
|
int a = floor(bb.maxy + 0.5);
|
||||||
|
int d = floor(bb.miny + 0.5);
|
||||||
|
|
||||||
|
if(a < 0) a = 0;
|
||||||
|
if(d > 0) d = 0;
|
||||||
|
|
||||||
|
sf->ascent = min(a, em);
|
||||||
sf->descent = em - bb.maxy;
|
sf->descent = em - bb.maxy;
|
||||||
|
|
||||||
info->os2_winascent = 0;
|
info->os2_winascent = a;
|
||||||
info->os2_typoascent = 0;
|
info->os2_typoascent = a;
|
||||||
info->hhead_ascent = 0;
|
info->hhead_ascent = a;
|
||||||
info->winascent_add = 1;
|
info->winascent_add = 0;
|
||||||
info->typoascent_add = 1;
|
info->typoascent_add = 0;
|
||||||
info->hheadascent_add = 1;
|
info->hheadascent_add = 0;
|
||||||
|
|
||||||
info->os2_windescent = 0;
|
info->os2_windescent = -d;
|
||||||
info->os2_typodescent = 0;
|
info->os2_typodescent = d;
|
||||||
info->hhead_descent = 0;
|
info->hhead_descent = d;
|
||||||
info->windescent_add = 1;
|
info->windescent_add = 0;
|
||||||
info->typodescent_add = 1;
|
info->typodescent_add = 0;
|
||||||
info->hheaddescent_add = 1;
|
info->hheaddescent_add = 0;
|
||||||
|
|
||||||
info->os2_typolinegap = 0;
|
info->os2_typolinegap = 0;
|
||||||
info->linegap = 0;
|
info->linegap = 0;
|
||||||
|
@ -282,14 +286,21 @@ void ffw_set_widths(int * width_list, int mapping_len)
|
||||||
{
|
{
|
||||||
SplineFont * sf = cur_fv->sf;
|
SplineFont * sf = cur_fv->sf;
|
||||||
|
|
||||||
|
if(sf->onlybitmaps
|
||||||
|
&& cur_fv->active_bitmap != NULL
|
||||||
|
&& sf->bitmaps != NULL)
|
||||||
|
{
|
||||||
|
printf("TODO: width vs bitmap\n");
|
||||||
|
}
|
||||||
|
|
||||||
EncMap * map = cur_fv->map;
|
EncMap * map = cur_fv->map;
|
||||||
int i;
|
int i;
|
||||||
int imax = min(mapping_len, map->enccount);
|
int imax = min(mapping_len, map->enccount);
|
||||||
for(i = 0; i < imax; ++i)
|
for(i = 0; i < imax; ++i)
|
||||||
{
|
{
|
||||||
// TODO why need this
|
/*
|
||||||
// when width_list[i] == -1, the code itself should be unused.
|
* Do mess with it if the glyphs is not used.
|
||||||
// but might be reference within ttf etc
|
*/
|
||||||
if(width_list[i] == -1) continue;
|
if(width_list[i] == -1) continue;
|
||||||
|
|
||||||
int j = map->map[i];
|
int j = map->map[i];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user