From 7c2679d23c13a28822b9e455953d302a63f021a5 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Wed, 19 Sep 2012 03:20:34 +0800 Subject: [PATCH] working on asc/des --- src/BackgroundRenderer.cc | 2 +- src/HTMLRenderer/text.cc | 34 ++--------------- src/ffw.c | 78 ++++++++++++++------------------------- src/include/ffw.h | 7 +--- 4 files changed, 34 insertions(+), 87 deletions(-) diff --git a/src/BackgroundRenderer.cc b/src/BackgroundRenderer.cc index 6956408..af4cb13 100644 --- a/src/BackgroundRenderer.cc +++ b/src/BackgroundRenderer.cc @@ -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); } diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc index deedeae..5ad0f17 100644 --- a/src/HTMLRenderer/text.cc +++ b/src/HTMLRenderer/text.cc @@ -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; } { diff --git a/src/ffw.c b/src/ffw.c index 74b94d6..e9d3445 100644 --- a/src/ffw.c +++ b/src/ffw.c @@ -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; } diff --git a/src/include/ffw.h b/src/include/ffw.h index ef8d866..da01a26 100644 --- a/src/include/ffw.h +++ b/src/include/ffw.h @@ -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 }