1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-08 19:00:33 +00:00

best solution so far, need more check of CID fonts

This commit is contained in:
Lu Wang 2012-08-28 00:14:11 +08:00
parent 28eb708339
commit f460476c0f

View File

@ -202,52 +202,49 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
bool use_tounicode = ((suffix == ".ttf") || (param->always_apply_tounicode)); bool use_tounicode = ((suffix == ".ttf") || (param->always_apply_tounicode));
if(use_tounicode) auto ctu = font->getToUnicode();
ofstream map_fout(tmp_dir / (fn + ".encoding"));
add_tmp_file(fn+".encoding");
int cnt = 0;
for(int i = 0; i <= maxcode; ++i)
{ {
auto ctu = font->getToUnicode(); if((suffix != ".ttf") && (font_8bit != nullptr) && (font_8bit->getCharName(i) == nullptr))
continue;
ofstream map_fout(tmp_dir / (fn + ".encoding")); ++ cnt;
add_tmp_file(fn+".encoding"); map_fout << format("0x%|1$X|") % ((code2GID && (i < code2GID_len))? code2GID[i] : i);
int cnt = 0; Unicode u, *pu=&u;
for(int i = 0; i <= maxcode; ++i)
if(use_tounicode)
{ {
if((suffix != ".ttf") && (font_8bit != nullptr) && (font_8bit->getCharName(i) == nullptr)) int n = 0;
continue; if(ctu)
n = ctu->mapToUnicode(i, &pu);
++ cnt; u = check_unicode(pu, n, i, font);
map_fout << format("0x%|1$X|") % ((code2GID && (i < code2GID_len))? code2GID[i] : i); }
else
Unicode u, *pu=&u; {
u = unicode_from_font(i, font);
if(use_tounicode)
{
int n = 0;
if(ctu)
n = ctu->mapToUnicode(i, &pu);
u = check_unicode(pu, n, i, font);
}
else
{
u = unicode_from_font(i, font);
}
map_fout << format(" 0x%|1$X|") % u;
map_fout << format(" # 0x%|1$X|") % i;
map_fout << endl;
} }
if(cnt > 0) map_fout << format(" 0x%|1$X|") % u;
{ map_fout << format(" # 0x%|1$X|") % i;
script_fout << format("LoadEncodingFile(%1%, \"%2%\")") % (tmp_dir / (fn+".encoding")) % fn << endl;
script_fout << format("Reencode(\"%1%\", 1)") % fn << endl;
}
if(ctu) map_fout << endl;
ctu->decRefCnt();
} }
if(cnt > 0)
{
script_fout << format("LoadEncodingFile(%1%, \"%2%\")") % (tmp_dir / (fn+".encoding")) % fn << endl;
script_fout << format("Reencode(\"%1%\", 1)") % fn << endl;
}
if(ctu)
ctu->decRefCnt();
script_fout << format("Generate(%1%)") % ((param->single_html ? tmp_dir : dest_dir) / (fn+".ttf")) << endl; script_fout << format("Generate(%1%)") % ((param->single_html ? tmp_dir : dest_dir) / (fn+".ttf")) << endl;
if(param->single_html) if(param->single_html)
add_tmp_file(fn+".ttf"); add_tmp_file(fn+".ttf");