Adjust stroke font output to match v6 output
Many minor tweaks were added that changed the output of the stroke font
from v5/v6. These offsets changed the gerber output expected. This
reverts the changes to something much closer to the v6 output. It is
not pixel-perfect but gets very close on most texts.
Fixes https://gitlab.com/kicad/code/kicad/issues/14609
(cherry picked from commit 72267cf9b0
)
This commit is contained in:
parent
3efdc963d8
commit
81be16d058
|
@ -188,10 +188,11 @@ void FONT::Draw( KIGFX::GAL* aGal, const wxString& aText, const VECTOR2I& aPosit
|
|||
*/
|
||||
VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
|
||||
const std::unique_ptr<MARKUP::NODE>& aNode, const VECTOR2I& aPosition,
|
||||
const KIFONT::FONT* aFont, const VECTOR2I& aSize, const EDA_ANGLE& aAngle,
|
||||
bool aMirror, const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle )
|
||||
const KIFONT::FONT* aFont, const VECTOR2I& aSize, const VECTOR2I& aOffset,
|
||||
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
|
||||
TEXT_STYLE_FLAGS aTextStyle )
|
||||
{
|
||||
VECTOR2I nextPosition = aPosition;
|
||||
VECTOR2I nextPosition = aPosition + aOffset;
|
||||
bool drawUnderline = false;
|
||||
bool drawOverbar = false;
|
||||
|
||||
|
@ -214,7 +215,7 @@ VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* a
|
|||
BOX2I bbox;
|
||||
|
||||
nextPosition = aFont->GetTextAsGlyphs( &bbox, aGlyphs, aNode->asWxString(), aSize,
|
||||
aPosition, aAngle, aMirror, aOrigin,
|
||||
nextPosition, aAngle, aMirror, aOrigin,
|
||||
textStyle );
|
||||
|
||||
if( aBoundingBox )
|
||||
|
@ -229,7 +230,7 @@ VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* a
|
|||
for( const std::unique_ptr<MARKUP::NODE>& child : aNode->children )
|
||||
{
|
||||
nextPosition = drawMarkup( aBoundingBox, aGlyphs, child, nextPosition, aFont, aSize,
|
||||
aAngle, aMirror, aOrigin, textStyle );
|
||||
VECTOR2I(), aAngle, aMirror, aOrigin, textStyle );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,13 +284,13 @@ VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* a
|
|||
|
||||
VECTOR2I FONT::drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
|
||||
const wxString& aText, const VECTOR2I& aPosition, const VECTOR2I& aSize,
|
||||
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
|
||||
TEXT_STYLE_FLAGS aTextStyle ) const
|
||||
const VECTOR2I& aOffset, const EDA_ANGLE& aAngle, bool aMirror,
|
||||
const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) const
|
||||
{
|
||||
MARKUP::MARKUP_PARSER markupParser( TO_UTF8( aText ) );
|
||||
std::unique_ptr<MARKUP::NODE> root = markupParser.Parse();
|
||||
|
||||
return ::drawMarkup( aBoundingBox, aGlyphs, root, aPosition, this, aSize, aAngle, aMirror,
|
||||
return ::drawMarkup( aBoundingBox, aGlyphs, root, aPosition, this, aSize, aOffset, aAngle, aMirror,
|
||||
aOrigin, aTextStyle );
|
||||
}
|
||||
|
||||
|
@ -303,7 +304,13 @@ void FONT::drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const wxSt
|
|||
return;
|
||||
|
||||
TEXT_STYLE_FLAGS textStyle = 0;
|
||||
VECTOR2I offset;
|
||||
|
||||
if( !IsOutline() )
|
||||
{
|
||||
offset.x = aGal->GetLineWidth() / 1.52;
|
||||
offset.y = -aGal->GetLineWidth() * 0.052;
|
||||
}
|
||||
if( aItalic )
|
||||
textStyle |= TEXT_STYLE::ITALIC;
|
||||
|
||||
|
@ -312,7 +319,7 @@ void FONT::drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const wxSt
|
|||
|
||||
std::vector<std::unique_ptr<GLYPH>> glyphs;
|
||||
|
||||
(void) drawMarkup( aBoundingBox, &glyphs, aText, aPosition, aSize, aAngle, aMirror, aOrigin,
|
||||
(void) drawMarkup( aBoundingBox, &glyphs, aText, aPosition, aSize, offset, aAngle, aMirror, aOrigin,
|
||||
textStyle );
|
||||
|
||||
aGal->DrawGlyphs( glyphs );
|
||||
|
@ -332,7 +339,7 @@ VECTOR2I FONT::StringBoundaryLimits( const wxString& aText, const VECTOR2I& aSiz
|
|||
if( aItalic )
|
||||
textStyle |= TEXT_STYLE::ITALIC;
|
||||
|
||||
(void) drawMarkup( &boundingBox, nullptr, aText, VECTOR2I(), aSize, ANGLE_0, false,
|
||||
(void) drawMarkup( &boundingBox, nullptr, aText, VECTOR2I(), aSize, VECTOR2I(), ANGLE_0, false,
|
||||
VECTOR2I(), textStyle );
|
||||
|
||||
if( IsStroke() )
|
||||
|
@ -358,8 +365,8 @@ VECTOR2I FONT::boundingBoxSingleLine( BOX2I* aBBox, const wxString& aText,
|
|||
if( aItalic )
|
||||
textStyle |= TEXT_STYLE::ITALIC;
|
||||
|
||||
VECTOR2I extents = drawMarkup( aBBox, nullptr, aText, aPosition, aSize, ANGLE_0, false,
|
||||
VECTOR2I(), textStyle );
|
||||
VECTOR2I extents = drawMarkup( aBBox, nullptr, aText, aPosition, aSize, VECTOR2I(), ANGLE_0,
|
||||
false, VECTOR2I(), textStyle );
|
||||
|
||||
return extents;
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ void OUTLINE_FONT::GetLinesAsGlyphs( std::vector<std::unique_ptr<GLYPH>>* aGlyph
|
|||
|
||||
for( size_t i = 0; i < strings.GetCount(); i++ )
|
||||
{
|
||||
(void) drawMarkup( nullptr, aGlyphs, strings.Item( i ), positions[i], aAttrs.m_Size,
|
||||
(void) drawMarkup( nullptr, aGlyphs, strings.Item( i ), positions[i], aAttrs.m_Size, VECTOR2I(),
|
||||
aAttrs.m_Angle, aAttrs.m_Mirrored, aPosition, textStyle );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ using namespace KIFONT;
|
|||
|
||||
|
||||
///< Factor that determines relative vertical position of the overbar.
|
||||
static constexpr double OVERBAR_POSITION_FACTOR = 1.40;
|
||||
static constexpr double OVERBAR_POSITION_FACTOR = 1.23;
|
||||
|
||||
///< Factor that determines relative vertical position of the underline.
|
||||
static constexpr double UNDERLINE_POSITION_FACTOR = -0.16;
|
||||
|
@ -227,9 +227,9 @@ VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr
|
|||
{
|
||||
constexpr int TAB_WIDTH = 4;
|
||||
constexpr double INTER_CHAR = 0.2;
|
||||
constexpr double SUPER_SUB_SIZE_MULTIPLIER = 0.7;
|
||||
constexpr double SUPER_HEIGHT_OFFSET = 0.5;
|
||||
constexpr double SUB_HEIGHT_OFFSET = 0.3;
|
||||
constexpr double SUPER_SUB_SIZE_MULTIPLIER = 0.8;
|
||||
constexpr double SUPER_HEIGHT_OFFSET = 0.35;
|
||||
constexpr double SUB_HEIGHT_OFFSET = 0.15;
|
||||
|
||||
VECTOR2I cursor( aPosition );
|
||||
VECTOR2D glyphSize( aSize );
|
||||
|
@ -294,9 +294,6 @@ VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr
|
|||
|
||||
glyphExtents *= glyphSize;
|
||||
|
||||
if( tilt > 0.0 )
|
||||
glyphExtents.x -= glyphExtents.y * tilt;
|
||||
|
||||
cursor.x += KiROUND( glyphExtents.x );
|
||||
}
|
||||
|
||||
|
|
|
@ -245,15 +245,15 @@ protected:
|
|||
std::vector<VECTOR2I>& aExtents, const TEXT_ATTRIBUTES& aAttrs ) const;
|
||||
|
||||
VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
|
||||
const wxString& aText, const VECTOR2I& aPosition, const VECTOR2I& aSize,
|
||||
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
|
||||
TEXT_STYLE_FLAGS aTextStyle ) const;
|
||||
const wxString& aText, const VECTOR2I& aPosition, const VECTOR2I& aOffset,
|
||||
const VECTOR2I& aSize, const EDA_ANGLE& aAngle, bool aMirror,
|
||||
const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle ) const;
|
||||
|
||||
void wordbreakMarkup( std::vector<std::pair<wxString, int>>* aWords, const wxString& aText,
|
||||
const VECTOR2I& aSize, TEXT_STYLE_FLAGS aTextStyle ) const;
|
||||
|
||||
///< Factor that determines the pitch between 2 lines.
|
||||
static constexpr double INTERLINE_PITCH_RATIO = 1.62; // The golden mean
|
||||
static constexpr double INTERLINE_PITCH_RATIO = 1.61; // The golden mean
|
||||
|
||||
private:
|
||||
static FONT* getDefaultFont();
|
||||
|
|
Loading…
Reference in New Issue