2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2013 Google Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
26 #include "core/CSSValueKeywords.h"
27 #include "core/css/FontSize.h"
28 #include "platform/fonts/FontDescription.h"
29 #include "platform/heap/Handle.h"
30 #include "wtf/PassRefPtr.h"
38 class FontDescriptionChangeScope;
42 WTF_MAKE_NONCOPYABLE(FontBuilder);
44 FontBuilder(const Document&);
46 void setStyle(RenderStyle* style) { m_style = style; }
47 void setInitial(float effectiveZoom);
49 void didChangeFontParameters(bool);
51 void inheritFrom(const FontDescription&);
53 FontFamily standardFontFamily() const;
54 AtomicString standardFontFamilyName() const;
55 AtomicString genericFontFamilyName(FontDescription::GenericFamilyType) const;
57 void setWeight(FontWeight);
58 void setSize(const FontDescription::Size&);
59 void setStretch(FontStretch);
60 void setFamilyDescription(const FontDescription::FamilyDescription&);
61 void setFeatureSettings(PassRefPtr<FontFeatureSettings>);
62 void setScript(const String& locale);
63 void setStyle(FontStyle);
64 void setVariant(FontVariant);
65 void setVariantLigatures(const FontDescription::VariantLigatures&);
66 void setTextRendering(TextRenderingMode);
67 void setKerning(FontDescription::Kerning);
68 void setFontSmoothing(FontSmoothingMode);
70 // FIXME: These need to just vend a Font object eventually.
71 void createFont(PassRefPtrWillBeRawPtr<FontSelector>, const RenderStyle* parentStyle, RenderStyle*);
73 void createFontForDocument(PassRefPtrWillBeRawPtr<FontSelector>, RenderStyle*);
75 // FIXME: These should not be necessary eventually.
76 void setFontDirty(bool fontDirty) { m_fontDirty = fontDirty; }
77 // FIXME: This is only used by an ASSERT in StyleResolver. Remove?
78 bool fontDirty() const { return m_fontDirty; }
80 static FontDescription::FamilyDescription initialFamilyDescription() { return FontDescription::FamilyDescription(initialGenericFamily()); }
81 static FontFeatureSettings* initialFeatureSettings() { return nullptr; }
82 static FontDescription::GenericFamilyType initialGenericFamily() { return FontDescription::StandardFamily; }
83 static FontDescription::Size initialSize() { return FontDescription::Size(FontSize::initialKeywordSize(), 0.0f, false); }
84 static TextRenderingMode initialTextRendering() { return AutoTextRendering; }
85 static FontVariant initialVariant() { return FontVariantNormal; }
86 static FontDescription::VariantLigatures initialVariantLigatures() { return FontDescription::VariantLigatures(); }
87 static FontStyle initialStyle() { return FontStyleNormal; }
88 static FontDescription::Kerning initialKerning() { return FontDescription::AutoKerning; }
89 static FontSmoothingMode initialFontSmoothing() { return AutoSmoothing; }
90 static FontStretch initialStretch() { return FontStretchNormal; }
91 static FontWeight initialWeight() { return FontWeightNormal; }
93 friend class FontDescriptionChangeScope;
97 void setFamilyDescription(FontDescription&, const FontDescription::FamilyDescription&);
98 void setSize(FontDescription&, const FontDescription::Size&);
99 void checkForOrientationChange(RenderStyle*);
100 // This function fixes up the default font size if it detects that the current generic font family has changed. -dwh
101 void checkForGenericFamilyChange(RenderStyle*, const RenderStyle* parentStyle);
102 void updateComputedSize(RenderStyle*, const RenderStyle* parentStyle);
103 void updateComputedSize(FontDescription&, RenderStyle*);
105 float getComputedSizeFromSpecifiedSize(FontDescription&, float effectiveZoom, float specifiedSize);
107 const Document& m_document;
108 // FIXME: This member is here on a short-term lease. The plan is to remove
109 // any notion of RenderStyle from here, allowing FontBuilder to build Font objects
110 // directly, rather than as a byproduct of calling RenderStyle::setFontDescription.
111 // FontDescriptionChangeScope should be the only consumer of this member.
112 // If you're using it, U R DOIN IT WRONG.
113 RenderStyle* m_style;
115 // Fontbuilder is responsbile for creating the Font()
116 // object on RenderStyle from various other font-related
117 // properties on RenderStyle. Whenever one of those
118 // is changed, FontBuilder tracks the need to update
119 // style->font() with this bool.
122 friend class FontBuilderTest;