blob: 33b555d5c82f7194cd34dce8cd73380be470933c [file] [log] [blame]
// This file comes from pdftohtml project
// Copyright from:
// Gueorgui Ovtcharov
// Rainer Dorsch <>
// Mikhail Kruk <>
// Modified under the Poppler project -
// All changes made under the Poppler project to this file are licensed
// under GPL version 2 or later
// Copyright (C) 2010 OSSD CDAC Mumbai by Leena Chourey ( and Onkar Potdar (
// Copyright (C) 2010, 2012, 2017, 2018 Albert Astals Cid <>
// Copyright (C) 2011 Steven Murdoch <>
// Copyright (C) 2011 Joshua Richardson <>
// Copyright (C) 2012 Igor Slepchin <>
// Copyright (C) 2018 Adam Reichold <>
// 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
#ifndef _HTML_FONTS_H
#define _HTML_FONTS_H
#include "goo/GooString.h"
#include "GfxState.h"
#include "CharTypes.h"
#include <vector>
class HtmlFontColor{
unsigned int r;
unsigned int g;
unsigned int b;
bool Ok(unsigned int xcol){ return xcol<=255;}
GooString *convtoX(unsigned int xcol) const;
HtmlFontColor(GfxRGB rgb);
HtmlFontColor(const HtmlFontColor& x){r=x.r;g=x.g;b=x.b;}
HtmlFontColor& operator=(const HtmlFontColor &x){
return *this;
GooString* toString() const;
bool isEqual(const HtmlFontColor& col) const{
return ((r==col.r)&&(g==col.g)&&(b==col.b));
} ;
class HtmlFont{
unsigned int size;
int lineSize;
bool italic;
bool bold;
bool rotOrSkewed;
std::string familyName;
GooString *FontName;
HtmlFontColor color;
double rotSkewMat[4]; // only four values needed for rotation and skew
HtmlFont(GfxFont *font,int _size, GfxRGB rgb);
HtmlFont(const HtmlFont& x);
HtmlFont& operator=(const HtmlFont& x);
HtmlFontColor getColor() const {return color;}
GooString* getFullName();
bool isItalic() const {return italic;}
bool isBold() const {return bold;}
bool isRotOrSkewed() const { return rotOrSkewed; }
unsigned int getSize() const {return size;}
int getLineSize() const {return lineSize;}
void setLineSize(int _lineSize) { lineSize = _lineSize; }
void setRotMat(const double * const mat)
{ rotOrSkewed = true; memcpy(rotSkewMat, mat, sizeof(rotSkewMat)); }
const double *getRotMat() const { return rotSkewMat; }
GooString* getFontName();
static GooString* HtmlFilter(const Unicode* u, int uLen); //char* s);
bool isEqual(const HtmlFont& x) const;
bool isEqualIgnoreBold(const HtmlFont& x) const;
void print() const {printf("font: %s (%s) %d %s%s\n", FontName->c_str(), familyName.c_str(), size, bold ? "bold " : "", italic ? "italic " : "");};
class HtmlFontAccu{
std::vector<HtmlFont> *accu;
HtmlFontAccu(const HtmlFontAccu &) = delete;
HtmlFontAccu& operator=(const HtmlFontAccu &) = delete;
int AddFont(const HtmlFont& font);
HtmlFont *Get(int i){
return &(*accu)[i];
GooString* CSStyle(int i, int j = 0);
int size() const {return accu->size();}