diff options
author | Igor Slepchin <igor.slepchin@gmail.com> | 2012-05-15 23:16:27 +0200 |
---|---|---|
committer | Albert Astals Cid <aacid@kde.org> | 2012-05-15 23:17:27 +0200 |
commit | 3a249aa8ad5e9f7511bcafd0416ce51c7efe5f4d (patch) | |
tree | ba77d572a71c40a3f7950823cfa3ba6ec4a0a689 | |
parent | ff2c251dbaef9b964af48f51ebb517626ac3145c (diff) |
Determine if font is bold or italic based on FontDescriptor.
Bug #49758
-rw-r--r-- | utils/HtmlFonts.cc | 24 | ||||
-rw-r--r-- | utils/HtmlFonts.h | 3 | ||||
-rw-r--r-- | utils/HtmlOutputDev.cc | 4 |
3 files changed, 21 insertions, 10 deletions
diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc index 7205a1d8..be02c5f3 100644 --- a/utils/HtmlFonts.cc +++ b/utils/HtmlFonts.cc @@ -23,6 +23,7 @@ // Copyright (C) 2010 OSSD CDAC Mumbai by Leena Chourey (leenac@cdacmumbai.in) and Onkar Potdar (onkar@cdacmumbai.in) // Copyright (C) 2011 Joshua Richardson <jric@chegg.com> // Copyright (C) 2011 Stephen Reichling <sreichling@chegg.com> +// Copyright (C) 2012 Igor Slepchin <igor.slepchin@gmail.com> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -33,6 +34,7 @@ #include "HtmlUtils.h" #include "GlobalParams.h" #include "UnicodeMap.h" +#include "GfxFont.h" #include <stdio.h> struct Fonts{ @@ -101,10 +103,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 +128,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)&&(i<font_num)) { diff --git a/utils/HtmlFonts.h b/utils/HtmlFonts.h index 3e3b0282..22368b28 100644 --- a/utils/HtmlFonts.h +++ b/utils/HtmlFonts.h @@ -21,6 +21,7 @@ // Copyright (C) 2010 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2011 Steven Murdoch <Steven.Murdoch@cl.cam.ac.uk> // Copyright (C) 2011 Joshua Richardson <jric@chegg.com> +// Copyright (C) 2012 Igor Slepchin <igor.slepchin@gmail.com> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -72,7 +73,7 @@ class HtmlFont{ public: HtmlFont(){FontName=NULL; rotOrSkewed = gFalse;} - HtmlFont(GooString* fontname,int _size, GfxRGB rgb); + HtmlFont(GfxFont *font,int _size, GfxRGB rgb); HtmlFont(const HtmlFont& x); HtmlFont& operator=(const HtmlFont& x); HtmlFontColor getColor() const {return color;} diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc index 2f079889..1d1b6285 100644 --- a/utils/HtmlOutputDev.cc +++ b/utils/HtmlOutputDev.cc @@ -174,9 +174,7 @@ HtmlString::HtmlString(GfxState *state, double fontSize, HtmlFontAccu* _fonts) : yMax = y - descent * fontSize; GfxRGB rgb; state->getFillRGB(&rgb); - GooString *name = state->getFont()->getName(); - if (!name) name = HtmlFont::getDefaultFont(); //new GooString("default"); - HtmlFont hfont=HtmlFont(name, static_cast<int>(fontSize-1), rgb); + HtmlFont hfont=HtmlFont(font, static_cast<int>(fontSize-1), rgb); if (isMatRotOrSkew(state->getTextMat())) { double normalizedMatrix[4]; memcpy(normalizedMatrix, state->getTextMat(), sizeof(normalizedMatrix)); |