1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

use the code2gid table when there is no one embedded

This commit is contained in:
Lu Wang 2013-05-04 02:52:30 +08:00
parent e6ca51087f
commit 8bad93c8e5
2 changed files with 21 additions and 16 deletions

5
TODO
View File

@ -1,9 +1,6 @@
- font issue
- cjkmix2*.pdf
- decision about reencoding external fonts
- pc1.pdf
- jyb.pdf
- SVD.pdf
- smarter space-as-offset
- show hints about possible useful parameters
- optimization levels
- don't dump image when it is empty

View File

@ -236,13 +236,15 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
* re-encoding the font by glyph names
*
* for 8bit + TrueType
* sort the glpyhs as the original order, and later will map GID (instead of char code) to Unicode
* sort the glpyhs as the original order, and load the code2GID table
* later we will map GID (instead of char code) to Unicode
*
* for CID + nonTrueType
* Flatten the font
*
* for CID Truetype
* same as 8bitTrueType, except for that we have to check 65536 charcodes
* use the embedded code2GID table if there is, otherwise use the one in the font
*/
if(font_8bit)
{
@ -305,11 +307,24 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
GfxCIDFont * _font = dynamic_cast<GfxCIDFont*>(font);
// code2GID has been stored for embedded CID fonts
code2GID = _font->getCIDToGID();
// To locate CID2GID for the font
// as in CairoFontEngine.cc
if(code2GID = _font->getCIDToGID())
{
// use the mapping stored in _font
code2GID_len = _font->getCIDToGIDLen();
}
else
{
// use the mapping stored in the file
if(FoFiTrueType * fftt = FoFiTrueType::load((char*)filepath.c_str()))
{
code2GID = _font->getCodeToGIDMap(fftt, &code2GID_len);
delete fftt;
}
}
}
else
{
ffw_cidflatten();
}
@ -454,13 +469,6 @@ 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);
/*
* Reencoding is not likely to work for external fonts,
* Just hope that we can get correct Unicode values, and let the browser choose the correct glyphs
*
* TODO: maybe add an option here, but anyway according to the DPF spec, this is implement-dependent
*/
// if(info.is_embeded)
ffw_reencode_raw(cur_mapping, max_key + 1, 1);
// In some space offsets in HTML, we insert a ' ' there in order to improve text copy&paste