Commit 6be27ae2 authored by Maciej Suminski's avatar Maciej Suminski

Glyphs and their bounding boxes are held in vectors instead of deque.

Moved scaling of font glyphs to the moment when they are created (eliminated a few multiplications unnecessary variables).
Changed some magic numbers into constants.
parent ca11855f
This diff is collapsed.
...@@ -39,7 +39,7 @@ namespace KIGFX ...@@ -39,7 +39,7 @@ namespace KIGFX
class GAL; class GAL;
typedef std::deque< std::deque<VECTOR2D> > GLYPH; typedef std::deque< std::deque<VECTOR2D> > GLYPH;
typedef std::deque<GLYPH> GLYPH_LIST; typedef std::vector<GLYPH> GLYPH_LIST;
/** /**
* @brief Class STROKE_FONT implements stroke font drawing. * @brief Class STROKE_FONT implements stroke font drawing.
...@@ -55,8 +55,6 @@ public: ...@@ -55,8 +55,6 @@ public:
/// Destructor /// Destructor
~STROKE_FONT(); ~STROKE_FONT();
// TODO Load font from a text file
/** /**
* @brief Load the new stroke font. * @brief Load the new stroke font.
* *
...@@ -75,16 +73,6 @@ public: ...@@ -75,16 +73,6 @@ public:
*/ */
void Draw( wxString aText, const VECTOR2D& aPosition, double aRotationAngle ); void Draw( wxString aText, const VECTOR2D& aPosition, double aRotationAngle );
/**
* @brief Set the scale factor of the font for the glyph size.
*
* @param aScaleFactor is the scale factor of the font.
*/
inline void SetScaleFactor( const double aScaleFactor )
{
m_scaleFactor = aScaleFactor;
}
/** /**
* @brief Set the glyph size. * @brief Set the glyph size.
* *
...@@ -158,13 +146,19 @@ public: ...@@ -158,13 +146,19 @@ public:
private: private:
GAL* m_gal; ///< Pointer to the GAL GAL* m_gal; ///< Pointer to the GAL
GLYPH_LIST m_glyphs; ///< Glyph list GLYPH_LIST m_glyphs; ///< Glyph list
std::deque<BOX2D> m_glyphBoundingBoxes; ///< Bounding boxes of the glyphs std::vector<BOX2D> m_glyphBoundingBoxes; ///< Bounding boxes of the glyphs
double m_scaleFactor; ///< Scale factor for the glyph
VECTOR2D m_glyphSize; ///< Size of the glyphs VECTOR2D m_glyphSize; ///< Size of the glyphs
EDA_TEXT_HJUSTIFY_T m_horizontalJustify; ///< Horizontal justification EDA_TEXT_HJUSTIFY_T m_horizontalJustify; ///< Horizontal justification
EDA_TEXT_VJUSTIFY_T m_verticalJustify; ///< Vertical justification EDA_TEXT_VJUSTIFY_T m_verticalJustify; ///< Vertical justification
bool m_bold, m_italic, m_mirrored, m_overbar; ///< Properties of text bool m_bold, m_italic, m_mirrored, m_overbar; ///< Properties of text
/**
* @brief Returns a single line height using current settings.
*
* @return The line height.
*/
int getInterline() const;
/** /**
* @brief Compute the bounding box of a given glyph. * @brief Compute the bounding box of a given glyph.
* *
...@@ -174,6 +168,14 @@ private: ...@@ -174,6 +168,14 @@ private:
*/ */
BOX2D computeBoundingBox( const GLYPH& aGlyph, const VECTOR2D& aGlyphBoundingX ) const; BOX2D computeBoundingBox( const GLYPH& aGlyph, const VECTOR2D& aGlyphBoundingX ) const;
/**
* @brief Draws a single line of text. Multiline texts should be split before using the
* function.
*
* @param aText is the text to be drawn.
*/
void drawSingleLineText( const wxString& aText );
/** /**
* @brief Compute the size of a given text. * @brief Compute the size of a given text.
* *
...@@ -182,7 +184,34 @@ private: ...@@ -182,7 +184,34 @@ private:
*/ */
VECTOR2D computeTextSize( const wxString& aText ) const; VECTOR2D computeTextSize( const wxString& aText ) const;
static const double LINE_HEIGHT_RATIO; /**
* @brief Returns number of lines for a given text.
*
* @param aText is the text to be checked.
* @return Number of lines of aText.
*/
unsigned int linesCount( const wxString& aText ) const
{
wxString::const_iterator it, itEnd;
unsigned int lines = 1;
for( it = aText.begin(), itEnd = aText.end(); it != itEnd; ++it )
{
if( *it == '\n' )
++lines;
}
return lines;
}
///> Factor that determines relative height of overbar.
static const double OVERBAR_HEIGHT;
///> Factor that determines relative line width for bold text.
static const double BOLD_FACTOR;
///> Scale factor for the glyph
static const double HERSHEY_SCALE;
}; };
} // namespace KIGFX } // namespace KIGFX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment