#ifndef FontDescription_h
#define FontDescription_h
-#include "FontFamilyNames.h"
+#include "platform/FontFamilyNames.h"
+#include "platform/fonts/FixedPitchFontType.h"
#include "platform/fonts/FontCacheKey.h"
#include "platform/fonts/FontFamily.h"
#include "platform/fonts/FontFeatureSettings.h"
#include "platform/fonts/FontOrientation.h"
#include "platform/fonts/FontSmoothingMode.h"
-#include "platform/fonts/FontTraitsMask.h"
+#include "platform/fonts/FontTraits.h"
#include "platform/fonts/FontWidthVariant.h"
#include "platform/fonts/TextRenderingMode.h"
#include "platform/fonts/TypesettingFeatures.h"
#include "wtf/RefPtr.h"
-namespace WebCore {
-
-enum FontWeight {
- FontWeight100,
- FontWeight200,
- FontWeight300,
- FontWeight400,
- FontWeight500,
- FontWeight600,
- FontWeight700,
- FontWeight800,
- FontWeight900,
- FontWeightNormal = FontWeight400,
- FontWeightBold = FontWeight700
-};
+#include <unicode/uscript.h>
-enum FontItalic {
- FontItalicOff = 0,
- FontItalicOn = 1
-};
-
-enum FontSmallCaps {
- FontSmallCapsOff = 0,
- FontSmallCapsOn = 1
-};
+namespace blink {
class PLATFORM_EXPORT FontDescription {
public:
enum LigaturesState { NormalLigaturesState, DisabledLigaturesState, EnabledLigaturesState };
FontDescription()
- : m_specifiedSize(0)
+ : m_locale("en")
+ , m_specifiedSize(0)
, m_computedSize(0)
, m_letterSpacing(0)
, m_wordSpacing(0)
, m_orientation(Horizontal)
, m_nonCJKGlyphOrientation(NonCJKGlyphOrientationVerticalRight)
, m_widthVariant(RegularWidth)
- , m_italic(FontItalicOff)
- , m_smallCaps(FontSmallCapsOff)
+ , m_style(FontStyleNormal)
+ , m_variant(FontVariantNormal)
, m_isAbsoluteSize(false)
, m_weight(FontWeightNormal)
+ , m_stretch(FontStretchNormal)
, m_genericFamily(NoFamily)
- , m_usePrinterFont(false)
, m_kerning(AutoKerning)
, m_commonLigaturesState(NormalLigaturesState)
, m_discretionaryLigaturesState(NormalLigaturesState)
, m_historicalLigaturesState(NormalLigaturesState)
+ , m_contextualLigaturesState(NormalLigaturesState)
, m_keywordSize(0)
, m_fontSmoothing(AutoSmoothing)
, m_textRendering(AutoTextRendering)
- , m_isSpecifiedFont(false)
, m_script(USCRIPT_COMMON)
, m_syntheticBold(false)
, m_syntheticItalic(false)
bool operator==(const FontDescription&) const;
bool operator!=(const FontDescription& other) const { return !(*this == other); }
+ struct VariantLigatures {
+ VariantLigatures()
+ : common(NormalLigaturesState)
+ , discretionary(NormalLigaturesState)
+ , historical(NormalLigaturesState)
+ , contextual(NormalLigaturesState)
+ {
+ }
+
+ unsigned common : 2;
+ unsigned discretionary : 2;
+ unsigned historical : 2;
+ unsigned contextual : 2;
+ };
+
const FontFamily& family() const { return m_familyList; }
FontFamily& firstFamily() { return m_familyList; }
float specifiedSize() const { return m_specifiedSize; }
float computedSize() const { return m_computedSize; }
- FontItalic italic() const { return static_cast<FontItalic>(m_italic); }
+ FontStyle style() const { return static_cast<FontStyle>(m_style); }
int computedPixelSize() const { return int(m_computedSize + 0.5f); }
- FontSmallCaps smallCaps() const { return static_cast<FontSmallCaps>(m_smallCaps); }
+ FontVariant variant() const { return static_cast<FontVariant>(m_variant); }
bool isAbsoluteSize() const { return m_isAbsoluteSize; }
FontWeight weight() const { return static_cast<FontWeight>(m_weight); }
- FontWeight lighterWeight() const;
- FontWeight bolderWeight() const;
+ FontStretch stretch() const { return static_cast<FontStretch>(m_stretch); }
+ static FontWeight lighterWeight(FontWeight);
+ static FontWeight bolderWeight(FontWeight);
GenericFamilyType genericFamily() const { return static_cast<GenericFamilyType>(m_genericFamily); }
-#if OS(MACOSX)
- bool usePrinterFont() const { return false; }
-#else
- bool usePrinterFont() const { return m_usePrinterFont; }
-#endif
+
// only use fixed default size when there is only one font family, and that family is "monospace"
- bool useFixedDefaultSize() const { return genericFamily() == MonospaceFamily && !family().next() && family().family() == FontFamilyNames::webkit_monospace; }
+ FixedPitchFontType fixedPitchFontType() const
+ {
+ if (genericFamily() == MonospaceFamily && !family().next() && family().family() == FontFamilyNames::webkit_monospace)
+ return FixedPitchFont;
+ return NonFixedPitchFont;
+ }
Kerning kerning() const { return static_cast<Kerning>(m_kerning); }
+ VariantLigatures variantLigatures() const;
LigaturesState commonLigaturesState() const { return static_cast<LigaturesState>(m_commonLigaturesState); }
LigaturesState discretionaryLigaturesState() const { return static_cast<LigaturesState>(m_discretionaryLigaturesState); }
LigaturesState historicalLigaturesState() const { return static_cast<LigaturesState>(m_historicalLigaturesState); }
+ LigaturesState contextualLigaturesState() const { return static_cast<LigaturesState>(m_contextualLigaturesState); }
unsigned keywordSize() const { return m_keywordSize; }
FontSmoothingMode fontSmoothing() const { return static_cast<FontSmoothingMode>(m_fontSmoothing); }
- TextRenderingMode textRenderingMode() const { return static_cast<TextRenderingMode>(m_textRendering); }
+ TextRenderingMode textRendering() const { return static_cast<TextRenderingMode>(m_textRendering); }
UScriptCode script() const { return static_cast<UScriptCode>(m_script); }
+ const String& locale() const { return m_locale; }
bool isSyntheticBold() const { return m_syntheticBold; }
bool isSyntheticItalic() const { return m_syntheticItalic; }
bool useSubpixelPositioning() const { return m_subpixelTextPosition; }
- FontTraitsMask traitsMask() const;
+ FontTraits traits() const;
float wordSpacing() const { return m_wordSpacing; }
float letterSpacing() const { return m_letterSpacing; }
- bool isSpecifiedFont() const { return m_isSpecifiedFont; }
FontOrientation orientation() const { return static_cast<FontOrientation>(m_orientation); }
NonCJKGlyphOrientation nonCJKGlyphOrientation() const { return static_cast<NonCJKGlyphOrientation>(m_nonCJKGlyphOrientation); }
FontWidthVariant widthVariant() const { return static_cast<FontWidthVariant>(m_widthVariant); }
FontFeatureSettings* featureSettings() const { return m_featureSettings.get(); }
- FontDescription makeNormalFeatureSettings() const;
float effectiveFontSize() const; // Returns either the computedSize or the computedPixelSize
- FontCacheKey cacheKey(const AtomicString& familyName, FontTraitsMask desiredTraits = static_cast<FontTraitsMask>(0)) const;
+ FontCacheKey cacheKey(const FontFaceCreationParams&, FontTraits desiredTraits = FontTraits(0)) const;
void setFamily(const FontFamily& family) { m_familyList = family; }
void setComputedSize(float s) { m_computedSize = clampToFloat(s); }
void setSpecifiedSize(float s) { m_specifiedSize = clampToFloat(s); }
- void setItalic(FontItalic i) { m_italic = i; }
- void setItalic(bool i) { setItalic(i ? FontItalicOn : FontItalicOff); }
- void setSmallCaps(FontSmallCaps c) { m_smallCaps = c; }
- void setSmallCaps(bool c) { setSmallCaps(c ? FontSmallCapsOn : FontSmallCapsOff); }
+ void setStyle(FontStyle i) { m_style = i; }
+ void setVariant(FontVariant c) { m_variant = c; }
+ void setVariantLigatures(const VariantLigatures&);
void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
void setWeight(FontWeight w) { m_weight = w; }
+ void setStretch(FontStretch s) { m_stretch = s; }
void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = genericFamily; }
- void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
void setKerning(Kerning kerning) { m_kerning = kerning; updateTypesettingFeatures(); }
- void setCommonLigaturesState(LigaturesState commonLigaturesState) { m_commonLigaturesState = commonLigaturesState; updateTypesettingFeatures(); }
- void setDiscretionaryLigaturesState(LigaturesState discretionaryLigaturesState) { m_discretionaryLigaturesState = discretionaryLigaturesState; }
- void setHistoricalLigaturesState(LigaturesState historicalLigaturesState) { m_historicalLigaturesState = historicalLigaturesState; }
void setKeywordSize(unsigned s) { m_keywordSize = s; }
void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoothing; }
- void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = rendering; updateTypesettingFeatures(); }
- void setIsSpecifiedFont(bool isSpecifiedFont) { m_isSpecifiedFont = isSpecifiedFont; }
+ void setTextRendering(TextRenderingMode rendering) { m_textRendering = rendering; updateTypesettingFeatures(); }
void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
void setNonCJKGlyphOrientation(NonCJKGlyphOrientation orientation) { m_nonCJKGlyphOrientation = orientation; }
void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = widthVariant; }
void setScript(UScriptCode s) { m_script = s; }
+ void setLocale(const String& locale) { m_locale = locale; }
void setSyntheticBold(bool syntheticBold) { m_syntheticBold = syntheticBold; }
void setSyntheticItalic(bool syntheticItalic) { m_syntheticItalic = syntheticItalic; }
void setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) { m_featureSettings = settings; }
- void setTraitsMask(FontTraitsMask);
+ void setTraits(FontTraits);
void setWordSpacing(float s) { m_wordSpacing = s; }
void setLetterSpacing(float s) { m_letterSpacing = s; }
private:
FontFamily m_familyList; // The list of font families to be used.
RefPtr<FontFeatureSettings> m_featureSettings;
+ String m_locale;
void updateTypesettingFeatures() const;
unsigned m_widthVariant : 2; // FontWidthVariant
- unsigned m_italic : 1; // FontItalic
- unsigned m_smallCaps : 1; // FontSmallCaps
+ unsigned m_style : 1; // FontStyle
+ unsigned m_variant : 1; // FontVariant
unsigned m_isAbsoluteSize : 1; // Whether or not CSS specified an explicit size
// (logical sizes like "medium" don't count).
- unsigned m_weight : 8; // FontWeight
+ unsigned m_weight : 4; // FontWeight
+ unsigned m_stretch : 4; // FontStretch
unsigned m_genericFamily : 3; // GenericFamilyType
- unsigned m_usePrinterFont : 1;
unsigned m_kerning : 2; // Kerning
unsigned m_commonLigaturesState : 2;
unsigned m_discretionaryLigaturesState : 2;
unsigned m_historicalLigaturesState : 2;
+ unsigned m_contextualLigaturesState : 2;
unsigned m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium). If so,
// then we can accurately translate across different generic families to adjust for different preference settings
unsigned m_fontSmoothing : 2; // FontSmoothingMode
unsigned m_textRendering : 2; // TextRenderingMode
- unsigned m_isSpecifiedFont : 1; // True if a web page specifies a non-generic font family as the first font family.
unsigned m_script : 7; // Used to help choose an appropriate font for generic font families.
unsigned m_syntheticBold : 1;
unsigned m_syntheticItalic : 1;
&& m_computedSize == other.m_computedSize
&& m_letterSpacing == other.m_letterSpacing
&& m_wordSpacing == other.m_wordSpacing
- && m_italic == other.m_italic
- && m_smallCaps == other.m_smallCaps
+ && m_style == other.m_style
+ && m_variant == other.m_variant
&& m_isAbsoluteSize == other.m_isAbsoluteSize
&& m_weight == other.m_weight
+ && m_stretch == other.m_stretch
&& m_genericFamily == other.m_genericFamily
- && m_usePrinterFont == other.m_usePrinterFont
&& m_kerning == other.m_kerning
&& m_commonLigaturesState == other.m_commonLigaturesState
&& m_discretionaryLigaturesState == other.m_discretionaryLigaturesState
&& m_historicalLigaturesState == other.m_historicalLigaturesState
+ && m_contextualLigaturesState == other.m_contextualLigaturesState
&& m_keywordSize == other.m_keywordSize
&& m_fontSmoothing == other.m_fontSmoothing
&& m_textRendering == other.m_textRendering
- && m_isSpecifiedFont == other.m_isSpecifiedFont
&& m_orientation == other.m_orientation
&& m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation
&& m_widthVariant == other.m_widthVariant
&& m_subpixelTextPosition == other.m_subpixelTextPosition;
}
-}
+} // namespace blink
#endif