Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: webkit/pending/FontDescription.h

Issue 6500: Cleaning up the unfork (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/pending/FontCache.cpp ('k') | webkit/pending/Frame.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIother.m_ If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USm_
22 *
23 */
24
25 #ifndef FontDescription_h
26 #define FontDescription_h
27
28 #include "FontFamily.h"
29 #include "FontRenderingMode.h"
30 #include "FontTraitsMask.h"
31 #include <unicode/uscript.h>
32
33 namespace WebCore {
34
35 enum FontWeight {
36 FontWeight100,
37 FontWeight200,
38 FontWeight300,
39 FontWeight400,
40 FontWeight500,
41 FontWeight600,
42 FontWeight700,
43 FontWeight800,
44 FontWeight900,
45 FontWeightNormal = FontWeight400,
46 FontWeightBold = FontWeight700
47 };
48
49 class FontDescription {
50 public:
51 enum GenericFamilyType { NoFamily, StandardFamily, SerifFamily, SansSerifFam ily,
52 MonospaceFamily, CursiveFamily, FantasyFamily };
53
54 FontDescription()
55 : m_specifiedSize(0)
56 , m_computedSize(0)
57 , m_italic(false)
58 , m_smallCaps(false)
59 , m_isAbsoluteSize(false)
60 , m_weight(FontWeightNormal)
61 , m_genericFamily(NoFamily)
62 , m_usePrinterFont(false)
63 , m_renderingMode(NormalRenderingMode)
64 , m_keywordSize(0)
65 , m_dominantScript(USCRIPT_INVALID_CODE)
66 {
67 }
68
69 bool operator==(const FontDescription&) const;
70 bool operator!=(const FontDescription& other) const { return !(*this == othe r); }
71
72 const FontFamily& family() const { return m_familyList; }
73 FontFamily& firstFamily() { return m_familyList; }
74 float specifiedSize() const { return m_specifiedSize; }
75 float computedSize() const { return m_computedSize; }
76 bool italic() const { return m_italic; }
77 int computedPixelSize() const { return int(m_computedSize + 0.5f); }
78 bool smallCaps() const { return m_smallCaps; }
79 bool isAbsoluteSize() const { return m_isAbsoluteSize; }
80 FontWeight weight() const { return static_cast<FontWeight>(m_weight); }
81 FontWeight lighterWeight() const;
82 FontWeight bolderWeight() const;
83 GenericFamilyType genericFamily() const { return static_cast<GenericFamilyTy pe>(m_genericFamily); }
84 bool usePrinterFont() const { return m_usePrinterFont; }
85 FontRenderingMode renderingMode() const { return static_cast<FontRenderingMo de>(m_renderingMode); }
86 int keywordSize() const { return m_keywordSize; }
87 UScriptCode dominantScript() const { return m_dominantScript; }
88
89 FontTraitsMask traitsMask() const;
90
91 void setFamily(const FontFamily& family) { m_familyList = family; }
92 void setComputedSize(float s) { m_computedSize = s; }
93 void setSpecifiedSize(float s) { m_specifiedSize = s; }
94 void setItalic(bool i) { m_italic = i; }
95 void setSmallCaps(bool c) { m_smallCaps = c; }
96 void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
97 void setWeight(FontWeight w) { m_weight = w; }
98 void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = g enericFamily; }
99 void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
100 void setRenderingMode(FontRenderingMode mode) { m_renderingMode = mode; }
101 void setKeywordSize(int s) { m_keywordSize = s; }
102 void setDominantScript(UScriptCode s) { m_dominantScript = s; }
103
104 private:
105 FontFamily m_familyList; // The list of font families to be used.
106
107 float m_specifiedSize; // Specified CSS value. Independent of rendering is sues such as integer
108 // rounding, minimum font sizes, and zooming.
109 float m_computedSize; // Computed size adjusted for the minimum font size and the zoom factor.
110
111 bool m_italic : 1;
112 bool m_smallCaps : 1;
113 bool m_isAbsoluteSize : 1; // Whether or not CSS specified an explicit siz e
114 // (logical sizes like "medium" don't count).
115 unsigned m_weight : 8; // FontWeight
116 unsigned m_genericFamily : 3; // GenericFamilyType
117 bool m_usePrinterFont : 1;
118
119 unsigned m_renderingMode : 1; // Used to switch between CG and GDI text on Windows.
120
121 int m_keywordSize : 4; // We cache whether or not a font is currently repres ented by a CSS keyword (e.g., medium). If so,
122 // then we can accurately translate across different generic families to adjust for different preference settings
123 // (e.g., 13px monospace vs. 16px everything else). Sizes are 1-8 (like the HTML size values for <font>).
124 UScriptCode m_dominantScript; // See the comment in Document.h
125
126 };
127
128 inline bool FontDescription::operator==(const FontDescription& other) const
129 {
130 return m_familyList == other.m_familyList
131 && m_specifiedSize == other.m_specifiedSize
132 && m_computedSize == other.m_computedSize
133 && m_italic == other.m_italic
134 && m_smallCaps == other.m_smallCaps
135 && m_isAbsoluteSize == other.m_isAbsoluteSize
136 && m_weight == other.m_weight
137 && m_genericFamily == other.m_genericFamily
138 && m_usePrinterFont == other.m_usePrinterFont
139 && m_renderingMode == other.m_renderingMode
140 && m_keywordSize == other.m_keywordSize;
141 }
142
143 }
144
145 #endif
OLDNEW
« no previous file with comments | « webkit/pending/FontCache.cpp ('k') | webkit/pending/Frame.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698