From 583ea81fe8f9926bc05143de565221c032dcea76 Mon Sep 17 00:00:00 2001 From: Igor Slepchin Date: Thu, 10 May 2012 16:38:15 -0400 Subject: [PATCH] Determine if font is bold or italic based on FontDescriptor. Bug 49758 --- utils/HtmlFonts.cc | 23 +++++++++++++++++------ utils/HtmlFonts.h | 2 +- utils/HtmlOutputDev.cc | 4 +--- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc index 7ce7e6a..92bc690 100644 --- a/utils/HtmlFonts.cc +++ b/utils/HtmlFonts.cc @@ -33,6 +33,7 @@ #include "HtmlUtils.h" #include "GlobalParams.h" #include "UnicodeMap.h" +#include "GfxFont.h" #include struct Fonts{ @@ -101,10 +102,12 @@ GooString *HtmlFontColor::toString() const{ return tmp; } -HtmlFont::HtmlFont(GooString* ftname,int _size, GfxRGB rgb){ +HtmlFont::HtmlFont(GfxFont *font, int _size, GfxRGB rgb){ //if (col) color=HtmlFontColor(col); //else color=HtmlFontColor(); color=HtmlFontColor(rgb); + GooString* ftname=font->getName(); + if (!ftname) ftname = getDefaultFont(); GooString *fontname = NULL; @@ -124,12 +127,20 @@ HtmlFont::HtmlFont(GooString* ftname,int _size, GfxRGB rgb){ bold = gFalse; rotOrSkewed = gFalse; + if (font->isBold() || font->getWeight() >= GfxFont::W700) bold=gTrue; + if (font->isItalic()) italic=gTrue; + if (fontname){ - if (strstr(fontname->lowerCase()->getCString(),"bold")) bold=gTrue; - - if (strstr(fontname->lowerCase()->getCString(),"italic")|| - strstr(fontname->lowerCase()->getCString(),"oblique")) italic=gTrue; - + if (!bold && strstr(fontname->lowerCase()->getCString(),"bold")) { + bold=gTrue; + } + + if (!italic && + (strstr(fontname->lowerCase()->getCString(),"italic")|| + strstr(fontname->lowerCase()->getCString(),"oblique"))) { + italic=gTrue; + } + int i=0; while (strcmp(ftname->getCString(),fonts[i].Fontname)&&(igetFillRGB(&rgb); - GooString *name = state->getFont()->getName(); - if (!name) name = HtmlFont::getDefaultFont(); //new GooString("default"); - HtmlFont hfont=HtmlFont(name, static_cast(fontSize-1), rgb); + HtmlFont hfont=HtmlFont(font, static_cast(fontSize-1), rgb); if (isMatRotOrSkew(state->getTextMat())) { double normalizedMatrix[4]; memcpy(normalizedMatrix, state->getTextMat(), sizeof(normalizedMatrix)); -- 1.7.7.6