[poppler] Branch 'poppler-0.20' - utils/HtmlFonts.cc utils/HtmlFonts.h utils/HtmlOutputDev.cc
Albert Astals Cid
aacid at kemper.freedesktop.org
Tue May 15 14:18:17 PDT 2012
utils/HtmlFonts.cc | 24 ++++++++++++++++++------
utils/HtmlFonts.h | 3 ++-
utils/HtmlOutputDev.cc | 4 +---
3 files changed, 21 insertions(+), 10 deletions(-)
New commits:
commit 7e7997e12faccf4c0513811b324a2fd0fa960a96
Author: Igor Slepchin <igor.slepchin at gmail.com>
Date: Tue May 15 23:16:27 2012 +0200
Determine if font is bold or italic based on FontDescriptor.
Bug #49758
diff --git a/utils/HtmlFonts.cc b/utils/HtmlFonts.cc
index 7205a1d..be02c5f 100644
--- a/utils/HtmlFonts.cc
+++ b/utils/HtmlFonts.cc
@@ -23,6 +23,7 @@
// Copyright (C) 2010 OSSD CDAC Mumbai by Leena Chourey (leenac at cdacmumbai.in) and Onkar Potdar (onkar at cdacmumbai.in)
// Copyright (C) 2011 Joshua Richardson <jric at chegg.com>
// Copyright (C) 2011 Stephen Reichling <sreichling at chegg.com>
+// Copyright (C) 2012 Igor Slepchin <igor.slepchin at 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 3e3b028..22368b2 100644
--- a/utils/HtmlFonts.h
+++ b/utils/HtmlFonts.h
@@ -21,6 +21,7 @@
// Copyright (C) 2010 Albert Astals Cid <aacid at kde.org>
// Copyright (C) 2011 Steven Murdoch <Steven.Murdoch at cl.cam.ac.uk>
// Copyright (C) 2011 Joshua Richardson <jric at chegg.com>
+// Copyright (C) 2012 Igor Slepchin <igor.slepchin at 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 2f07988..1d1b628 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));
More information about the poppler
mailing list