Fix outline font boundingbox issues.
This commit is contained in:
parent
aef2a3fca4
commit
438c63f587
|
@ -478,8 +478,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||||
wxArrayString strings;
|
wxArrayString strings;
|
||||||
wxString text = GetShownText();
|
wxString text = GetShownText();
|
||||||
int thickness = GetEffectiveTextPenWidth();
|
int thickness = GetEffectiveTextPenWidth();
|
||||||
int linecount = 1;
|
|
||||||
bool hasOverBar = false; // true if the first line of text as an overbar
|
|
||||||
|
|
||||||
if( IsMultilineAllowed() )
|
if( IsMultilineAllowed() )
|
||||||
{
|
{
|
||||||
|
@ -491,19 +489,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||||
text = strings.Item( aLine );
|
text = strings.Item( aLine );
|
||||||
else
|
else
|
||||||
text = strings.Item( 0 );
|
text = strings.Item( 0 );
|
||||||
|
|
||||||
linecount = strings.GetCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search for overbar symbol. Only text is scanned,
|
|
||||||
// because only this line can change the bounding box
|
|
||||||
for( unsigned ii = 1; ii < text.size(); ii++ )
|
|
||||||
{
|
|
||||||
if( text[ii-1] == '~' && text[ii] == '{' )
|
|
||||||
{
|
|
||||||
hasOverBar = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -511,7 +496,10 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||||
KIFONT::FONT* font = GetDrawFont();
|
KIFONT::FONT* font = GetDrawFont();
|
||||||
VECTOR2D fontSize( GetTextSize() );
|
VECTOR2D fontSize( GetTextSize() );
|
||||||
double penWidth( thickness );
|
double penWidth( thickness );
|
||||||
int dx = KiROUND( font->StringBoundaryLimits( text, fontSize, penWidth ).x );
|
bool bold = IsBold();
|
||||||
|
bool italic = IsItalic();
|
||||||
|
VECTOR2D extents = font->StringBoundaryLimits( text, fontSize, penWidth, bold, italic );
|
||||||
|
int dx = KiROUND( extents.x );
|
||||||
int dy = GetInterline();
|
int dy = GetInterline();
|
||||||
|
|
||||||
// Creates bounding box (rectangle) for horizontal, left and top justified text. The
|
// Creates bounding box (rectangle) for horizontal, left and top justified text. The
|
||||||
|
@ -527,26 +515,13 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||||
|
|
||||||
rect.SetOrigin( pos );
|
rect.SetOrigin( pos );
|
||||||
|
|
||||||
if( hasOverBar )
|
// for multiline texts and aLine < 0, merge all rectangles (aLine == -1 signals all lines)
|
||||||
{ // A overbar adds an extra size to the text
|
|
||||||
// Height from the base line text of chars like [ or {
|
|
||||||
double curr_height = GetTextHeight() * 1.15;
|
|
||||||
double overbarPosition = font->ComputeOverbarVerticalPosition( fontSize.y );
|
|
||||||
int extra_height = KiROUND( overbarPosition - curr_height );
|
|
||||||
|
|
||||||
extra_height += thickness / 2;
|
|
||||||
textsize.y += extra_height;
|
|
||||||
rect.Move( VECTOR2I( 0, -extra_height ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// for multiline texts and aLine < 0, merge all rectangles
|
|
||||||
// ( if aLine < 0, we want the full text bounding box )
|
|
||||||
if( IsMultilineAllowed() && aLine < 0 )
|
if( IsMultilineAllowed() && aLine < 0 )
|
||||||
{
|
{
|
||||||
for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
|
for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
|
||||||
{
|
{
|
||||||
text = strings.Item( ii );
|
text = strings.Item( ii );
|
||||||
dx = KiROUND( font->StringBoundaryLimits( text, fontSize, penWidth ).x );
|
dx = KiROUND( font->StringBoundaryLimits( text, fontSize, penWidth, bold, italic ).x );
|
||||||
textsize.x = std::max( textsize.x, dx );
|
textsize.x = std::max( textsize.x, dx );
|
||||||
textsize.y += dy;
|
textsize.y += dy;
|
||||||
}
|
}
|
||||||
|
@ -584,10 +559,6 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||||
case GR_TEXT_V_ALIGN_BOTTOM: rect.SetY( rect.GetY() - rect.GetHeight() ); break;
|
case GR_TEXT_V_ALIGN_BOTTOM: rect.SetY( rect.GetY() - rect.GetHeight() ); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Many fonts draw diacriticals, descenders, etc. outside the X-height of the font. This
|
|
||||||
// will cacth most (but probably not all) of them.
|
|
||||||
rect.Inflate( 0, thickness * 1.5 );
|
|
||||||
|
|
||||||
rect.Normalize(); // Make h and v sizes always >= 0
|
rect.Normalize(); // Make h and v sizes always >= 0
|
||||||
|
|
||||||
return rect;
|
return rect;
|
||||||
|
|
|
@ -368,6 +368,37 @@ VECTOR2D FONT::drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VECTOR2D FONT::StringBoundaryLimits( const UTF8& aText, const VECTOR2D& aSize, int aThickness,
|
||||||
|
bool aBold, bool aItalic ) const
|
||||||
|
{
|
||||||
|
// TODO do we need to parse every time - have we already parsed?
|
||||||
|
std::vector<std::unique_ptr<GLYPH>> glyphs; // ignored
|
||||||
|
BOX2I boundingBox;
|
||||||
|
TEXT_STYLE_FLAGS textStyle = 0;
|
||||||
|
|
||||||
|
if( aBold )
|
||||||
|
textStyle |= TEXT_STYLE::BOLD;
|
||||||
|
|
||||||
|
if( aItalic )
|
||||||
|
textStyle |= TEXT_STYLE::ITALIC;
|
||||||
|
|
||||||
|
(void) drawMarkup( &boundingBox, glyphs, aText, VECTOR2D(), aSize, EDA_ANGLE::ANGLE_0,
|
||||||
|
false, VECTOR2D(), textStyle );
|
||||||
|
|
||||||
|
if( IsStroke() )
|
||||||
|
{
|
||||||
|
// Inflate by a bit more than thickness/2 to catch diacriticals, descenders, etc.
|
||||||
|
boundingBox.Inflate( KiROUND( aThickness * 0.75 ) );
|
||||||
|
}
|
||||||
|
else if( IsOutline() )
|
||||||
|
{
|
||||||
|
// Outline fonts have thickness built in
|
||||||
|
}
|
||||||
|
|
||||||
|
return boundingBox.GetSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VECTOR2D FONT::boundingBoxSingleLine( BOX2I* aBoundingBox, const UTF8& aText,
|
VECTOR2D FONT::boundingBoxSingleLine( BOX2I* aBoundingBox, const UTF8& aText,
|
||||||
const VECTOR2I& aPosition, const VECTOR2D& aSize,
|
const VECTOR2I& aPosition, const VECTOR2D& aSize,
|
||||||
bool aItalic ) const
|
bool aItalic ) const
|
||||||
|
|
|
@ -150,65 +150,16 @@ FT_Error OUTLINE_FONT::loadFace( const wxString& aFontFileName )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the boundary limits of aText (the bounding box of all shapes).
|
|
||||||
*
|
|
||||||
* @return a VECTOR2D giving the width and height of text.
|
|
||||||
*/
|
|
||||||
VECTOR2D OUTLINE_FONT::StringBoundaryLimits( const KIGFX::GAL* aGal, const UTF8& aText,
|
|
||||||
const VECTOR2D& aGlyphSize,
|
|
||||||
double aGlyphThickness ) const
|
|
||||||
{
|
|
||||||
hb_buffer_t* buf = hb_buffer_create();
|
|
||||||
hb_buffer_add_utf8( buf, aText.c_str(), -1, 0, -1 );
|
|
||||||
|
|
||||||
// guess direction, script, and language based on contents
|
|
||||||
hb_buffer_guess_segment_properties( buf );
|
|
||||||
|
|
||||||
unsigned int glyphCount;
|
|
||||||
hb_glyph_info_t* glyphInfo = hb_buffer_get_glyph_infos( buf, &glyphCount );
|
|
||||||
hb_font_t* referencedFont = hb_ft_font_create_referenced( m_face );
|
|
||||||
//hb_glyph_position_t* glyphPos = hb_buffer_get_glyph_positions( buf, &glyphCount );
|
|
||||||
|
|
||||||
hb_ft_font_set_funcs( referencedFont );
|
|
||||||
hb_shape( referencedFont, buf, nullptr, 0 );
|
|
||||||
|
|
||||||
int width = 0;
|
|
||||||
int height = m_face->size->metrics.height;
|
|
||||||
|
|
||||||
FT_UInt previous;
|
|
||||||
|
|
||||||
for( int i = 0; i < (int) glyphCount; i++ )
|
|
||||||
{
|
|
||||||
//hb_glyph_position_t& pos = glyphPos[i];
|
|
||||||
int codepoint = glyphInfo[i].codepoint;
|
|
||||||
|
|
||||||
if( i > 0 )
|
|
||||||
{
|
|
||||||
FT_Vector delta;
|
|
||||||
FT_Get_Kerning( m_face, previous, codepoint, FT_KERNING_DEFAULT, &delta );
|
|
||||||
width += delta.x >> 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_Load_Glyph( m_face, codepoint, FT_LOAD_NO_BITMAP );
|
|
||||||
FT_GlyphSlot glyph = m_face->glyph;
|
|
||||||
|
|
||||||
width += glyph->advance.x >> 6;
|
|
||||||
previous = codepoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
return VECTOR2D( width * m_faceScaler, height * m_faceScaler );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the vertical position of an overbar. This is the distance between the text
|
* Compute the vertical position of an overbar. This is the distance between the text
|
||||||
* baseline and the overbar.
|
* baseline and the overbar.
|
||||||
*/
|
*/
|
||||||
double OUTLINE_FONT::ComputeOverbarVerticalPosition( double aGlyphHeight ) const
|
double OUTLINE_FONT::ComputeOverbarVerticalPosition( double aGlyphHeight ) const
|
||||||
{
|
{
|
||||||
// TODO: dummy to make this compile! not used
|
// The overbar on actual text is positioned above the bounding box of the glyphs. However,
|
||||||
return aGlyphHeight;
|
// that's expensive to calculate so we use an estimation here (as this is only used for
|
||||||
|
// calculating bounding boxes).
|
||||||
|
return aGlyphHeight * OUTLINE_FONT_SIZE_COMPENSATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,15 +178,6 @@ double OUTLINE_FONT::GetInterline( double aGlyphHeight, double aLineSpacing ) co
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the X and Y size of a given text. The text is expected to be a single line.
|
|
||||||
*/
|
|
||||||
VECTOR2D OUTLINE_FONT::ComputeTextLineSize( const KIGFX::GAL* aGal, const UTF8& aText ) const
|
|
||||||
{
|
|
||||||
return StringBoundaryLimits( aGal, aText, aGal->GetGlyphSize(), 0.0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static bool contourIsFilled( const CONTOUR& c )
|
static bool contourIsFilled( const CONTOUR& c )
|
||||||
{
|
{
|
||||||
switch( c.orientation )
|
switch( c.orientation )
|
||||||
|
|
|
@ -176,6 +176,8 @@ void STROKE_FONT::loadNewStrokeFont( const char* const aNewStrokeFont[], int aNe
|
||||||
|
|
||||||
m_glyphs = &g_defaultFontGlyphs;
|
m_glyphs = &g_defaultFontGlyphs;
|
||||||
m_glyphBoundingBoxes = g_defaultFontGlyphBoundingBoxes;
|
m_glyphBoundingBoxes = g_defaultFontGlyphBoundingBoxes;
|
||||||
|
m_fontName = wxT( "KiCad Font" );
|
||||||
|
m_fontFileName = wxEmptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,30 +195,6 @@ double STROKE_FONT::ComputeOverbarVerticalPosition( double aGlyphHeight ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VECTOR2D STROKE_FONT::ComputeTextLineSize( const KIGFX::GAL* aGal, const UTF8& aText ) const
|
|
||||||
{
|
|
||||||
//TODO default glyph size (and line width) is a guess
|
|
||||||
VECTOR2D glyphSize = aGal ? aGal->GetGlyphSize() : VECTOR2D( 16.0, 16.0 );
|
|
||||||
double lineWidth = aGal ? aGal->GetLineWidth() : 1.0;
|
|
||||||
return StringBoundaryLimits( aGal, aText, glyphSize, lineWidth );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VECTOR2D STROKE_FONT::StringBoundaryLimits( const KIGFX::GAL* aGal, const UTF8& aText,
|
|
||||||
const VECTOR2D& aGlyphSize,
|
|
||||||
double aGlyphThickness ) const
|
|
||||||
{
|
|
||||||
// TODO do we need to parse every time - have we already parsed?
|
|
||||||
std::vector<std::unique_ptr<GLYPH>> glyphs; // ignored
|
|
||||||
BOX2I boundingBox;
|
|
||||||
|
|
||||||
(void) drawMarkup( &boundingBox, glyphs, aText, VECTOR2D(), aGlyphSize, EDA_ANGLE::ANGLE_0,
|
|
||||||
false, VECTOR2D(), 0 /* TODO: should include TEXT_STYLE::ITALIC if set */ );
|
|
||||||
|
|
||||||
return boundingBox.GetSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr<GLYPH>>& aGlyphs,
|
VECTOR2I STROKE_FONT::GetTextAsGlyphs( BOX2I* aBBox, std::vector<std::unique_ptr<GLYPH>>& aGlyphs,
|
||||||
const UTF8& aText, const VECTOR2D& aSize,
|
const UTF8& aText, const VECTOR2D& aSize,
|
||||||
const VECTOR2I& aPosition, const EDA_ANGLE& aAngle,
|
const VECTOR2I& aPosition, const EDA_ANGLE& aAngle,
|
||||||
|
|
|
@ -97,16 +97,12 @@ int Clamp_Text_PenSize( int aPenSize, const VECTOR2I& aSize, bool aBold )
|
||||||
|
|
||||||
|
|
||||||
int GraphicTextWidth( const wxString& aText, KIFONT::FONT* aFont, const VECTOR2I& aSize,
|
int GraphicTextWidth( const wxString& aText, KIFONT::FONT* aFont, const VECTOR2I& aSize,
|
||||||
bool aItalic, bool aBold )
|
int aThickness, bool aBold, bool aItalic )
|
||||||
{
|
{
|
||||||
basic_gal.SetFontItalic( aItalic );
|
|
||||||
basic_gal.SetFontBold( aBold );
|
|
||||||
basic_gal.SetGlyphSize( VECTOR2D( aSize ) );
|
|
||||||
|
|
||||||
if( !aFont )
|
if( !aFont )
|
||||||
aFont = KIFONT::FONT::GetFont();
|
aFont = KIFONT::FONT::GetFont();
|
||||||
|
|
||||||
return KiROUND( aFont->ComputeTextLineSize( &basic_gal, aText ).x );
|
return KiROUND( aFont->StringBoundaryLimits( aText, aSize, aThickness, aBold, aItalic ).x );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -795,7 +795,7 @@ void SVG_PLOTTER::Text( const VECTOR2I& aPos,
|
||||||
|
|
||||||
// aSize.x or aSize.y is < 0 for mirrored texts.
|
// aSize.x or aSize.y is < 0 for mirrored texts.
|
||||||
// The actual text size value is the absolute value
|
// The actual text size value is the absolute value
|
||||||
text_size.x = std::abs( GraphicTextWidth( aText, aFont, aSize, aItalic, aWidth ) );
|
text_size.x = std::abs( GraphicTextWidth( aText, aFont, aSize, aWidth, aBold, aItalic ) );
|
||||||
text_size.y = std::abs( aSize.x * 4/3 ); // Hershey font height to em size conversion
|
text_size.y = std::abs( aSize.x * 4/3 ); // Hershey font height to em size conversion
|
||||||
DPOINT anchor_pos_dev = userToDeviceCoordinates( aPos );
|
DPOINT anchor_pos_dev = userToDeviceCoordinates( aPos );
|
||||||
DPOINT text_pos_dev = userToDeviceCoordinates( text_pos );
|
DPOINT text_pos_dev = userToDeviceCoordinates( text_pos );
|
||||||
|
|
|
@ -1092,6 +1092,7 @@ const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles, bool aPinOnly )
|
||||||
bool showName = !name.IsEmpty();
|
bool showName = !name.IsEmpty();
|
||||||
bool showNum = !number.IsEmpty();
|
bool showNum = !number.IsEmpty();
|
||||||
int minsizeV = TARGET_PIN_RADIUS;
|
int minsizeV = TARGET_PIN_RADIUS;
|
||||||
|
int penWidth = GetPenWidth();
|
||||||
|
|
||||||
if( !aIncludeInvisibles && !IsVisible() )
|
if( !aIncludeInvisibles && !IsVisible() )
|
||||||
showName = false;
|
showName = false;
|
||||||
|
@ -1117,7 +1118,7 @@ const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles, bool aPinOnly )
|
||||||
if( showNum )
|
if( showNum )
|
||||||
{
|
{
|
||||||
VECTOR2D fontSize( m_numTextSize, m_numTextSize );
|
VECTOR2D fontSize( m_numTextSize, m_numTextSize );
|
||||||
VECTOR2D numSize = font->StringBoundaryLimits( number, fontSize, GetPenWidth() );
|
VECTOR2D numSize = font->StringBoundaryLimits( number, fontSize, penWidth, false, false );
|
||||||
|
|
||||||
numberTextLength = KiROUND( numSize.x );
|
numberTextLength = KiROUND( numSize.x );
|
||||||
numberTextHeight = KiROUND( numSize.y );
|
numberTextHeight = KiROUND( numSize.y );
|
||||||
|
@ -1135,7 +1136,7 @@ const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles, bool aPinOnly )
|
||||||
if( showName )
|
if( showName )
|
||||||
{
|
{
|
||||||
VECTOR2D fontSize( m_nameTextSize, m_nameTextSize );
|
VECTOR2D fontSize( m_nameTextSize, m_nameTextSize );
|
||||||
VECTOR2D nameSize = font->StringBoundaryLimits( name, fontSize, GetPenWidth() );
|
VECTOR2D nameSize = font->StringBoundaryLimits( name, fontSize, penWidth, false, false );
|
||||||
|
|
||||||
nameTextLength = KiROUND( nameSize.x ) + nameTextOffset;
|
nameTextLength = KiROUND( nameSize.x ) + nameTextOffset;
|
||||||
nameTextHeight = KiROUND( nameSize.y ) + Mils2iu( PIN_TEXT_MARGIN );
|
nameTextHeight = KiROUND( nameSize.y ) + Mils2iu( PIN_TEXT_MARGIN );
|
||||||
|
|
|
@ -464,7 +464,8 @@ void SCH_PAINTER::boxText( const wxString& aText, const VECTOR2D& aPosition,
|
||||||
aAttrs.m_Italic );
|
aAttrs.m_Italic );
|
||||||
}
|
}
|
||||||
|
|
||||||
VECTOR2D extents = font->StringBoundaryLimits( aText, aAttrs.m_Size, aAttrs.m_StrokeWidth );
|
VECTOR2D extents = font->StringBoundaryLimits( aText, aAttrs.m_Size, aAttrs.m_StrokeWidth,
|
||||||
|
aAttrs.m_Bold, aAttrs.m_Italic );
|
||||||
EDA_RECT box( (VECTOR2I) aPosition, wxSize( extents.x, aAttrs.m_Size.y ) );
|
EDA_RECT box( (VECTOR2I) aPosition, wxSize( extents.x, aAttrs.m_Size.y ) );
|
||||||
|
|
||||||
switch( aAttrs.m_Halign )
|
switch( aAttrs.m_Halign )
|
||||||
|
@ -1470,8 +1471,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer )
|
||||||
m_gal->SetStrokeColor( color );
|
m_gal->SetStrokeColor( color );
|
||||||
m_gal->SetFillColor( color );
|
m_gal->SetFillColor( color );
|
||||||
|
|
||||||
VECTOR2D textPos( aText->GetTextPos() );
|
VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings );
|
||||||
VECTOR2D text_offset = aText->GetSchematicTextOffset( &m_schSettings );
|
|
||||||
wxString shownText( aText->GetShownText() );
|
wxString shownText( aText->GetShownText() );
|
||||||
|
|
||||||
if( drawingShadows && eeconfig()->m_Selection.text_as_box )
|
if( drawingShadows && eeconfig()->m_Selection.text_as_box )
|
||||||
|
@ -1491,7 +1491,20 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer )
|
||||||
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
||||||
attrs.m_StrokeWidth = getTextThickness( aText, drawingShadows );
|
attrs.m_StrokeWidth = getTextThickness( aText, drawingShadows );
|
||||||
|
|
||||||
strokeText( shownText, textPos + text_offset, attrs );
|
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = nullptr;
|
||||||
|
|
||||||
|
if( !text_offset.x && !text_offset.y )
|
||||||
|
cache = aText->GetRenderCache( shownText );
|
||||||
|
|
||||||
|
if( cache )
|
||||||
|
{
|
||||||
|
for( const std::unique_ptr<KIFONT::GLYPH>& glyph : *cache )
|
||||||
|
m_gal->DrawGlyph( *glyph.get() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strokeText( shownText, aText->GetTextPos(), attrs );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -244,21 +244,7 @@ bool SCH_TEXT::IncrementLabel( int aIncrement )
|
||||||
|
|
||||||
VECTOR2I SCH_TEXT::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const
|
VECTOR2I SCH_TEXT::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const
|
||||||
{
|
{
|
||||||
VECTOR2I text_offset;
|
return VECTOR2I( 0, 0 );
|
||||||
|
|
||||||
// add an offset to x (or y) position to aid readability of text on a wire or line
|
|
||||||
int dist = GetTextOffset( aSettings ) + GetPenWidth();
|
|
||||||
|
|
||||||
switch( GetLabelSpinStyle() )
|
|
||||||
{
|
|
||||||
case LABEL_SPIN_STYLE::UP:
|
|
||||||
case LABEL_SPIN_STYLE::BOTTOM: text_offset.x = -dist; break; // Vert Orientation
|
|
||||||
default:
|
|
||||||
case LABEL_SPIN_STYLE::LEFT:
|
|
||||||
case LABEL_SPIN_STYLE::RIGHT: text_offset.y = -dist; break; // Horiz Orientation
|
|
||||||
}
|
|
||||||
|
|
||||||
return text_offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -737,6 +723,26 @@ void SCH_LABEL_BASE::SwapData( SCH_ITEM* aItem )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VECTOR2I SCH_LABEL_BASE::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const
|
||||||
|
{
|
||||||
|
VECTOR2I text_offset;
|
||||||
|
|
||||||
|
// add an offset to x (or y) position to aid readability of text on a wire or line
|
||||||
|
int dist = GetTextOffset( aSettings ) + GetPenWidth();
|
||||||
|
|
||||||
|
switch( GetLabelSpinStyle() )
|
||||||
|
{
|
||||||
|
case LABEL_SPIN_STYLE::UP:
|
||||||
|
case LABEL_SPIN_STYLE::BOTTOM: text_offset.x = -dist; break; // Vert Orientation
|
||||||
|
default:
|
||||||
|
case LABEL_SPIN_STYLE::LEFT:
|
||||||
|
case LABEL_SPIN_STYLE::RIGHT: text_offset.y = -dist; break; // Horiz Orientation
|
||||||
|
}
|
||||||
|
|
||||||
|
return text_offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_LABEL_BASE::Rotate( const VECTOR2I& aCenter )
|
void SCH_LABEL_BASE::Rotate( const VECTOR2I& aCenter )
|
||||||
{
|
{
|
||||||
VECTOR2I pt = GetTextPos();
|
VECTOR2I pt = GetTextPos();
|
||||||
|
|
|
@ -296,6 +296,8 @@ public:
|
||||||
|
|
||||||
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override;
|
||||||
|
|
||||||
|
VECTOR2I GetSchematicTextOffset( const RENDER_SETTINGS* aSettings ) const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the graphic shape (a polygon) associated to the text.
|
* Calculate the graphic shape (a polygon) associated to the text.
|
||||||
*
|
*
|
||||||
|
|
|
@ -141,15 +141,8 @@ public:
|
||||||
*
|
*
|
||||||
* @return a VECTOR2D giving the width and height of text.
|
* @return a VECTOR2D giving the width and height of text.
|
||||||
*/
|
*/
|
||||||
virtual VECTOR2D StringBoundaryLimits( const KIGFX::GAL* aGal, const UTF8& aText,
|
VECTOR2D StringBoundaryLimits( const UTF8& aText, const VECTOR2D& aSize, int aThickness,
|
||||||
const VECTOR2D& aGlyphSize,
|
bool aBold, bool aItalic ) const;
|
||||||
double aGlyphThickness ) const = 0;
|
|
||||||
|
|
||||||
VECTOR2D StringBoundaryLimits( const UTF8& aText, const VECTOR2D& aGlyphSize,
|
|
||||||
double aGlyphThickness ) const
|
|
||||||
{
|
|
||||||
return StringBoundaryLimits( nullptr, aText, aGlyphSize, aGlyphThickness );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the vertical position of an overbar. This is the distance between the text
|
* Compute the vertical position of an overbar. This is the distance between the text
|
||||||
|
@ -163,11 +156,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual double GetInterline( double aGlyphHeight, double aLineSpacing = 1.0 ) const = 0;
|
virtual double GetInterline( double aGlyphHeight, double aLineSpacing = 1.0 ) const = 0;
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the X and Y size of a given text. The text is expected to be a single line.
|
|
||||||
*/
|
|
||||||
virtual VECTOR2D ComputeTextLineSize( const KIGFX::GAL* aGal, const UTF8& aText ) const = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert text string to an array of GLYPHs.
|
* Convert text string to an array of GLYPHs.
|
||||||
*
|
*
|
||||||
|
|
|
@ -81,17 +81,6 @@ public:
|
||||||
const VECTOR2D& aOrigin, const TEXT_ATTRIBUTES& aAttributes ) const override;
|
const VECTOR2D& aOrigin, const TEXT_ATTRIBUTES& aAttributes ) const override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the boundary limits of aText (the bounding box of all shapes).
|
|
||||||
*
|
|
||||||
* The overbar and alignment are not taken in account, '~' characters are skipped.
|
|
||||||
*
|
|
||||||
* @return a VECTOR2D giving the width and height of text.
|
|
||||||
*/
|
|
||||||
VECTOR2D StringBoundaryLimits( const KIGFX::GAL* aGal, const UTF8& aText,
|
|
||||||
const VECTOR2D& aGlyphSize,
|
|
||||||
double aGlyphThickness ) const override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the vertical position of an overbar. This is the distance between the text
|
* Compute the vertical position of an overbar. This is the distance between the text
|
||||||
* baseline and the overbar.
|
* baseline and the overbar.
|
||||||
|
@ -104,12 +93,6 @@ public:
|
||||||
*/
|
*/
|
||||||
double GetInterline( double aGlyphHeight = 0.0, double aLineSpacing = 1.0 ) const override;
|
double GetInterline( double aGlyphHeight = 0.0, double aLineSpacing = 1.0 ) const override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the X and Y size of a given text. The text is expected to be a single line.
|
|
||||||
*/
|
|
||||||
VECTOR2D ComputeTextLineSize( const KIGFX::GAL* aGal, const UTF8& aText ) const override;
|
|
||||||
|
|
||||||
|
|
||||||
VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>& aGlyphs,
|
VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>& aGlyphs,
|
||||||
const UTF8& aText, const VECTOR2D& aSize, const VECTOR2I& aPosition,
|
const UTF8& aText, const VECTOR2D& aSize, const VECTOR2I& aPosition,
|
||||||
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
|
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
|
||||||
|
|
|
@ -64,15 +64,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static STROKE_FONT* LoadFont( const wxString& aFontName );
|
static STROKE_FONT* LoadFont( const wxString& aFontName );
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the boundary limits of aText (the bounding box of all shapes).
|
|
||||||
*
|
|
||||||
* @return a VECTOR2D giving the width and height of text.
|
|
||||||
*/
|
|
||||||
VECTOR2D StringBoundaryLimits( const KIGFX::GAL* aGal, const UTF8& aText,
|
|
||||||
const VECTOR2D& aGlyphSize,
|
|
||||||
double aGlyphThickness ) const override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the vertical position of an overbar. This is the distance between the text
|
* Compute the vertical position of an overbar. This is the distance between the text
|
||||||
* baseline and the overbar.
|
* baseline and the overbar.
|
||||||
|
@ -85,11 +76,6 @@ public:
|
||||||
*/
|
*/
|
||||||
double GetInterline( double aGlyphHeight, double aLineSpacing = 1.0 ) const override;
|
double GetInterline( double aGlyphHeight, double aLineSpacing = 1.0 ) const override;
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the X and Y size of a given text. The text is expected to be a single line.
|
|
||||||
*/
|
|
||||||
VECTOR2D ComputeTextLineSize( const KIGFX::GAL* aGal, const UTF8& aText ) const override;
|
|
||||||
|
|
||||||
VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>& aGlyphs,
|
VECTOR2I GetTextAsGlyphs( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>& aGlyphs,
|
||||||
const UTF8& aText, const VECTOR2D& aSize, const VECTOR2I& aPosition,
|
const UTF8& aText, const VECTOR2D& aSize, const VECTOR2I& aPosition,
|
||||||
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
|
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
|
||||||
|
|
|
@ -85,7 +85,7 @@ int GetPenSizeForNormal( const wxSize& aTextSize );
|
||||||
* @return the X size of the graphic text.
|
* @return the X size of the graphic text.
|
||||||
*/
|
*/
|
||||||
int GraphicTextWidth( const wxString& aText, KIFONT::FONT* aFont, const VECTOR2I& aSize,
|
int GraphicTextWidth( const wxString& aText, KIFONT::FONT* aFont, const VECTOR2I& aSize,
|
||||||
bool italic, bool bold );
|
int aThickness, bool aBold, bool aItalic );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw a graphic text (like footprint text)
|
* Draw a graphic text (like footprint text)
|
||||||
|
|
Loading…
Reference in New Issue