diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc index b161af6..11202ab 100644 --- a/src/HTMLRenderer/text.cc +++ b/src/HTMLRenderer/text.cc @@ -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) diff --git a/src/ffw.c b/src/ffw.c index 434b9bf..21dbb32 100644 --- a/src/ffw.c +++ b/src/ffw.c @@ -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 diff --git a/src/include/ffw.h b/src/include/ffw.h index d20469a..8c34870 100644 --- a/src/include/ffw.h +++ b/src/include/ffw.h @@ -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); diff --git a/test/test.py b/test/test.py index 3e39e1a..5298d58 100755 --- a/test/test.py +++ b/test/test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python DIR = 'pdf' -DIR = '../../pdf.js/test/pdfs' +#DIR = '../../pdf.js/test/pdfs' import os