mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-07-05 17:48:38 +00:00
working on asc/des
This commit is contained in:
parent
c55fee198e
commit
7c2679d23c
|
@ -18,6 +18,6 @@ void BackgroundRenderer::drawChar(GfxState *state, double x, double y,
|
||||||
double originX, double originY,
|
double originX, double originY,
|
||||||
CharCode code, int nBytes, Unicode *u, int uLen)
|
CharCode code, int nBytes, Unicode *u, int uLen)
|
||||||
{
|
{
|
||||||
// SplashOutputDev::drawChar(state,x,y,dx,dy,originX,originY,code, nBytes, u, uLen);
|
SplashOutputDev::drawChar(state,x,y,dx,dy,originX,originY,code, nBytes, u, uLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -361,37 +361,11 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
|
||||||
ffw_load_font((char*)fn);
|
ffw_load_font((char*)fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ffw_metric(&info.ascent, &info.descent);
|
||||||
|
|
||||||
|
if(param->debug)
|
||||||
{
|
{
|
||||||
// read metrics
|
cerr << "Ascent: " << info.ascent << " Descent: " << info.descent << endl;
|
||||||
// int em = ffw_get_em_size();
|
|
||||||
int ascent,descent;
|
|
||||||
ffw_metric(&ascent, &descent);
|
|
||||||
int em = ascent + descent;
|
|
||||||
|
|
||||||
if(em != 0)
|
|
||||||
{
|
|
||||||
info.ascent = ((double)ascent) / em;
|
|
||||||
info.descent = -((double)descent) / em;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
info.ascent = 0;
|
|
||||||
info.descent = 0;
|
|
||||||
}
|
|
||||||
if(param->debug)
|
|
||||||
{
|
|
||||||
cerr << "Ascent: " << info.ascent << " Descent: " << info.descent << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
ffw_set_ascent(ascent);
|
|
||||||
ffw_set_descent(descent);
|
|
||||||
|
|
||||||
if(!get_metric_only)
|
|
||||||
{
|
|
||||||
if(font_8bit)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
78
src/ffw.c
78
src/ffw.c
|
@ -40,11 +40,6 @@ static char * strcopy(const char * str)
|
||||||
return _;
|
return _;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int max(int a, int b)
|
|
||||||
{
|
|
||||||
return (a>b) ? a : b;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dumb_logwarning(const char * format, ...)
|
static void dumb_logwarning(const char * format, ...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -214,7 +209,7 @@ void ffw_close(void)
|
||||||
cur_fv = NULL;
|
cur_fv = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ffw_metric(int * ascent, int * descent)
|
void ffw_metric(double * ascent, double * descent)
|
||||||
{
|
{
|
||||||
DBounds bb;
|
DBounds bb;
|
||||||
SplineFont * sf = cur_fv->sf;
|
SplineFont * sf = cur_fv->sf;
|
||||||
|
@ -222,59 +217,42 @@ void ffw_metric(int * ascent, int * descent)
|
||||||
struct pfminfo * info = &sf->pfminfo;
|
struct pfminfo * info = &sf->pfminfo;
|
||||||
|
|
||||||
//debug
|
//debug
|
||||||
printf("%d %d\n", *ascent, *descent);
|
printf("bb %lf %lf\n", bb.maxy, bb.miny);
|
||||||
|
printf("_ %d %d\n", sf->ascent, sf->descent);
|
||||||
|
printf("win %d %d\n", info->os2_winascent, info->os2_windescent);
|
||||||
|
printf("%d %d\n", info->winascent_add, info->windescent_add);
|
||||||
|
printf("typo %d %d\n", info->os2_typoascent, info->os2_typodescent);
|
||||||
|
printf("%d %d\n", info->typoascent_add, info->typodescent_add);
|
||||||
|
printf("hhead %d %d\n", info->hhead_ascent, info->hhead_descent);
|
||||||
|
printf("%d %d\n", info->hheadascent_add, info->hheaddescent_add);
|
||||||
|
|
||||||
*ascent = sf->ascent;
|
int em = sf->ascent + sf->descent;
|
||||||
*descent = sf->descent;
|
|
||||||
|
|
||||||
//debug
|
if (em > 0)
|
||||||
printf("%d %d\n", *ascent, *descent);
|
{
|
||||||
|
*ascent = ((double)bb.maxy) / em;
|
||||||
|
*descent = ((double)bb.miny) / em;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*ascent = *descent = 0;
|
||||||
|
}
|
||||||
|
|
||||||
info->os2_winascent = 0;
|
info->os2_winascent = *ascent;
|
||||||
info->os2_typoascent = 0;
|
info->os2_typoascent = *ascent;
|
||||||
info->hhead_ascent = 0;
|
info->hhead_ascent = *ascent;
|
||||||
info->winascent_add = 0;
|
info->winascent_add = 0;
|
||||||
info->typoascent_add = 0;
|
info->typoascent_add = 0;
|
||||||
info->hheadascent_add = 0;
|
info->hheadascent_add = 0;
|
||||||
|
|
||||||
info->os2_windescent = 0;
|
info->os2_windescent = -*descent;
|
||||||
info->os2_typodescent = 0;
|
info->os2_typodescent = *descent;
|
||||||
info->hhead_descent = 0;
|
info->hhead_descent = *descent;
|
||||||
info->windescent_add = 0;
|
info->windescent_add = 0;
|
||||||
info->typodescent_add = 0;
|
info->typodescent_add = 0;
|
||||||
info->hheaddescent_add = 0;
|
info->hheaddescent_add = 0;
|
||||||
}
|
|
||||||
|
info->pfmset = 1;
|
||||||
int ffw_get_em_size(void)
|
sf->changed = true;
|
||||||
{
|
|
||||||
return (cur_fv->sf->pfminfo.os2_typoascent - cur_fv->sf->pfminfo.os2_typodescent);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ffw_get_max_ascent(void)
|
|
||||||
{
|
|
||||||
return max(cur_fv->sf->pfminfo.os2_winascent,
|
|
||||||
max(cur_fv->sf->pfminfo.os2_typoascent,
|
|
||||||
cur_fv->sf->pfminfo.hhead_ascent));
|
|
||||||
}
|
|
||||||
|
|
||||||
int ffw_get_max_descent(void)
|
|
||||||
{
|
|
||||||
return max(cur_fv->sf->pfminfo.os2_windescent,
|
|
||||||
max(-cur_fv->sf->pfminfo.os2_typodescent,
|
|
||||||
-cur_fv->sf->pfminfo.hhead_descent));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ffw_set_ascent(int a)
|
|
||||||
{
|
|
||||||
cur_fv->sf->pfminfo.os2_winascent = a;
|
|
||||||
cur_fv->sf->pfminfo.os2_typoascent = a;
|
|
||||||
cur_fv->sf->pfminfo.hhead_ascent = a;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ffw_set_descent(int d)
|
|
||||||
{
|
|
||||||
cur_fv->sf->pfminfo.os2_windescent = d;
|
|
||||||
cur_fv->sf->pfminfo.os2_typodescent = -d;
|
|
||||||
cur_fv->sf->pfminfo.hhead_descent = -d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,12 +31,7 @@ void ffw_save(const char * filename);
|
||||||
void ffw_close(void);
|
void ffw_close(void);
|
||||||
|
|
||||||
// fix metrics and get them
|
// fix metrics and get them
|
||||||
void ffw_metric(int * ascent, int * descent);
|
void ffw_metric(double * ascent, double * descent);
|
||||||
int ffw_get_em_size(void);
|
|
||||||
int ffw_get_max_ascent(void);
|
|
||||||
int ffw_get_max_descent(void);
|
|
||||||
void ffw_set_ascent(int a);
|
|
||||||
void ffw_set_descent(int d);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user