• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KHTML

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, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
00006  * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Library General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Library General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Library General Public License
00019  * along with this library; see the file COPYING.LIother.m_  If not, write to
00020  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021  * Boston, MA 02110-1301, USm_
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; // The list of font families to be used.
00099 
00100     float m_specifiedSize;   // Specified CSS value. Independent of rendering issues such as integer
00101                              // rounding, minimum font sizes, and zooming.
00102     float m_computedSize;    // Computed size adjusted for the minimum font size and the zoom factor.  
00103 
00104     bool m_italic : 1;
00105     bool m_smallCaps : 1;
00106     bool m_isAbsoluteSize : 1;   // Whether or not CSS specified an explicit size
00107                                  // (logical sizes like "medium" don't count).
00108     unsigned m_weight : 8; // FontWeight
00109     unsigned m_genericFamily : 3; // GenericFamilyType
00110     bool m_usePrinterFont : 1;
00111 
00112     unsigned m_renderingMode : 1;  // Used to switch between CG and GDI text on Windows.
00113 
00114     int m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium).  If so,
00115                            // then we can accurately translate across different generic families to adjust for different preference settings
00116                            // (e.g., 13px monospace vs. 16px everything else).  Sizes are 1-8 (like the HTML size values for <font>).
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

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal