mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
fixed a encoding bug
This commit is contained in:
parent
96a87f8976
commit
5986cee893
@ -198,7 +198,7 @@ void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo &
|
||||
maxcode = 0xff;
|
||||
if((suffix == ".ttf") || (suffix == ".ttc") || (suffix == ".otf"))
|
||||
{
|
||||
ff_reencode("original", 0);
|
||||
ff_reencode_glyph_order();
|
||||
FoFiTrueType *fftt = nullptr;
|
||||
if((fftt = FoFiTrueType::load((char*)filepath.c_str())) != nullptr)
|
||||
{
|
||||
@ -250,7 +250,7 @@ void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo &
|
||||
|
||||
if(suffix == ".ttf")
|
||||
{
|
||||
ff_reencode("original", 0);
|
||||
ff_reencode_glyph_order();
|
||||
|
||||
GfxCIDFont * _font = dynamic_cast<GfxCIDFont*>(font);
|
||||
|
||||
@ -281,11 +281,11 @@ void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo &
|
||||
auto ctu = font->getToUnicode();
|
||||
memset(cur_mapping, 0, maxcode * sizeof(int32_t));
|
||||
|
||||
ofstream _out(tmp_dir / (fn+".map"));
|
||||
|
||||
if(code2GID)
|
||||
maxcode = min(maxcode, code2GID_len-1);
|
||||
maxcode = min(maxcode, code2GID_len - 1);
|
||||
|
||||
int max_key = maxcode;
|
||||
for(int i = 0; i <= maxcode; ++i)
|
||||
{
|
||||
if((suffix != ".ttf") && (font_8bit != nullptr) && (font_8bit->getCharName(i) == nullptr))
|
||||
@ -296,10 +296,12 @@ void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo &
|
||||
int k = i;
|
||||
if(code2GID)
|
||||
{
|
||||
if((k = code2GID[i]) == 0)
|
||||
continue;
|
||||
if((k = code2GID[i]) == 0) continue;
|
||||
}
|
||||
|
||||
if(k > max_key)
|
||||
max_key = k;
|
||||
|
||||
Unicode u, *pu=&u;
|
||||
if(info.use_tounicode)
|
||||
{
|
||||
@ -311,12 +313,10 @@ void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo &
|
||||
u = unicode_from_font(i, font);
|
||||
}
|
||||
|
||||
_out << k << ' ' << u << endl;
|
||||
|
||||
cur_mapping[k] = u;
|
||||
}
|
||||
|
||||
ff_reencode_raw(cur_mapping, maxcode, 1);
|
||||
ff_reencode_raw(cur_mapping, max_key + 1, 1);
|
||||
|
||||
if(ctu)
|
||||
ctu->decRefCnt();
|
||||
|
30
src/ff/ff.c
30
src/ff/ff.c
@ -11,6 +11,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <fontforge/config.h>
|
||||
#include <fontforge.h>
|
||||
@ -18,7 +19,8 @@
|
||||
|
||||
#include "ff.h"
|
||||
|
||||
FontViewBase * cur_fv = NULL;
|
||||
static FontViewBase * cur_fv = NULL;
|
||||
static Encoding * original_enc = NULL;
|
||||
|
||||
static void err(const char * format, ...)
|
||||
{
|
||||
@ -60,6 +62,8 @@ void ff_init(void)
|
||||
|
||||
//disable error output of Fontforge
|
||||
ui_interface->logwarning = &dummy;
|
||||
|
||||
original_enc = FindOrMakeEncoding("original");
|
||||
}
|
||||
void ff_load_font(const char * filename)
|
||||
{
|
||||
@ -76,19 +80,10 @@ void ff_load_font(const char * filename)
|
||||
cur_fv = font->fv;
|
||||
}
|
||||
|
||||
/*
|
||||
void ff_load_encoding(const char * filename, const char * encname)
|
||||
{
|
||||
char * _filename = strcopy(filename);
|
||||
char * _encname = strcopy(encname);
|
||||
ParseEncodingFile(_filename, _encname);
|
||||
free(_encname);
|
||||
free(_filename);
|
||||
}
|
||||
*/
|
||||
|
||||
static void ff_do_reencode(Encoding * encoding, int force)
|
||||
{
|
||||
assert(encoding);
|
||||
|
||||
if(force)
|
||||
{
|
||||
SFForceEncoding(cur_fv->sf, cur_fv->map, encoding);
|
||||
@ -96,12 +91,21 @@ static void ff_do_reencode(Encoding * encoding, int force)
|
||||
else
|
||||
{
|
||||
EncMapFree(cur_fv->map);
|
||||
cur_fv->map= EncMapFromEncoding(cur_fv->sf, encoding);
|
||||
cur_fv->map = EncMapFromEncoding(cur_fv->sf, encoding);
|
||||
}
|
||||
if(cur_fv->normal)
|
||||
{
|
||||
EncMapFree(cur_fv->normal);
|
||||
cur_fv->normal = NULL;
|
||||
}
|
||||
|
||||
SFReplaceEncodingBDFProps(cur_fv->sf, cur_fv->map);
|
||||
}
|
||||
|
||||
void ff_reencode_glyph_order(void)
|
||||
{
|
||||
ff_do_reencode(original_enc, 0);
|
||||
}
|
||||
|
||||
void ff_reencode(const char * encname, int force)
|
||||
{
|
||||
|
@ -20,10 +20,7 @@ extern "C" {
|
||||
|
||||
void ff_init(void);
|
||||
void ff_load_font(const char * filename);
|
||||
/*
|
||||
void ff_load_encoding(const char * filename, const char * encname);
|
||||
*/
|
||||
void ff_reencode(const char * encname, int force);
|
||||
void ff_reencode_glyph_order(void);
|
||||
void ff_reencode_raw(int32_t * mapping, int mapping_len, int force);
|
||||
void ff_reencode_raw2(char ** mapping, int mapping_len, int force);
|
||||
void ff_cidflatten(void);
|
||||
|
Loading…
Reference in New Issue
Block a user