mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
..
This commit is contained in:
commit
792c2ff728
5
TODO
5
TODO
@ -1,3 +1,5 @@
|
|||||||
|
word space/offset before the first letter (calendar pdf)
|
||||||
|
|
||||||
don't dump image when there is nothing
|
don't dump image when there is nothing
|
||||||
|
|
||||||
Integrate splash/cairo
|
Integrate splash/cairo
|
||||||
@ -6,12 +8,9 @@ native support for draw
|
|||||||
|
|
||||||
draw non-orthogonal lines with CSS
|
draw non-orthogonal lines with CSS
|
||||||
|
|
||||||
create a glyph for ' ', if there is not in a font
|
|
||||||
|
|
||||||
position history stack (popstate)
|
position history stack (popstate)
|
||||||
|
|
||||||
==Wait until someone asks==
|
==Wait until someone asks==
|
||||||
|
|
||||||
try harder finding glyph names (using fontforge) for CID Type 0
|
try harder finding glyph names (using fontforge) for CID Type 0
|
||||||
rename single-html -> embed-font/image/css ...
|
rename single-html -> embed-font/image/css ...
|
||||||
merge sub/sup into one line
|
merge sub/sup into one line
|
||||||
|
@ -66,6 +66,7 @@ span {
|
|||||||
}
|
}
|
||||||
._ {
|
._ {
|
||||||
color:transparent;
|
color:transparent;
|
||||||
|
z-index:-1;
|
||||||
}
|
}
|
||||||
::selection{
|
::selection{
|
||||||
background: rgba(127,255,255,1);
|
background: rgba(127,255,255,1);
|
||||||
|
@ -101,6 +101,7 @@ static void get_shading_bbox(GfxState * state, GfxShading * shading,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Note that the coordinate system in HTML and PDF are different
|
* Note that the coordinate system in HTML and PDF are different
|
||||||
|
* This functions returns the angle of vector (dx,dy) in the PDF coordinate system, in rad
|
||||||
*/
|
*/
|
||||||
static double get_angle(double dx, double dy)
|
static double get_angle(double dx, double dy)
|
||||||
{
|
{
|
||||||
|
@ -41,12 +41,6 @@ void HTMLRenderer::export_remote_font(const FontInfo & info, const string & suff
|
|||||||
<< ";line-height:" << _round(info.ascent - info.descent)
|
<< ";line-height:" << _round(info.ascent - info.descent)
|
||||||
<< ";font-style:normal;font-weight:normal;}";
|
<< ";font-style:normal;font-weight:normal;}";
|
||||||
|
|
||||||
// when ' ' is not vaild in the font, when we use ' ' in padding
|
|
||||||
// the browser will use the fallback font, whose metrics could be (very) different, then the layout will be affected
|
|
||||||
// so set the font-zie to avoid being affected
|
|
||||||
if(!(info.has_space))
|
|
||||||
css_fout << ".f" << info.id << ">._{font-size:1px;}";
|
|
||||||
|
|
||||||
css_fout << endl;
|
css_fout << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ HTMLRenderer::HTMLRenderer(const Param * param)
|
|||||||
|
|
||||||
HTMLRenderer::~HTMLRenderer()
|
HTMLRenderer::~HTMLRenderer()
|
||||||
{
|
{
|
||||||
ffw_fin();
|
ffw_finalize();
|
||||||
clean_tmp_files();
|
clean_tmp_files();
|
||||||
delete [] cur_mapping;
|
delete [] cur_mapping;
|
||||||
delete [] cur_mapping2;
|
delete [] cur_mapping2;
|
||||||
|
@ -190,7 +190,7 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
|
|||||||
* if parm->tounicode is 0, try the provided tounicode map first
|
* if parm->tounicode is 0, try the provided tounicode map first
|
||||||
*/
|
*/
|
||||||
info.use_tounicode = (is_truetype_suffix(suffix) || (param->tounicode >= 0));
|
info.use_tounicode = (is_truetype_suffix(suffix) || (param->tounicode >= 0));
|
||||||
info.has_space = false;
|
bool has_space = false;
|
||||||
|
|
||||||
const char * used_map = nullptr;
|
const char * used_map = nullptr;
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(u == ' ')
|
if(u == ' ')
|
||||||
info.has_space = true;
|
has_space = true;
|
||||||
|
|
||||||
if(codeset.insert(u).second)
|
if(codeset.insert(u).second)
|
||||||
{
|
{
|
||||||
@ -410,6 +410,22 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
|
|||||||
|
|
||||||
ffw_reencode_raw(cur_mapping, max_key + 1, 1);
|
ffw_reencode_raw(cur_mapping, max_key + 1, 1);
|
||||||
|
|
||||||
|
// we need the space chracter for offsets
|
||||||
|
if(!has_space)
|
||||||
|
{
|
||||||
|
int space_width;
|
||||||
|
if(font_8bit)
|
||||||
|
{
|
||||||
|
space_width = (int)floor(font_8bit->getWidth(' ') * info.em_size + 0.5);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char buf[2] = {0, ' '};
|
||||||
|
space_width = (int)floor(font_cid->getWidth(buf, 2) * info.em_size + 0.5);
|
||||||
|
}
|
||||||
|
ffw_make_char((int)' ', space_width);
|
||||||
|
}
|
||||||
|
|
||||||
if(ctu)
|
if(ctu)
|
||||||
ctu->decRefCnt();
|
ctu->decRefCnt();
|
||||||
}
|
}
|
||||||
|
42
src/ffw.c
42
src/ffw.c
@ -77,7 +77,7 @@ void ffw_init(int debug)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffw_fin(void)
|
void ffw_finalize(void)
|
||||||
{
|
{
|
||||||
while(enc_head)
|
while(enc_head)
|
||||||
{
|
{
|
||||||
@ -147,6 +147,26 @@ void ffw_prepare_font(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ffw_save(const char * filename)
|
||||||
|
{
|
||||||
|
char * _filename = strcopy(filename);
|
||||||
|
char * _ = strcopy("");
|
||||||
|
|
||||||
|
int r = GenerateScript(cur_fv->sf, _filename
|
||||||
|
, _, -1, -1, NULL, NULL, cur_fv->map, NULL, ly_fore);
|
||||||
|
|
||||||
|
free(_);
|
||||||
|
free(_filename);
|
||||||
|
|
||||||
|
if(!r)
|
||||||
|
err("Cannot save font to %s\n", filename);
|
||||||
|
}
|
||||||
|
void ffw_close(void)
|
||||||
|
{
|
||||||
|
FontViewClose(cur_fv);
|
||||||
|
cur_fv = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void ffw_do_reencode(Encoding * encoding, int force)
|
static void ffw_do_reencode(Encoding * encoding, int force)
|
||||||
{
|
{
|
||||||
assert(encoding);
|
assert(encoding);
|
||||||
@ -235,25 +255,9 @@ void ffw_cidflatten(void)
|
|||||||
SFFlatten(cur_fv->sf->cidmaster);
|
SFFlatten(cur_fv->sf->cidmaster);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffw_save(const char * filename)
|
void ffw_make_char(int enc, int width)
|
||||||
{
|
{
|
||||||
char * _filename = strcopy(filename);
|
SFMakeChar(cur_fv->sf, cur_fv->map, enc)->width = width;
|
||||||
char * _ = strcopy("");
|
|
||||||
|
|
||||||
int r = GenerateScript(cur_fv->sf, _filename
|
|
||||||
, _, -1, -1, NULL, NULL, cur_fv->map, NULL, ly_fore);
|
|
||||||
|
|
||||||
free(_);
|
|
||||||
free(_filename);
|
|
||||||
|
|
||||||
if(!r)
|
|
||||||
err("Cannot save font to %s\n", filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ffw_close(void)
|
|
||||||
{
|
|
||||||
FontViewClose(cur_fv);
|
|
||||||
cur_fv = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ffw_get_em_size(void)
|
int ffw_get_em_size(void)
|
||||||
|
@ -19,18 +19,31 @@ extern "C" {
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
////////////////////////
|
||||||
|
// global
|
||||||
void ffw_init(int debug);
|
void ffw_init(int debug);
|
||||||
void ffw_fin(void);
|
void ffw_finalize(void);
|
||||||
|
|
||||||
|
////////////////////////
|
||||||
|
// load & save
|
||||||
void ffw_load_font(const char * filename);
|
void ffw_load_font(const char * filename);
|
||||||
void ffw_prepare_font(void);
|
void ffw_prepare_font(void);
|
||||||
void ffw_reencode_glyph_order(void);
|
|
||||||
void ffw_reencode_raw(int32_t * mapping, int mapping_len, int force);
|
|
||||||
void ffw_reencode_raw2(char ** mapping, int mapping_len, int force);
|
|
||||||
void ffw_cidflatten(void);
|
|
||||||
void ffw_save(const char * filename);
|
void ffw_save(const char * filename);
|
||||||
void ffw_close(void);
|
void ffw_close(void);
|
||||||
|
|
||||||
|
////////////////////////
|
||||||
|
// encoding
|
||||||
|
void ffw_reencode_glyph_order(void);
|
||||||
|
void ffw_reencode_raw(int32_t * mapping, int mapping_len, int force);
|
||||||
|
void ffw_reencode_raw2(char ** mapping, int mapping_len, int force);
|
||||||
|
|
||||||
|
void ffw_cidflatten(void);
|
||||||
|
// get or create the char, and set the width
|
||||||
|
void ffw_make_char(int enc, int width);
|
||||||
|
|
||||||
|
////////////////////////
|
||||||
|
// metrics
|
||||||
int ffw_get_em_size(void);
|
int ffw_get_em_size(void);
|
||||||
// fix metrics and get them
|
// fix metrics and get them
|
||||||
void ffw_metric(double * ascent, double * descent);
|
void ffw_metric(double * ascent, double * descent);
|
||||||
@ -39,6 +52,8 @@ void ffw_set_widths(int * width_list, int mapping_len,
|
|||||||
int stretch_narrow, int squeeze_wide,
|
int stretch_narrow, int squeeze_wide,
|
||||||
int remove_unused);
|
int remove_unused);
|
||||||
|
|
||||||
|
////////////////////////
|
||||||
|
// others
|
||||||
void ffw_auto_hint(void);
|
void ffw_auto_hint(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -103,7 +103,6 @@ public:
|
|||||||
bool use_tounicode;
|
bool use_tounicode;
|
||||||
int em_size;
|
int em_size;
|
||||||
double ascent, descent;
|
double ascent, descent;
|
||||||
bool has_space; // whether space is included in the font
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Matrix_less
|
class Matrix_less
|
||||||
|
Loading…
Reference in New Issue
Block a user