1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-03 08:38:39 +00:00

working on asc/des

This commit is contained in:
Lu Wang 2012-09-19 03:20:34 +08:00
parent c55fee198e
commit 7c2679d23c
4 changed files with 34 additions and 87 deletions

View File

@ -18,6 +18,6 @@ void BackgroundRenderer::drawChar(GfxState *state, double x, double y,
double originX, double originY,
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);
}

View File

@ -361,37 +361,11 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo
ffw_load_font((char*)fn);
}
ffw_metric(&info.ascent, &info.descent);
if(param->debug)
{
// read metrics
// 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)
{
}
}
cerr << "Ascent: " << info.ascent << " Descent: " << info.descent << endl;
}
{

View File

@ -40,11 +40,6 @@ static char * strcopy(const char * str)
return _;
}
static int max(int a, int b)
{
return (a>b) ? a : b;
}
static void dumb_logwarning(const char * format, ...)
{
}
@ -214,7 +209,7 @@ void ffw_close(void)
cur_fv = NULL;
}
void ffw_metric(int * ascent, int * descent)
void ffw_metric(double * ascent, double * descent)
{
DBounds bb;
SplineFont * sf = cur_fv->sf;
@ -222,59 +217,42 @@ void ffw_metric(int * ascent, int * descent)
struct pfminfo * info = &sf->pfminfo;
//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;
*descent = sf->descent;
int em = sf->ascent + sf->descent;
//debug
printf("%d %d\n", *ascent, *descent);
if (em > 0)
{
*ascent = ((double)bb.maxy) / em;
*descent = ((double)bb.miny) / em;
}
else
{
*ascent = *descent = 0;
}
info->os2_winascent = 0;
info->os2_typoascent = 0;
info->hhead_ascent = 0;
info->os2_winascent = *ascent;
info->os2_typoascent = *ascent;
info->hhead_ascent = *ascent;
info->winascent_add = 0;
info->typoascent_add = 0;
info->hheadascent_add = 0;
info->os2_windescent = 0;
info->os2_typodescent = 0;
info->hhead_descent = 0;
info->os2_windescent = -*descent;
info->os2_typodescent = *descent;
info->hhead_descent = *descent;
info->windescent_add = 0;
info->typodescent_add = 0;
info->hheaddescent_add = 0;
}
int ffw_get_em_size(void)
{
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;
info->pfmset = 1;
sf->changed = true;
}

View File

@ -31,12 +31,7 @@ void ffw_save(const char * filename);
void ffw_close(void);
// fix metrics and get them
void ffw_metric(int * ascent, int * 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);
void ffw_metric(double * ascent, double * descent);
#ifdef __cplusplus
}