1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 13:00:08 +00:00

remove alternate unicodes

This commit is contained in:
Lu Wang 2012-10-06 19:20:35 +08:00
parent b2633ffc1b
commit 7664fb5a79
4 changed files with 44 additions and 18 deletions

View File

@ -166,12 +166,13 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
}
ffw_load_font(filepath.c_str());
ffw_prepare_font();
if(param->debug)
{
auto fn = str_fmt("%s/__raw_font_%lld%s", param->tmp_dir.c_str(), info.id, param->font_suffix.c_str());
auto fn = str_fmt("%s/__raw_font_%lld", param->tmp_dir.c_str(), info.id, param->font_suffix.c_str());
add_tmp_file((char*)fn);
ffw_save((char*)fn);
ofstream((char*)fn, ofstream::binary) << ifstream(filepath).rdbuf();
}
int * code2GID = nullptr;
@ -406,6 +407,7 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
}
ffw_set_widths(width_list, max_key + 1, param->stretch_narrow_glyph, param->squeeze_wide_glyph, param->remove_unused_glyph);
ffw_reencode_raw(cur_mapping, max_key + 1, 1);
if(ctu)

View File

@ -48,13 +48,9 @@ static char * strcopy(const char * str)
return _;
}
static void dumb_logwarning(const char * format, ...)
{
}
static void dumb_logwarning(const char * format, ...) { }
static void dumb_post_error(const char * title, const char * error, ...)
{
}
static void dumb_post_error(const char * title, const char * error, ...) { }
void ffw_init(int debug)
{
@ -118,6 +114,41 @@ void ffw_load_font(const char * filename)
cur_fv = font->fv;
}
/*
* Fight again dirty stuffs
*/
void ffw_prepare_font(void)
{
/*
* Disabled, because it causes crashing
memset(cur_fv->selected, 1, cur_fv->map->enccount);
// remove kern
FVRemoveKerns(cur_fv);
FVRemoveVKerns(cur_fv);
*/
/*
* Remove Alternate Unicodes
* We never use them because we will do a force encoding
*/
int i;
SplineFont * sf = cur_fv->sf;
for(i = 0; i < sf->glyphcnt; ++i)
{
SplineChar * sc = sf->glyphs[i];
if(sc)
{
struct altuni * p = sc->altuni;
if(p)
{
AltUniFree(p);
sc->altuni = NULL;
}
}
}
}
static void ffw_do_reencode(Encoding * encoding, int force)
{
assert(encoding);
@ -295,20 +326,12 @@ void ffw_metric(double * ascent, double * descent)
/*
* TODO:bitmap, reference have not been considered in this function
* TODO:remove_unused may not be suitable to be done here
*/
void ffw_set_widths(int * width_list, int mapping_len,
int stretch_narrow, int squeeze_wide,
int remove_unused)
{
/*
* Disabled, because it causes crashing
memset(cur_fv->selected, 1, cur_fv->map->enccount);
// remove kern
FVRemoveKerns(cur_fv);
FVRemoveVKerns(cur_fv);
*/
SplineFont * sf = cur_fv->sf;
if(sf->onlybitmaps

View File

@ -23,6 +23,7 @@ extern "C" {
void ffw_init(int debug);
void ffw_fin(void);
void ffw_load_font(const char * filename);
void ffw_prepare_font(void);
void ffw_reencode_glyph_order(void);
void ffw_reencode_raw(int32_t * mapping, int mapping_len, int force);
void ffw_reencode_raw2(char ** mapping, int mapping_len, int force);

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python
DIR = 'pdf'
DIR = '../../pdf.js/test/pdfs'
#DIR = '../../pdf.js/test/pdfs'
import os