00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FontDescription_h
00025 #define FontDescription_h
00026
00027 #include "FontFamily.h"
00028
00029 namespace WebCore {
00030
00031 const unsigned cNormalWeight = 50;
00032 const unsigned cBoldWeight = 63;
00033
00034 class FontDescription {
00035 public:
00036 enum GenericFamilyType { NoFamily, StandardFamily, SerifFamily, SansSerifFamily,
00037 MonospaceFamily, CursiveFamily, FantasyFamily };
00038
00039 FontDescription()
00040 : m_specifiedSize(0), m_computedSize(0),
00041 m_italic(false), m_smallCaps(false), m_isAbsoluteSize(false), m_weight(cNormalWeight),
00042 m_genericFamily(NoFamily), m_usePrinterFont(false), m_keywordSize(0)
00043 {}
00044
00045 bool operator==(const FontDescription&) const;
00046 bool operator!=(const FontDescription& other) const { return !(*this == other); }
00047
00048 const FontFamily& family() const { return m_familyList; }
00049 FontFamily& firstFamily() { return m_familyList; }
00050 float specifiedSize() const { return m_specifiedSize; }
00051 float computedSize() const { return m_computedSize; }
00052 bool italic() const { return m_italic; }
00053 bool bold() const { return weight() == cBoldWeight; }
00054 int computedPixelSize() const { return int(m_computedSize + 0.5f); }
00055 bool smallCaps() const { return m_smallCaps; }
00056 bool isAbsoluteSize() const { return m_isAbsoluteSize; }
00057 unsigned weight() const { return m_weight; }
00058 GenericFamilyType genericFamily() const { return static_cast<GenericFamilyType>(m_genericFamily); }
00059 bool usePrinterFont() const { return m_usePrinterFont; }
00060 int keywordSize() const { return m_keywordSize; }
00061
00062 void setFamily(const FontFamily& family) { m_familyList = family; }
00063 void setComputedSize(float s) { m_computedSize = s; }
00064 void setSpecifiedSize(float s) { m_specifiedSize = s; }
00065 void setItalic(bool i) { m_italic = i; }
00066 void setBold(bool b) { m_weight = (b ? cBoldWeight : cNormalWeight); }
00067 void setSmallCaps(bool c) { m_smallCaps = c; }
00068 void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
00069 void setWeight(unsigned w) { m_weight = w; }
00070 void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = genericFamily; }
00071 void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
00072 void setKeywordSize(int s) { m_keywordSize = s; }
00073
00074 private:
00075 FontFamily m_familyList;
00076
00077 float m_specifiedSize;
00078
00079 float m_computedSize;
00080
00081 bool m_italic : 1;
00082 bool m_smallCaps : 1;
00083 bool m_isAbsoluteSize : 1;
00084
00085 unsigned m_weight : 8;
00086 unsigned m_genericFamily : 3;
00087 bool m_usePrinterFont : 1;
00088
00089 int m_keywordSize : 4;
00090
00091
00092 };
00093
00094 inline bool FontDescription::operator==(const FontDescription& other) const
00095 {
00096 return m_familyList == other.m_familyList
00097 && m_specifiedSize == other.m_specifiedSize
00098 && m_computedSize == other.m_computedSize
00099 && m_italic == other.m_italic
00100 && m_smallCaps == other.m_smallCaps
00101 && m_isAbsoluteSize == other.m_isAbsoluteSize
00102 && m_weight == other.m_weight
00103 && m_genericFamily == other.m_genericFamily
00104 && m_usePrinterFont == other.m_usePrinterFont
00105 && m_keywordSize == other.m_keywordSize;
00106 }
00107
00108 }
00109
00110 #endif