Browse Source

added BaselineDistance scale

dmuratshin 9 years ago
parent
commit
e4a54f2257
4 changed files with 6 additions and 10 deletions
  1. 0 7
      oxygine/src/Font.cpp
  2. 1 2
      oxygine/src/Font.h
  3. 4 0
      oxygine/src/TextStyle.h
  4. 1 1
      oxygine/src/text_utils/Aligner.cpp

+ 0 - 7
oxygine/src/Font.cpp

@@ -32,8 +32,6 @@ namespace oxygine
         _sdf = sdf;
         _sdf = sdf;
         _size = realSize;
         _size = realSize;
         _baselineDistance = baselineDistance;
         _baselineDistance = baselineDistance;
-        _lineHeight = lineHeight;
-        //_glyphs.reserve(200);
     }
     }
 
 
     void Font::addGlyph(const glyph& gl)
     void Font::addGlyph(const glyph& gl)
@@ -98,11 +96,6 @@ namespace oxygine
         return _scale;
         return _scale;
     }
     }
 
 
-    int Font::getLineHeight() const
-    {
-        return _lineHeight;
-    }
-
     bool Font::isSDF() const
     bool Font::isSDF() const
     {
     {
         return _sdf;
         return _sdf;

+ 1 - 2
oxygine/src/Font.h

@@ -58,12 +58,12 @@ namespace oxygine
         void sortGlyphs() {}
         void sortGlyphs() {}
 
 
         void setScale(float scale) { _scale = scale; }
         void setScale(float scale) { _scale = scale; }
+        void setBaselineDistance(int d) { _baselineDistance = d; }
 
 
         const glyph*    getGlyph(int code, const glyphOptions& opt) const;
         const glyph*    getGlyph(int code, const glyphOptions& opt) const;
         int             getBaselineDistance() const;
         int             getBaselineDistance() const;
         int             getSize() const;
         int             getSize() const;
         float           getScale() const;
         float           getScale() const;
-        int             getLineHeight() const;
         bool            isSDF() const;
         bool            isSDF() const;
 
 
     protected:
     protected:
@@ -83,6 +83,5 @@ namespace oxygine
 
 
         int _size;
         int _size;
         int _baselineDistance;
         int _baselineDistance;
-        int _lineHeight;
     };
     };
 }
 }

+ 4 - 0
oxygine/src/TextStyle.h

@@ -41,6 +41,7 @@ namespace oxygine
             outline(0.0f),
             outline(0.0f),
             outlineColor(Color::Black),
             outlineColor(Color::Black),
             weight(0.5f),
             weight(0.5f),
+            baselineScale(1.0f),
             options(0) {}
             options(0) {}
 
 
         const ResFont* font;
         const ResFont* font;
@@ -66,6 +67,7 @@ namespace oxygine
         float outline;//works only with SD fonts, disabled by default = 0.0f, 0.5 - max outline
         float outline;//works only with SD fonts, disabled by default = 0.0f, 0.5 - max outline
         Color outlineColor;//works only with SD fonts
         Color outlineColor;//works only with SD fonts
         float weight;//works only with SD fonts, font weight, default = 0.5f,  0.0 - bold, 1.0 - thin
         float weight;//works only with SD fonts, font weight, default = 0.5f,  0.0 - bold, 1.0 - thin
+        float baselineScale;//baseline distance multiplier
 
 
 
 
 
 
@@ -83,6 +85,8 @@ namespace oxygine
         TextStyle alignMiddle() const { TextStyle st = *this; st.vAlign = VALIGN_MIDDLE; st.hAlign = HALIGN_MIDDLE; return st; }
         TextStyle alignMiddle() const { TextStyle st = *this; st.vAlign = VALIGN_MIDDLE; st.hAlign = HALIGN_MIDDLE; return st; }
 
 
         TextStyle withHOffset(int offset) const { TextStyle st = *this; st.linesOffset = offset; return st; }
         TextStyle withHOffset(int offset) const { TextStyle st = *this; st.linesOffset = offset; return st; }
+        TextStyle withBaselineScale(float s) const { TextStyle st = *this; st.baselineScale = s; return st; }
+
         TextStyle withKerning(int kerning) const { TextStyle st = *this; st.kerning = kerning; return st; }
         TextStyle withKerning(int kerning) const { TextStyle st = *this; st.kerning = kerning; return st; }
         TextStyle withMultiline(bool multiline = true) const { TextStyle st = *this; st.multiline = multiline; return st; }
         TextStyle withMultiline(bool multiline = true) const { TextStyle st = *this; st.multiline = multiline; return st; }
         TextStyle withColor(const Color& color) const { TextStyle st = *this; st.color = color; return st; }
         TextStyle withColor(const Color& color) const { TextStyle st = *this; st.color = color; return st; }

+ 1 - 1
oxygine/src/text_utils/Aligner.cpp

@@ -102,7 +102,7 @@ namespace oxygine
 
 
         int Aligner::getLineSkip() const
         int Aligner::getLineSkip() const
         {
         {
-            return _font->getBaselineDistance() + getStyle().linesOffset;
+            return _font->getBaselineDistance() * getStyle().baselineScale + getStyle().linesOffset;
         }
         }
 
 
         void Aligner::_alignLine(line& ln)
         void Aligner::_alignLine(line& ln)