KHTML
FontDescription.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef FontDescription_h
00026 #define FontDescription_h
00027
00028 #include "FontFamily.h"
00029 #include "FontRenderingMode.h"
00030
00031 namespace WebCore {
00032
00033 enum FontWeight {
00034 FontWeight100,
00035 FontWeight200,
00036 FontWeight300,
00037 FontWeight400,
00038 FontWeight500,
00039 FontWeight600,
00040 FontWeight700,
00041 FontWeight800,
00042 FontWeight900,
00043 FontWeightNormal = FontWeight400,
00044 FontWeightBold = FontWeight700
00045 };
00046
00047 class FontDescription {
00048 public:
00049 enum GenericFamilyType { NoFamily, StandardFamily, SerifFamily, SansSerifFamily,
00050 MonospaceFamily, CursiveFamily, FantasyFamily };
00051
00052 FontDescription()
00053 : m_specifiedSize(0)
00054 , m_computedSize(0)
00055 , m_italic(false)
00056 , m_smallCaps(false)
00057 , m_isAbsoluteSize(false)
00058 , m_weight(FontWeightNormal)
00059 , m_genericFamily(NoFamily)
00060 , m_usePrinterFont(false)
00061 , m_renderingMode(NormalRenderingMode)
00062 , m_keywordSize(0)
00063 {
00064 }
00065
00066 bool operator==(const FontDescription&) const;
00067 bool operator!=(const FontDescription& other) const { return !(*this == other); }
00068
00069 const FontFamily& family() const { return m_familyList; }
00070 FontFamily& firstFamily() { return m_familyList; }
00071 float specifiedSize() const { return m_specifiedSize; }
00072 float computedSize() const { return m_computedSize; }
00073 bool italic() const { return m_italic; }
00074 int computedPixelSize() const { return int(m_computedSize + 0.5f); }
00075 bool smallCaps() const { return m_smallCaps; }
00076 bool isAbsoluteSize() const { return m_isAbsoluteSize; }
00077 FontWeight weight() const { return static_cast<FontWeight>(m_weight); }
00078 FontWeight lighterWeight() const;
00079 FontWeight bolderWeight() const;
00080 GenericFamilyType genericFamily() const { return static_cast<GenericFamilyType>(m_genericFamily); }
00081 bool usePrinterFont() const { return m_usePrinterFont; }
00082 FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); }
00083 int keywordSize() const { return m_keywordSize; }
00084
00085 void setFamily(const FontFamily& family) { m_familyList = family; }
00086 void setComputedSize(float s) { m_computedSize = s; }
00087 void setSpecifiedSize(float s) { m_specifiedSize = s; }
00088 void setItalic(bool i) { m_italic = i; }
00089 void setSmallCaps(bool c) { m_smallCaps = c; }
00090 void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
00091 void setWeight(FontWeight w) { m_weight = w; }
00092 void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = genericFamily; }
00093 void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
00094 void setRenderingMode(FontRenderingMode mode) { m_renderingMode = mode; }
00095 void setKeywordSize(int s) { m_keywordSize = s; }
00096
00097 private:
00098 FontFamily m_familyList;
00099
00100 float m_specifiedSize;
00101
00102 float m_computedSize;
00103
00104 bool m_italic : 1;
00105 bool m_smallCaps : 1;
00106 bool m_isAbsoluteSize : 1;
00107
00108 unsigned m_weight : 8;
00109 unsigned m_genericFamily : 3;
00110 bool m_usePrinterFont : 1;
00111
00112 unsigned m_renderingMode : 1;
00113
00114 int m_keywordSize : 4;
00115
00116
00117 };
00118
00119 inline bool FontDescription::operator==(const FontDescription& other) const
00120 {
00121 return m_familyList == other.m_familyList
00122 && m_specifiedSize == other.m_specifiedSize
00123 && m_computedSize == other.m_computedSize
00124 && m_italic == other.m_italic
00125 && m_smallCaps == other.m_smallCaps
00126 && m_isAbsoluteSize == other.m_isAbsoluteSize
00127 && m_weight == other.m_weight
00128 && m_genericFamily == other.m_genericFamily
00129 && m_usePrinterFont == other.m_usePrinterFont
00130 && m_renderingMode == other.m_renderingMode
00131 && m_keywordSize == other.m_keywordSize;
00132 }
00133
00134 }
00135
00136 #endif