mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
add a font preprocessor
This commit is contained in:
parent
ab9dd287e6
commit
45b54d18c4
@ -66,6 +66,8 @@ add_executable(pdf2htmlEX
|
||||
src/ff/ff.c
|
||||
src/BackgroundRenderer.h
|
||||
src/BackgroundRenderer.cc
|
||||
src/FontPreprocessor.h
|
||||
src/FontPreprocessor.cc
|
||||
src/Consts.h
|
||||
src/Consts.cc
|
||||
src/util.h
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
allowAntialiasA) { }
|
||||
virtual ~BackgroundRenderer() { }
|
||||
|
||||
void drawChar(GfxState *state, double x, double y,
|
||||
virtual void drawChar(GfxState *state, double x, double y,
|
||||
double dx, double dy,
|
||||
double originX, double originY,
|
||||
CharCode code, int nBytes, Unicode *u, int uLen);
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "Param.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "FontPreprocessor.h"
|
||||
|
||||
/*
|
||||
* Naming Convention
|
||||
@ -124,6 +124,7 @@ class HTMLRenderer : public OutputDev
|
||||
////////////////////////////////////////////////////
|
||||
// misc
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
void add_tmp_file (const std::string & fn);
|
||||
void clean_tmp_files ();
|
||||
boost::filesystem::path dump_embedded_font (GfxFont * font, long long fn_id);
|
||||
@ -333,6 +334,7 @@ class HTMLRenderer : public OutputDev
|
||||
// for font reencoding
|
||||
int32_t * cur_mapping;
|
||||
char ** cur_mapping2;
|
||||
FontPreprocessor font_preprocessor;
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// styles & resources
|
||||
|
@ -51,12 +51,20 @@ HTMLRenderer::~HTMLRenderer()
|
||||
|
||||
void HTMLRenderer::process(PDFDoc *doc)
|
||||
{
|
||||
cerr << "Working: ";
|
||||
|
||||
xref = doc->getXRef();
|
||||
|
||||
BackgroundRenderer * bg_renderer = nullptr;
|
||||
cerr << "Preprocessing: ";
|
||||
for(int i = param->first_page; i <= param->last_page ; ++i)
|
||||
{
|
||||
doc->displayPage(&font_preprocessor, i, param->h_dpi, param->v_dpi,
|
||||
0, true, false, false,
|
||||
nullptr, nullptr, nullptr, nullptr);
|
||||
cerr << "." << flush;
|
||||
}
|
||||
cerr << endl;
|
||||
|
||||
cerr << "Working: ";
|
||||
BackgroundRenderer * bg_renderer = nullptr;
|
||||
if(param->process_nontext)
|
||||
{
|
||||
// Render non-text objects as image
|
||||
|
@ -25,7 +25,7 @@ const FontInfo * HTMLRenderer::install_font(GfxFont * font)
|
||||
{
|
||||
assert(sizeof(long long) == 2*sizeof(int));
|
||||
|
||||
long long fn_id = (font == nullptr) ? 0 : *reinterpret_cast<long long*>(font->getID());
|
||||
long long fn_id = (font == nullptr) ? 0 : hash_ref(font->getID());
|
||||
|
||||
auto iter = font_name_map.find(fn_id);
|
||||
if(iter != font_name_map.end())
|
||||
|
@ -217,8 +217,12 @@ void HTMLRenderer::embed_font(const path & filepath, GfxFont * font, FontInfo &
|
||||
|
||||
memset(cur_mapping2, 0, 256 * sizeof(char*));
|
||||
|
||||
const char * used_map = font_preprocessor.get_code_map(hash_ref(font->getID()));
|
||||
|
||||
for(int i = 0; i < 256; ++i)
|
||||
{
|
||||
if(!used_map[i]) continue;
|
||||
|
||||
auto cn = font_8bit->getCharName(i);
|
||||
if(cn == nullptr)
|
||||
{
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <CharTypes.h>
|
||||
#include <UTF8.h>
|
||||
#include <GlobalParams.h>
|
||||
#include <Object.h>
|
||||
|
||||
#include "Consts.h"
|
||||
|
||||
@ -49,6 +50,11 @@ static inline bool _tm_equal(const double * tm1, const double * tm2, int size =
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline long long hash_ref(const Ref * id)
|
||||
{
|
||||
return (((long long)(id->num)) << (sizeof(id->gen)*8)) | (id->gen);
|
||||
}
|
||||
|
||||
/*
|
||||
* http://en.wikipedia.org/wiki/HTML_decimal_character_rendering
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user