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

reencode to unicode full before generating a font, such that FF won't ditch glyphs

This commit is contained in:
Lu Wang 2013-07-05 10:52:31 +08:00
parent 17c351c810
commit 92274d2502
5 changed files with 17 additions and 2 deletions

View File

@ -519,9 +519,13 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
/*
* Step 3
*
* Reencode to Unicode Full such that FontForge won't ditch unicode values larger than 0xFFFF
*
* Generate the font as desired
*
*/
ffw_reencode_unicode_full();
string cur_tmp_fn = (char*)str_fmt("%s/__tmp_font1%s", param.tmp_dir.c_str(), param.font_suffix.c_str());
tmp_files.add(cur_tmp_fn);
string other_tmp_fn = (char*)str_fmt("%s/__tmp_font2%s", param.tmp_dir.c_str(), param.font_suffix.c_str());

View File

@ -67,6 +67,7 @@ struct Param
std::string data_dir;
int css_draw;
int debug;
int wa_unicode;
// non-optional
std::string input_filename, output_filename;

View File

@ -28,6 +28,7 @@ static inline int min(int a, int b)
static FontViewBase * cur_fv = NULL;
static Encoding * original_enc = NULL;
static Encoding * unicodefull_enc = NULL;
static Encoding * enc_head = NULL;
static void err(const char * format, ...)
@ -68,6 +69,7 @@ void ffw_init(int debug)
}
original_enc = FindOrMakeEncoding("original");
unicodefull_enc = FindOrMakeEncoding("UnicodeFull");
{
Val v;
@ -202,6 +204,11 @@ void ffw_reencode_glyph_order(void)
ffw_do_reencode(original_enc, 0);
}
void ffw_reencode_unicode_full(void)
{
ffw_do_reencode(unicodefull_enc, 0);
}
void ffw_reencode(const char * encname, int force)
{
Encoding * enc = FindOrMakeEncoding(encname);
@ -215,8 +222,10 @@ void ffw_reencode_raw(int32 * mapping, int mapping_len, int force)
{
Encoding * enc = calloc(1, sizeof(Encoding));
enc->only_1byte = enc->has_1byte = true;
enc->char_cnt = mapping_len;
enc->unicode = (int32_t*)malloc(mapping_len * sizeof(int32_t));
int len = (mapping_len < 256) ? 256 : mapping_len;
enc->char_cnt = len;
enc->unicode = (int32_t*)malloc(len * sizeof(int32_t));
memcpy(enc->unicode, mapping, mapping_len * sizeof(int32_t));
enc->enc_name = strcopy("");

View File

@ -36,6 +36,7 @@ void ffw_close(void);
////////////////////////
// encoding
void ffw_reencode_glyph_order(void);
void ffw_reencode_unicode_full(void);
void ffw_reencode_raw(int32_t * mapping, int mapping_len, int force);
void ffw_reencode_raw2(char ** mapping, int mapping_len, int force);

0
test/test.py Normal file → Executable file
View File