Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / fonts / FontDescription.h
index 8634fc6..e98c663 100644 (file)
@@ -34,6 +34,7 @@
 #include "platform/fonts/FontTraitsMask.h"
 #include "platform/fonts/FontWidthVariant.h"
 #include "platform/fonts/TextRenderingMode.h"
+#include "platform/fonts/TypesettingFeatures.h"
 #include "platform/text/NonCJKGlyphOrientation.h"
 #include "wtf/MathExtras.h"
 
@@ -77,6 +78,8 @@ public:
     FontDescription()
         : m_specifiedSize(0)
         , m_computedSize(0)
+        , m_letterSpacing(0)
+        , m_wordSpacing(0)
         , m_orientation(Horizontal)
         , m_nonCJKGlyphOrientation(NonCJKGlyphOrientationVerticalRight)
         , m_widthVariant(RegularWidth)
@@ -95,6 +98,10 @@ public:
         , m_textRendering(AutoTextRendering)
         , m_isSpecifiedFont(false)
         , m_script(USCRIPT_COMMON)
+        , m_syntheticBold(false)
+        , m_syntheticItalic(false)
+        , m_subpixelTextPosition(s_useSubpixelTextPositioning)
+        , m_typesettingFeatures(s_defaultTypesettingFeatures)
     {
     }
 
@@ -113,7 +120,11 @@ public:
     FontWeight lighterWeight() const;
     FontWeight bolderWeight() const;
     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; }
     Kerning kerning() const { return static_cast<Kerning>(m_kerning); }
@@ -124,8 +135,13 @@ public:
     FontSmoothingMode fontSmoothing() const { return static_cast<FontSmoothingMode>(m_fontSmoothing); }
     TextRenderingMode textRenderingMode() const { return static_cast<TextRenderingMode>(m_textRendering); }
     UScriptCode script() const { return static_cast<UScriptCode>(m_script); }
+    bool isSyntheticBold() const { return m_syntheticBold; }
+    bool isSyntheticItalic() const { return m_syntheticItalic; }
+    bool useSubpixelPositioning() const { return m_subpixelTextPosition; }
 
     FontTraitsMask traitsMask() 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); }
@@ -146,33 +162,47 @@ public:
     void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
     void setWeight(FontWeight w) { m_weight = w; }
     void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = genericFamily; }
-#if OS(MACOSX)
-    void setUsePrinterFont(bool) { }
-#else
     void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
-#endif
-    void setKerning(Kerning kerning) { m_kerning = kerning; }
-    void setCommonLigaturesState(LigaturesState commonLigaturesState) { m_commonLigaturesState = commonLigaturesState; }
+    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; }
+    void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = rendering; updateTypesettingFeatures(); }
     void setIsSpecifiedFont(bool isSpecifiedFont) { m_isSpecifiedFont = isSpecifiedFont; }
     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 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 setWordSpacing(float s) { m_wordSpacing = s; }
+    void setLetterSpacing(float s) { m_letterSpacing = s; }
+
+    TypesettingFeatures typesettingFeatures() const { return static_cast<TypesettingFeatures>(m_typesettingFeatures); }
+
+    static void setSubpixelPositioning(bool b) { s_useSubpixelTextPositioning = b; }
+    static bool subpixelPositioning() { return s_useSubpixelTextPositioning; }
+
+    static void setDefaultTypesettingFeatures(TypesettingFeatures);
+    static TypesettingFeatures defaultTypesettingFeatures();
 
 private:
     FontFamily m_familyList; // The list of font families to be used.
     RefPtr<FontFeatureSettings> m_featureSettings;
 
+    void updateTypesettingFeatures() const;
+
     float m_specifiedSize;   // Specified CSS value. Independent of rendering issues such as integer
                              // rounding, minimum font sizes, and zooming.
     float m_computedSize;    // Computed size adjusted for the minimum font size and the zoom factor.
 
+    float m_letterSpacing;
+    float m_wordSpacing;
+
     unsigned m_orientation : 1; // FontOrientation - Whether the font is rendering on a horizontal line or a vertical line.
     unsigned m_nonCJKGlyphOrientation : 1; // NonCJKGlyphOrientation - Only used by vertical text. Determines the default orientation for non-ideograph glyphs.
 
@@ -200,6 +230,15 @@ private:
     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;
+    unsigned m_subpixelTextPosition : 1;
+
+    mutable unsigned m_typesettingFeatures : 2; // TypesettingFeatures
+
+    static TypesettingFeatures s_defaultTypesettingFeatures;
+
+    static bool s_useSubpixelTextPositioning;
 };
 
 inline bool FontDescription::operator==(const FontDescription& other) const
@@ -207,6 +246,8 @@ inline bool FontDescription::operator==(const FontDescription& other) const
     return m_familyList == other.m_familyList
         && m_specifiedSize == other.m_specifiedSize
         && 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_isAbsoluteSize == other.m_isAbsoluteSize
@@ -225,7 +266,10 @@ inline bool FontDescription::operator==(const FontDescription& other) const
         && m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation
         && m_widthVariant == other.m_widthVariant
         && m_script == other.m_script
-        && m_featureSettings == other.m_featureSettings;
+        && m_syntheticBold == other.m_syntheticBold
+        && m_syntheticItalic == other.m_syntheticItalic
+        && m_featureSettings == other.m_featureSettings
+        && m_subpixelTextPosition == other.m_subpixelTextPosition;
 }
 
 }