1 #ifndef _HTML_FONTS_H 2 #define _HTML_FONTS_H 3 #include "GVector.h" 4 #include "GString.h" 5 #include "GfxState.h" 6 #include "CharTypes.h" 7 8 9 class HtmlFontColor{ 10 private: 11 unsigned int r; 12 unsigned int g; 13 unsigned int b; Ok(unsigned int xcol)14 GBool Ok(unsigned int xcol){ return ((xcol<=255)&&(xcol>=0));} 15 GString *convtoX(unsigned int xcol) const; 16 public: HtmlFontColor()17 HtmlFontColor():r(0),g(0),b(0){} 18 HtmlFontColor(GfxRGB rgb); HtmlFontColor(const HtmlFontColor & x)19 HtmlFontColor(const HtmlFontColor& x){r=x.r;g=x.g;b=x.b;} 20 HtmlFontColor& operator=(const HtmlFontColor &x){ 21 r=x.r;g=x.g;b=x.b; 22 return *this; 23 } ~HtmlFontColor()24 ~HtmlFontColor(){}; 25 GString* toString() const; isEqual(const HtmlFontColor & col)26 GBool isEqual(const HtmlFontColor& col) const{ 27 return ((r==col.r)&&(g==col.g)&&(b==col.b)); 28 } 29 } ; 30 31 32 class HtmlFont{ 33 private: 34 unsigned int size; 35 double charspace; 36 int lineSize; 37 GBool italic; 38 GBool bold; 39 GBool oblique; 40 int pos; // position of the font name in the fonts array 41 static GString *DefaultFont; 42 GString *FontName; 43 HtmlFontColor color; 44 static GString* HtmlFilter(Unicode* u, int uLen); //char* s); 45 public: 46 HtmlFont()47 HtmlFont(){FontName=NULL;}; 48 HtmlFont(GString* fontname,int _size,double _charspace, GfxRGB rgb); 49 HtmlFont(const HtmlFont& x); 50 HtmlFont& operator=(const HtmlFont& x); getColor()51 HtmlFontColor getColor() const {return color;} 52 ~HtmlFont(); 53 static void clear(); 54 GString* getFullName(); isItalic()55 GBool isItalic() const {return italic;} isBold()56 GBool isBold() const {return bold;} isOblique()57 GBool isOblique() const {return oblique;} getSize()58 unsigned int getSize() const {return size;} getLineSize()59 int getLineSize() const {return lineSize;} setLineSize(int _lineSize)60 void setLineSize(int _lineSize) { lineSize = _lineSize; } 61 GString* getFontName(); getCharSpace()62 double getCharSpace() const {return charspace;} setCharSpace(double _charspace)63 void setCharSpace(double _charspace){charspace = _charspace;} 64 static GString* getDefaultFont(); 65 static void setDefaultFont(GString* defaultFont); 66 GBool isEqual(const HtmlFont& x) const; 67 GBool isEqualIgnoreBold(const HtmlFont& x) const; 68 static GString* simple(HtmlFont *font, Unicode *content, int uLen); print()69 void print() const {printf("font: %s %d %s%spos: %d\n", FontName->getCString(), size, bold ? "bold " : "", italic ? "italic " : "", pos);}; 70 }; 71 72 class HtmlFontAccu{ 73 private: 74 GVector<HtmlFont> *accu; 75 76 public: 77 HtmlFontAccu(); 78 ~HtmlFontAccu(); 79 int AddFont(const HtmlFont& font); Get(int i)80 HtmlFont* Get(int i){ 81 GVector<HtmlFont>::iterator g=accu->begin(); 82 g+=i; 83 return g; 84 } 85 GString* getCSStyle (int i, GString* content); 86 GString* CSStyle(int i); size()87 int size() const {return accu->size();} 88 89 }; 90 #endif 91