1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
* All rights reserved.
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef FontBuilder_h
#define FontBuilder_h
#include "core/CSSValueKeywords.h"
#include "core/CoreExport.h"
#include "core/css/FontSize.h"
#include "platform/fonts/FontDescription.h"
#include "platform/fonts/FontVariantNumeric.h"
#include "platform/heap/Handle.h"
#include "wtf/PassRefPtr.h"
namespace blink {
class FontSelector;
class ComputedStyle;
class CORE_EXPORT FontBuilder {
STACK_ALLOCATED();
WTF_MAKE_NONCOPYABLE(FontBuilder);
public:
FontBuilder(const Document&);
void setInitial(float effectiveZoom);
void didChangeEffectiveZoom();
void didChangeTextOrientation();
void didChangeWritingMode();
FontFamily standardFontFamily() const;
AtomicString standardFontFamilyName() const;
AtomicString genericFontFamilyName(FontDescription::GenericFamilyType) const;
float fontSizeForKeyword(unsigned keyword, bool isMonospace) const;
void setWeight(FontWeight);
void setSize(const FontDescription::Size&);
void setSizeAdjust(const float aspectValue);
void setStretch(FontStretch);
void setFamilyDescription(const FontDescription::FamilyDescription&);
void setFeatureSettings(PassRefPtr<FontFeatureSettings>);
void setLocale(PassRefPtr<const LayoutLocale>);
void setStyle(FontStyle);
void setVariantCaps(FontDescription::FontVariantCaps);
void setVariantLigatures(const FontDescription::VariantLigatures&);
void setVariantNumeric(const FontVariantNumeric&);
void setTextRendering(TextRenderingMode);
void setKerning(FontDescription::Kerning);
void setFontSmoothing(FontSmoothingMode);
void setVariationSettings(PassRefPtr<FontVariationSettings>);
// FIXME: These need to just vend a Font object eventually.
void createFont(FontSelector*, ComputedStyle&);
void createFontForDocument(FontSelector*, ComputedStyle&);
bool fontDirty() const { return m_flags; }
static FontDescription::FamilyDescription initialFamilyDescription() {
return FontDescription::FamilyDescription(initialGenericFamily());
}
static FontFeatureSettings* initialFeatureSettings() { return nullptr; }
static FontVariationSettings* initialVariationSettings() { return nullptr; }
static FontDescription::GenericFamilyType initialGenericFamily() {
return FontDescription::StandardFamily;
}
static FontDescription::Size initialSize() {
return FontDescription::Size(FontSize::initialKeywordSize(), 0.0f, false);
}
static float initialSizeAdjust() { return FontSizeAdjustNone; }
static TextRenderingMode initialTextRendering() { return AutoTextRendering; }
static FontDescription::FontVariantCaps initialVariantCaps() {
return FontDescription::CapsNormal;
}
static FontDescription::VariantLigatures initialVariantLigatures() {
return FontDescription::VariantLigatures();
}
static FontVariantNumeric initialVariantNumeric() {
return FontVariantNumeric();
};
static LayoutLocale* initialLocale() { return nullptr; }
static FontStyle initialStyle() { return FontStyleNormal; }
static FontDescription::Kerning initialKerning() {
return FontDescription::AutoKerning;
}
static FontSmoothingMode initialFontSmoothing() { return AutoSmoothing; }
static FontStretch initialStretch() { return FontStretchNormal; }
static FontWeight initialWeight() { return FontWeightNormal; }
private:
void setFamilyDescription(FontDescription&,
const FontDescription::FamilyDescription&);
void setSize(FontDescription&, const FontDescription::Size&);
void updateOrientation(FontDescription&, const ComputedStyle&);
// This function fixes up the default font size if it detects that the current
// generic font family has changed. -dwh
void checkForGenericFamilyChange(const FontDescription&, FontDescription&);
void updateSpecifiedSize(FontDescription&, const ComputedStyle&);
void updateComputedSize(FontDescription&, const ComputedStyle&);
void updateAdjustedSize(FontDescription&,
const ComputedStyle&,
FontSelector*);
float getComputedSizeFromSpecifiedSize(FontDescription&,
float effectiveZoom,
float specifiedSize);
Member<const Document> m_document;
FontDescription m_fontDescription;
enum class PropertySetFlag {
Weight,
Size,
Stretch,
Family,
FeatureSettings,
Locale,
Style,
SizeAdjust,
VariantCaps,
VariantLigatures,
VariantNumeric,
VariationSettings,
TextRendering,
Kerning,
FontSmoothing,
EffectiveZoom,
TextOrientation,
WritingMode
};
void set(PropertySetFlag flag) { m_flags |= (1 << unsigned(flag)); }
bool isSet(PropertySetFlag flag) const {
return m_flags & (1 << unsigned(flag));
}
unsigned m_flags;
};
} // namespace blink
#endif
|