pleyo.com

/src/trunk2/BAL/Interfaces/font/FontDescription.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
00003  *           (C) 2000 Antti Koivisto (koivisto@kde.org)
00004  *           (C) 2000 Dirk Mueller (mueller@kde.org)
00005  * Copyright (C) 2003-6 Apple Computer, Inc.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public License
00018  * along with this library; see the file COPYING.LIother.m_  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020  * Boston, MA 02110-1301, USm_
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; // The list of font families to be used.
00076 
00077     float m_specifiedSize;   // Specified CSS value. Independent of rendering issues such as integer
00078                              // rounding, minimum font sizes, and zooming.
00079     float m_computedSize;    // Computed size adjusted for the minimum font size and the zoom factor.  
00080 
00081     bool m_italic : 1;
00082     bool m_smallCaps : 1;
00083     bool m_isAbsoluteSize : 1;   // Whether or not CSS specified an explicit size
00084                                  // (logical sizes like "medium" don't count).
00085     unsigned m_weight : 8;
00086     unsigned m_genericFamily : 3; // GenericFamilyType
00087     bool m_usePrinterFont : 1;
00088     
00089     int m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium).  If so,
00090                            // then we can accurately translate across different generic families to adjust for different preference settings
00091                            // (e.g., 13px monospace vs. 16px everything else).  Sizes are 1-8 (like the HTML size values for <font>).
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

Generated on Wed Nov 21 20:04:17 2007 for Origyn Web Browser by Doxygen 1.5.3

pleyo.com
pleyo.com