7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 23:41:40 +00:00

ADDED: parameterize font metrics and allow customization of overbar height.

This commit is contained in:
Jeff Young 2023-08-06 20:20:53 +01:00
parent a0ebedc0ac
commit 5e112ca78e
64 changed files with 834 additions and 624 deletions

View File

@ -118,7 +118,8 @@ void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContaine
attrs.m_Angle = aText->GetDrawRotation();
font->Draw( &callback_gal, aText->GetShownText( true ), aText->GetDrawPos(), attrs );
font->Draw( &callback_gal, aText->GetShownText( true ), aText->GetDrawPos(), attrs,
aOwner->GetFontMetrics() );
}
}

View File

@ -58,9 +58,17 @@
#include <gr_basic.h>
#include <trigo.h>
#include <render_settings.h>
#include <font/font.h>
// ============================ BASE CLASS ==============================
const KIFONT::METRICS& DS_DRAW_ITEM_BASE::GetFontMetrics() const
{
return KIFONT::METRICS::Default();
}
void DS_DRAW_ITEM_BASE::ViewGetLayers( int aLayers[], int& aCount ) const
{
aCount = 1;

View File

@ -270,7 +270,8 @@ void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
attrs.m_StrokeWidth = std::max( aItem->GetEffectiveTextPenWidth(),
m_renderSettings.GetDefaultPenWidth() );
font->Draw( m_gal, aItem->GetShownText( true ), aItem->GetTextPos(), attrs );
font->Draw( m_gal, aItem->GetShownText( true ), aItem->GetTextPos(), attrs,
aItem->GetFontMetrics() );
}

View File

@ -22,11 +22,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file eda_text.cpp
* @brief Implementation of base KiCad text object.
*/
#include <algorithm> // for max
#include <stddef.h> // for NULL
#include <type_traits> // for swap
@ -473,6 +468,11 @@ KIFONT::FONT* EDA_TEXT::getDrawFont() const
}
const KIFONT::METRICS& EDA_TEXT::getFontMetrics() const
{
return KIFONT::METRICS::Default();
}
void EDA_TEXT::ClearRenderCache()
{
@ -508,7 +508,7 @@ EDA_TEXT::GetRenderCache( const KIFONT::FONT* aFont, const wxString& forResolved
attrs.m_Angle = resolvedAngle;
font->GetLinesAsGlyphs( &m_render_cache, forResolvedText, GetDrawPos() + aOffset,
attrs );
attrs, getFontMetrics() );
m_render_cache_font = aFont;
m_render_cache_angle = resolvedAngle;
m_render_cache_text = forResolvedText;
@ -538,7 +538,7 @@ void EDA_TEXT::AddRenderCacheGlyph( const SHAPE_POLY_SET& aPoly )
int EDA_TEXT::GetInterline() const
{
return KiROUND( getDrawFont()->GetInterline( GetTextHeight() ) );
return KiROUND( getDrawFont()->GetInterline( GetTextHeight(), getFontMetrics() ) );
}
@ -577,20 +577,21 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
VECTOR2D fontSize( GetTextSize() );
bool bold = IsBold();
bool italic = IsItalic();
VECTOR2I extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic );
VECTOR2I extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic,
getFontMetrics() );
int overbarOffset = 0;
// Creates bounding box (rectangle) for horizontal, left and top justified text. The
// bounding box will be moved later according to the actual text options
VECTOR2I textsize = VECTOR2I( extents.x, extents.y );
VECTOR2I pos = drawPos;
int fudgeFactor = extents.y * 0.17;
int fudgeFactor = KiROUND( extents.y * 0.17 );
if( font->IsStroke() )
textsize.y += fudgeFactor;
if( IsMultilineAllowed() && aLine > 0 && aLine < (int) strings.GetCount() )
pos.y -= KiROUND( aLine * font->GetInterline( fontSize.y ) );
pos.y -= KiROUND( aLine * font->GetInterline( fontSize.y, getFontMetrics() ) );
if( text.Contains( wxT( "~{" ) ) )
overbarOffset = extents.y / 6;
@ -606,13 +607,15 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
for( unsigned ii = 1; ii < strings.GetCount(); ii++ )
{
text = strings.Item( ii );
extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic );
extents = font->StringBoundaryLimits( text, fontSize, thickness, bold, italic,
getFontMetrics() );
textsize.x = std::max( textsize.x, extents.x );
}
// interline spacing is only *between* lines, so total height is the height of the first
// line plus the interline distance (with interline spacing) for all subsequent lines
textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y ) );
textsize.y += KiROUND( ( strings.GetCount() - 1 ) * font->GetInterline( fontSize.y,
getFontMetrics() ) );
}
textsize.y += overbarOffset;
@ -780,7 +783,7 @@ void EDA_TEXT::printOneLineOfText( const RENDER_SETTINGS* aSettings, const VECTO
font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
GRPrintText( DC, aOffset + aPos, aColor, aText, GetDrawRotation(), size, GetHorizJustify(),
GetVertJustify(), penWidth, IsItalic(), IsBold(), font );
GetVertJustify(), penWidth, IsItalic(), IsBold(), font, getFontMetrics() );
}
@ -949,7 +952,7 @@ std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( bool aTriangula
if( cache )
callback_gal.DrawGlyphs( *cache );
else
font->Draw( &callback_gal, shownText, drawPos, attrs );
font->Draw( &callback_gal, shownText, drawPos, attrs, getFontMetrics() );
}
else
{
@ -969,7 +972,7 @@ std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( bool aTriangula
if( cache )
callback_gal.DrawGlyphs( *cache );
else
font->Draw( &callback_gal, shownText, drawPos, attrs );
font->Draw( &callback_gal, shownText, drawPos, attrs, getFontMetrics() );
}
return shape;

View File

@ -46,6 +46,15 @@
using namespace KIFONT;
METRICS g_defaultMetrics;
const METRICS& METRICS::Default()
{
return g_defaultMetrics;
}
FONT* FONT::s_defaultFont = nullptr;
std::map< std::tuple<wxString, bool, bool>, FONT*> FONT::s_fontMap;
@ -165,20 +174,21 @@ bool FONT::IsStroke( const wxString& aFontName )
void FONT::getLinePositions( const wxString& aText, const VECTOR2I& aPosition,
wxArrayString& aTextLines, std::vector<VECTOR2I>& aPositions,
std::vector<VECTOR2I>& aExtents, const TEXT_ATTRIBUTES& aAttrs ) const
std::vector<VECTOR2I>& aExtents, const TEXT_ATTRIBUTES& aAttrs,
const METRICS& aFontMetrics ) const
{
wxStringSplit( aText, aTextLines, '\n' );
int lineCount = aTextLines.Count();
aPositions.reserve( lineCount );
int interline = GetInterline( aAttrs.m_Size.y, aAttrs.m_LineSpacing );
int interline = GetInterline( aAttrs.m_Size.y, aFontMetrics ) * aAttrs.m_LineSpacing;
int height = 0;
for( int i = 0; i < lineCount; i++ )
{
VECTOR2I pos( aPosition.x, aPosition.y + i * interline );
VECTOR2I end = boundingBoxSingleLine( nullptr, aTextLines[i], pos, aAttrs.m_Size,
aAttrs.m_Italic );
aAttrs.m_Italic, aFontMetrics );
VECTOR2I bBox( end - pos );
aExtents.push_back( bBox );
@ -236,7 +246,8 @@ void FONT::getLinePositions( const wxString& aText, const VECTOR2I& aPosition,
* @param aAttrs are the styling attributes of the text, including its rotation
*/
void FONT::Draw( KIGFX::GAL* aGal, const wxString& aText, const VECTOR2I& aPosition,
const VECTOR2I& aCursor, const TEXT_ATTRIBUTES& aAttrs ) const
const VECTOR2I& aCursor, const TEXT_ATTRIBUTES& aAttrs,
const METRICS& aFontMetrics ) const
{
if( !aGal || aText.empty() )
return;
@ -248,7 +259,7 @@ void FONT::Draw( KIGFX::GAL* aGal, const wxString& aText, const VECTOR2I& aPosit
std::vector<VECTOR2I> positions;
std::vector<VECTOR2I> extents;
getLinePositions( aText, position, strings_list, positions, extents, aAttrs );
getLinePositions( aText, position, strings_list, positions, extents, aAttrs, aFontMetrics );
aGal->SetLineWidth( aAttrs.m_StrokeWidth );
@ -256,7 +267,7 @@ void FONT::Draw( KIGFX::GAL* aGal, const wxString& aText, const VECTOR2I& aPosit
{
drawSingleLineText( aGal, nullptr, strings_list[i], positions[i], aAttrs.m_Size,
aAttrs.m_Angle, aAttrs.m_Mirrored, aPosition, aAttrs.m_Italic,
aAttrs.m_Underlined );
aAttrs.m_Underlined, aFontMetrics );
}
}
@ -267,7 +278,8 @@ void FONT::Draw( KIGFX::GAL* aGal, const wxString& aText, const VECTOR2I& aPosit
VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const 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 )
bool aMirror, const VECTOR2I& aOrigin, TEXT_STYLE_FLAGS aTextStyle,
const METRICS& aFontMetrics )
{
VECTOR2I nextPosition = aPosition;
bool drawUnderline = false;
@ -307,7 +319,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.get(), nextPosition, aFont,
aSize, aAngle, aMirror, aOrigin, textStyle );
aSize, aAngle, aMirror, aOrigin, textStyle, aFontMetrics );
}
}
@ -315,7 +327,7 @@ VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* a
{
// Shorten the bar a little so its rounded ends don't make it over-long
double barTrim = aSize.x * 0.1;
double barOffset = aFont->ComputeUnderlineVerticalPosition( aSize.y );
double barOffset = aFontMetrics.GetUnderlineVerticalPosition( aSize.y );
VECTOR2D barStart( aPosition.x + barTrim, aPosition.y - barOffset );
VECTOR2D barEnd( nextPosition.x - barTrim, nextPosition.y - barOffset );
@ -337,7 +349,7 @@ VECTOR2I drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYPH>>* a
{
// Shorten the bar a little so its rounded ends don't make it over-long
double barTrim = aSize.x * 0.1;
double barOffset = aFont->ComputeOverbarVerticalPosition( aSize.y );
double barOffset = aFontMetrics.GetOverbarVerticalPosition( aSize.y );
VECTOR2D barStart( aPosition.x + barTrim, aPosition.y - barOffset );
VECTOR2D barEnd( nextPosition.x - barTrim, nextPosition.y - barOffset );
@ -362,7 +374,7 @@ 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
TEXT_STYLE_FLAGS aTextStyle, const METRICS& aFontMetrics ) const
{
std::lock_guard<std::mutex> lock( s_markupCacheMutex );
@ -381,14 +393,14 @@ VECTOR2I FONT::drawMarkup( BOX2I* aBoundingBox, std::vector<std::unique_ptr<GLYP
wxASSERT( markup && markup->root );
return ::drawMarkup( aBoundingBox, aGlyphs, markup->root.get(), aPosition, this, aSize, aAngle,
aMirror, aOrigin, aTextStyle );
aMirror, aOrigin, aTextStyle, aFontMetrics );
}
void FONT::drawSingleLineText( KIGFX::GAL* aGal, BOX2I* aBoundingBox, const wxString& aText,
const VECTOR2I& aPosition, const VECTOR2I& aSize,
const EDA_ANGLE& aAngle, bool aMirror, const VECTOR2I& aOrigin,
bool aItalic, bool aUnderline ) const
bool aItalic, bool aUnderline, const METRICS& aFontMetrics ) const
{
if( !aGal )
return;
@ -404,14 +416,14 @@ 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,
textStyle );
textStyle, aFontMetrics );
aGal->DrawGlyphs( glyphs );
}
VECTOR2I FONT::StringBoundaryLimits( const wxString& aText, const VECTOR2I& aSize, int aThickness,
bool aBold, bool aItalic ) const
bool aBold, bool aItalic, const METRICS& aFontMetrics ) const
{
// TODO do we need to parse every time - have we already parsed?
BOX2I boundingBox;
@ -424,7 +436,7 @@ VECTOR2I FONT::StringBoundaryLimits( const wxString& aText, const VECTOR2I& aSiz
textStyle |= TEXT_STYLE::ITALIC;
(void) drawMarkup( &boundingBox, nullptr, aText, VECTOR2I(), aSize, ANGLE_0, false, VECTOR2I(),
textStyle );
textStyle, aFontMetrics );
if( IsStroke() )
{
@ -442,7 +454,7 @@ VECTOR2I FONT::StringBoundaryLimits( const wxString& aText, const VECTOR2I& aSiz
VECTOR2I FONT::boundingBoxSingleLine( BOX2I* aBBox, const wxString& aText,
const VECTOR2I& aPosition, const VECTOR2I& aSize,
bool aItalic ) const
bool aItalic, const METRICS& aFontMetrics ) const
{
TEXT_STYLE_FLAGS textStyle = 0;
@ -450,7 +462,7 @@ VECTOR2I FONT::boundingBoxSingleLine( BOX2I* aBBox, const wxString& aText,
textStyle |= TEXT_STYLE::ITALIC;
VECTOR2I extents = drawMarkup( aBBox, nullptr, aText, aPosition, aSize, ANGLE_0, false,
VECTOR2I(), textStyle );
VECTOR2I(), textStyle, aFontMetrics );
return extents;
}

View File

@ -4,8 +4,6 @@
* Copyright (C) 2021 Ola Rinta-Koski <gitlab@rinta-koski.net>
* Copyright (C) 2021-2023 Kicad Developers, see AUTHORS.txt for contributors.
*
* Outline font class
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@ -146,47 +144,18 @@ FT_Error OUTLINE_FONT::loadFace( const wxString& aFontFileName, int aFaceIndex )
}
/**
* Compute the vertical position of an overbar. This is the distance between the text
* baseline and the overbar.
*/
double OUTLINE_FONT::ComputeOverbarVerticalPosition( double aGlyphHeight ) const
{
// The overbar on actual text is positioned above the bounding box of the glyphs. However,
// that's expensive to calculate so we use an estimation here (as this is only used for
// calculating bounding boxes).
return aGlyphHeight * m_outlineFontSizeCompensation;
}
/**
* Compute the vertical position of an underline. This is the distance between the text
* baseline and the underline.
*/
double OUTLINE_FONT::ComputeUnderlineVerticalPosition( double aGlyphHeight ) const
{
return aGlyphHeight * m_underlineOffsetScaler;
}
/**
* Compute the distance (interline) between 2 lines of text (for multiline texts). This is
* the distance between baselines, not the space between line bounding boxes.
*/
double OUTLINE_FONT::GetInterline( double aGlyphHeight, double aLineSpacing ) const
double OUTLINE_FONT::GetInterline( double aGlyphHeight, const METRICS& aFontMetrics ) const
{
double pitch = INTERLINE_PITCH_RATIO;
double glyphToFontHeight = 1.0;
if( GetFace()->units_per_EM )
pitch = GetFace()->height / GetFace()->units_per_EM;
glyphToFontHeight = GetFace()->height / GetFace()->units_per_EM;
double interline = aLineSpacing * aGlyphHeight * pitch * m_outlineFontSizeCompensation;
// FONT TODO this hack is an attempt to fix interline spacing by eyeballing it
static constexpr double interlineHackMultiplier = 1.2;
interline *= interlineHackMultiplier;
return interline;
return aFontMetrics.GetInterline( aGlyphHeight * glyphToFontHeight );
}
@ -241,7 +210,8 @@ BOX2I OUTLINE_FONT::getBoundingBox( const std::vector<std::unique_ptr<GLYPH>>& a
void OUTLINE_FONT::GetLinesAsGlyphs( std::vector<std::unique_ptr<GLYPH>>* aGlyphs,
const wxString& aText, const VECTOR2I& aPosition,
const TEXT_ATTRIBUTES& aAttrs ) const
const TEXT_ATTRIBUTES& aAttrs,
const METRICS& aFontMetrics ) const
{
wxArrayString strings;
std::vector<VECTOR2I> positions;
@ -251,12 +221,12 @@ void OUTLINE_FONT::GetLinesAsGlyphs( std::vector<std::unique_ptr<GLYPH>>* aGlyph
if( aAttrs.m_Italic )
textStyle |= TEXT_STYLE::ITALIC;
getLinePositions( aText, aPosition, strings, positions, extents, aAttrs );
getLinePositions( aText, aPosition, strings, positions, extents, aAttrs, aFontMetrics );
for( size_t i = 0; i < strings.GetCount(); i++ )
{
(void) drawMarkup( nullptr, aGlyphs, strings.Item( i ), positions[i], aAttrs.m_Size,
aAttrs.m_Angle, aAttrs.m_Mirrored, aPosition, textStyle );
aAttrs.m_Angle, aAttrs.m_Mirrored, aPosition, textStyle, aFontMetrics );
}
}

View File

@ -6,8 +6,6 @@
* @author Maciej Suminski <maciej.suminski@cern.ch>
* Copyright (C) 2016-2023 Kicad Developers, see AUTHORS.txt for contributors.
*
* Stroke font class
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@ -43,12 +41,6 @@
using namespace KIFONT;
///< Factor that determines relative vertical position of the overbar.
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;
///< Scale factor for a glyph
static constexpr double STROKE_FONT_SCALE = 1.0 / 21.0;
@ -199,23 +191,11 @@ void STROKE_FONT::loadNewStrokeFont( const char* const aNewStrokeFont[], int aNe
}
double STROKE_FONT::GetInterline( double aGlyphHeight, double aLineSpacing ) const
double STROKE_FONT::GetInterline( double aGlyphHeight, const METRICS& aFontMetrics ) const
{
// Do not add the glyph thickness to the interline. This makes bold text line-spacing
// different from normal text, which is poor typography.
return ( aGlyphHeight * aLineSpacing * INTERLINE_PITCH_RATIO );
}
static double LEGACY_FACTOR = 1.0435; // Adjustment to match legacy spacing
double STROKE_FONT::ComputeOverbarVerticalPosition( double aGlyphHeight ) const
{
return aGlyphHeight * OVERBAR_POSITION_FACTOR;
}
double STROKE_FONT::ComputeUnderlineVerticalPosition( double aGlyphHeight ) const
{
return aGlyphHeight * UNDERLINE_POSITION_FACTOR;
return aFontMetrics.GetInterline( aGlyphHeight ) * LEGACY_FACTOR;
}

View File

@ -18,7 +18,6 @@
*/
#include <font/text_attributes.h>
#include <font/outline_font.h>
@ -68,10 +67,10 @@ int TEXT_ATTRIBUTES::Compare( const TEXT_ATTRIBUTES& aRhs ) const
return m_StrokeWidth - aRhs.m_StrokeWidth;
if( m_Angle.AsDegrees() != aRhs.m_Angle.AsDegrees() )
return m_Angle.AsDegrees() - aRhs.m_Angle.AsDegrees();
return m_Angle.AsDegrees() < aRhs.m_Angle.AsDegrees() ? -1 : 1;
if( m_LineSpacing != aRhs.m_LineSpacing )
return m_LineSpacing - aRhs.m_LineSpacing;
return m_LineSpacing < aRhs.m_LineSpacing ? -1 : 1;
if( m_Halign != aRhs.m_Halign )
return m_Halign - aRhs.m_Halign;

View File

@ -273,7 +273,7 @@ void GAL::BitmapText( const wxString& aText, const VECTOR2I& aPosition, const ED
attrs.m_Size = VECTOR2I( m_attributes.m_Size.x, m_attributes.m_Size.y * 0.95 );
attrs.m_StrokeWidth = GetLineWidth() * 0.74;
font->Draw( this, aText, aPosition, attrs );
font->Draw( this, aText, aPosition, attrs, KIFONT::METRICS::Default() );
}

View File

@ -110,13 +110,14 @@ int Clamp_Text_PenSize( int aPenSize, const VECTOR2I& aSize, bool aStrict )
}
int GraphicTextWidth( const wxString& aText, KIFONT::FONT* aFont, const VECTOR2I& aSize,
int aThickness, bool aBold, bool aItalic )
int GRTextWidth( const wxString& aText, KIFONT::FONT* aFont, const VECTOR2I& aSize,
int aThickness, bool aBold, bool aItalic, const KIFONT::METRICS& aFontMetrics )
{
if( !aFont )
aFont = KIFONT::FONT::GetFont();
return KiROUND( aFont->StringBoundaryLimits( aText, aSize, aThickness, aBold, aItalic ).x );
return KiROUND( aFont->StringBoundaryLimits( aText, aSize, aThickness, aBold, aItalic,
aFontMetrics ).x );
}
@ -141,7 +142,8 @@ int GraphicTextWidth( const wxString& aText, KIFONT::FONT* aFont, const VECTOR2I
void GRPrintText( wxDC* aDC, const VECTOR2I& aPos, const COLOR4D& aColor, const wxString& aText,
const EDA_ANGLE& aOrient, const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify, enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth, bool aItalic, bool aBold, KIFONT::FONT* aFont )
int aWidth, bool aItalic, bool aBold, KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics )
{
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
bool fill_mode = true;
@ -182,7 +184,7 @@ void GRPrintText( wxDC* aDC, const VECTOR2I& aPos, const COLOR4D& aColor, const
attributes.m_Valign = aV_justify;
attributes.m_Size = aSize;
aFont->Draw( &callback_gal, aText, aPos, attributes );
aFont->Draw( &callback_gal, aText, aPos, attributes, aFontMetrics );
}

View File

@ -863,19 +863,20 @@ bool containsNonAsciiChars( const wxString& string )
}
void DXF_PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
void* aData )
void DXF_PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
// Fix me: see how to use DXF text mode for multiline texts
if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) )
@ -889,7 +890,7 @@ void DXF_PLOTTER::Text( const VECTOR2I& aPos,
// Perhaps multiline texts could be handled as DXF text entity
// but I do not want spend time about this (JPC)
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
aBold, aMultilineAllowed, aFont, aData );
aBold, aMultilineAllowed, aFont, aFontMetrics, aData );
}
else
{
@ -907,11 +908,13 @@ void DXF_PLOTTER::Text( const VECTOR2I& aPos,
}
void DXF_PLOTTER::PlotText( const VECTOR2I& aPos, const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
void* aData )
void DXF_PLOTTER::PlotText( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
TEXT_ATTRIBUTES attrs = aAttributes;
// Fix me: see how to use DXF text mode for multiline texts
@ -925,15 +928,16 @@ void DXF_PLOTTER::PlotText( const VECTOR2I& aPos, const COLOR4D& aColor,
// output text as graphics.
// Perhaps multiline texts could be handled as DXF text entity
// but I do not want spend time about that (JPC)
PLOTTER::PlotText( aPos, aColor, aText, aAttributes, aFont, aData );
PLOTTER::PlotText( aPos, aColor, aText, aAttributes, aFont, aFontMetrics, aData );
}
else
plotOneLineOfText( aPos, aColor, aText, attrs );
{
plotOneLineOfText( aPos, aColor, aText, attrs );
}
}
void DXF_PLOTTER::plotOneLineOfText( const VECTOR2I& aPos, const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes )
const wxString& aText, const TEXT_ATTRIBUTES& aAttributes )
{
/* Emit text as a text entity. This loses formatting and shape but it's
more useful as a CAD object */
@ -989,9 +993,9 @@ void DXF_PLOTTER::plotOneLineOfText( const VECTOR2I& aPos, const COLOR4D& aColor
"%d\n" // H alignment
" 73\n"
"%d\n", // V alignment
aAttributes.m_Bold ?
(aAttributes.m_Italic ? "KICADBI" : "KICADB")
: (aAttributes.m_Italic ? "KICADI" : "KICAD"), TO_UTF8( cname ),
aAttributes.m_Bold ? ( aAttributes.m_Italic ? "KICADBI" : "KICADB" )
: ( aAttributes.m_Italic ? "KICADI" : "KICAD" ),
TO_UTF8( cname ),
formatCoord( origin_dev.x ).c_str(), formatCoord( origin_dev.x ).c_str(),
formatCoord( origin_dev.y ).c_str(), formatCoord( origin_dev.y ).c_str(),
formatCoord( size_dev.y ).c_str(), formatCoord( fabs( size_dev.x / size_dev.y ) ).c_str(),

View File

@ -1976,19 +1976,20 @@ void GERBER_PLOTTER::FlashRegularPolygon( const VECTOR2I& aShapePos, int aDiamet
}
void GERBER_PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
void* aData )
void GERBER_PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
@ -1996,22 +1997,24 @@ void GERBER_PLOTTER::Text( const VECTOR2I& aPos,
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth,
aItalic, aBold, aMultilineAllowed, aFont, aData );
aItalic, aBold, aMultilineAllowed, aFont, aFontMetrics, aData );
}
void GERBER_PLOTTER::PlotText( const VECTOR2I& aPos, const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
void* aData )
void GERBER_PLOTTER::PlotText( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
GBR_METADATA* gbr_metadata = static_cast<GBR_METADATA*>( aData );
if( gbr_metadata )
formatNetAttribute( &gbr_metadata->m_NetlistMetadata );
PLOTTER::PlotText( aPos, aColor, aText, aAttributes, aFont, aData );
PLOTTER::PlotText( aPos, aColor, aText, aAttributes, aFont, aFontMetrics, aData );
}
void GERBER_PLOTTER::SetLayerPolarity( bool aPositive )

View File

@ -1551,19 +1551,20 @@ function ShM(aEntries) {
}
void PDF_PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
void* aData )
void PDF_PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
// PDF files do not like 0 sized texts which create broken files.
if( aSize.x == 0 || aSize.y == 0 )
@ -1596,7 +1597,8 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos,
if( !aFont )
aFont = KIFONT::FONT::GetFont();
VECTOR2I full_box( aFont->StringBoundaryLimits( aText, t_size, aWidth, aBold, aItalic ) );
VECTOR2I full_box( aFont->StringBoundaryLimits( aText, t_size, aWidth, aBold, aItalic,
aFontMetrics ) );
VECTOR2I box_x( full_box.x, 0 );
VECTOR2I box_y( 0, full_box.y );
@ -1623,7 +1625,8 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos,
// Extract the changed width and rotate by the orientation to get the offset for the
// next word
VECTOR2I bbox( aFont->StringBoundaryLimits( word, t_size, aWidth, aBold, aItalic ).x, 0 );
VECTOR2I bbox( aFont->StringBoundaryLimits( word, t_size, aWidth,
aBold, aItalic, aFontMetrics ).x, 0 );
RotatePoint( bbox, aOrient );
pos += bbox;
@ -1647,15 +1650,17 @@ void PDF_PLOTTER::Text( const VECTOR2I& aPos,
// Plot the stroked text (if requested)
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
aBold, aMultilineAllowed, aFont );
aBold, aMultilineAllowed, aFont, aFontMetrics );
}
void PDF_PLOTTER::PlotText( const VECTOR2I& aPos, const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
void* aData )
void PDF_PLOTTER::PlotText( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
VECTOR2I size = aAttributes.m_Size;
@ -1666,12 +1671,9 @@ void PDF_PLOTTER::PlotText( const VECTOR2I& aPos, const COLOR4D& aColor,
if( aAttributes.m_Mirrored )
size.x = -size.x;
PDF_PLOTTER::Text( aPos, aColor, aText, aAttributes.m_Angle, size,
aAttributes.m_Halign, aAttributes.m_Valign,
aAttributes.m_StrokeWidth,
aAttributes.m_Italic, aAttributes.m_Bold,
aAttributes.m_Multiline,
aFont, aData );
PDF_PLOTTER::Text( aPos, aColor, aText, aAttributes.m_Angle, size, aAttributes.m_Halign,
aAttributes.m_Valign, aAttributes.m_StrokeWidth, aAttributes.m_Italic,
aAttributes.m_Bold, aAttributes.m_Multiline, aFont, aFontMetrics, aData );
}

View File

@ -333,15 +333,11 @@ int PSLIKE_PLOTTER::returnPostscriptTextWidth( const wxString& aText, int aXSize
: ( aItalic ? hvo_widths : hv_widths );
double tally = 0;
for( unsigned i = 0; i < aText.length(); i++ )
for( wchar_t asciiCode : aText)
{
wchar_t AsciiCode = aText[i];
// Skip the negation marks and untabled points.
if( AsciiCode != '~' && AsciiCode < 256 )
{
tally += width_table[AsciiCode];
}
if( asciiCode != '~' && asciiCode < 256 )
tally += width_table[asciiCode];
}
// Widths are proportional to height, but height is enlarged by a scaling factor.
@ -349,38 +345,6 @@ int PSLIKE_PLOTTER::returnPostscriptTextWidth( const wxString& aText, int aXSize
}
void PSLIKE_PLOTTER::postscriptOverlinePositions( const wxString& aText, int aXSize,
bool aItalic, bool aBold,
std::vector<int> *pos_pairs )
{
/* XXX This function is *too* similar to returnPostscriptTextWidth.
Consider merging them... */
const double *width_table = aBold ? ( aItalic ? hvbo_widths : hvb_widths )
: ( aItalic ? hvo_widths : hv_widths );
double tally = 0;
for( unsigned i = 0; i < aText.length(); i++ )
{
wchar_t AsciiCode = aText[i];
// Skip the negation marks and untabled points
if( AsciiCode != '~' && AsciiCode < 256 )
{
tally += width_table[AsciiCode];
}
else
{
if( AsciiCode == '~' )
pos_pairs->push_back( KiROUND( aXSize * tally / postscriptTextAscent ) );
}
}
// Special rule: we have to complete the last bar if the ~ aren't matched
if( pos_pairs->size() % 2 == 1 )
pos_pairs->push_back( KiROUND( aXSize * tally / postscriptTextAscent ) );
}
void PS_PLOTTER::SetViewport( const VECTOR2I& aOffset, double aIusPerDecimil,
double aScale, bool aMirror )
{
@ -937,19 +901,20 @@ bool PS_PLOTTER::EndPlot()
void PS_PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
void* aData )
void PS_PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
SetCurrentLineWidth( aWidth );
SetColor( aColor );
@ -963,16 +928,17 @@ void PS_PLOTTER::Text( const VECTOR2I& aPos,
}
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
aBold, aMultilineAllowed, aFont, aData );
aBold, aMultilineAllowed, aFont, aFontMetrics, aData );
}
void PS_PLOTTER::PlotText( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
void* aData )
void PS_PLOTTER::PlotText( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
SetCurrentLineWidth( aAttributes.m_StrokeWidth );
SetColor( aColor );
@ -985,7 +951,7 @@ void PS_PLOTTER::PlotText( const VECTOR2I& aPos,
fprintf( m_outputFile, "%s %g %g phantomshow\n", ps_test.c_str(), pos_dev.x, pos_dev.y );
}
PLOTTER::PlotText( aPos, aColor, aText, aAttributes, aFont, aData );
PLOTTER::PlotText( aPos, aColor, aText, aAttributes, aFont, aFontMetrics, aData );
}

View File

@ -169,7 +169,6 @@ SVG_PLOTTER::SVG_PLOTTER()
m_brush_rgb_color = 0; // current color value (black)
m_brush_alpha = 1.0;
m_dashed = PLOT_DASH_TYPE::SOLID;
m_useInch = false; // millimeters are always the svg unit
m_precision = 4; // default: 4 digits in mantissa.
}
@ -778,19 +777,20 @@ bool SVG_PLOTTER::EndPlot()
}
void SVG_PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
void* aData )
void SVG_PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
setFillMode( FILL_T::NO_FILL );
SetColor( aColor );
@ -817,7 +817,7 @@ void SVG_PLOTTER::Text( const VECTOR2I& aPos,
// aSize.x or aSize.y is < 0 for mirrored texts.
// The actual text size value is the absolute value
text_size.x = std::abs( GraphicTextWidth( aText, aFont, aSize, aWidth, aBold, aItalic ) );
text_size.x = std::abs( GRTextWidth( aText, aFont, aSize, aWidth, aBold, aItalic, aFontMetrics ) );
text_size.y = std::abs( aSize.x * 4/3 ); // Hershey font height to em size conversion
VECTOR2D anchor_pos_dev = userToDeviceCoordinates( aPos );
VECTOR2D text_pos_dev = userToDeviceCoordinates( text_pos );
@ -849,27 +849,26 @@ void SVG_PLOTTER::Text( const VECTOR2I& aPos,
TO_UTF8( XmlEsc( aText ) ) );
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic,
aBold, aMultilineAllowed, aFont );
aBold, aMultilineAllowed, aFont, aFontMetrics );
fputs( "</g>", m_outputFile );
}
void SVG_PLOTTER::PlotText( const VECTOR2I& aPos, const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
void* aData )
void SVG_PLOTTER::PlotText( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
VECTOR2I size = aAttributes.m_Size;
if( aAttributes.m_Mirrored )
size.x = -size.x;
SVG_PLOTTER::Text( aPos, aColor, aText, aAttributes.m_Angle, size,
aAttributes.m_Halign, aAttributes.m_Valign,
aAttributes.m_StrokeWidth,
aAttributes.m_Italic, aAttributes.m_Bold,
aAttributes.m_Multiline,
aFont, aData );
SVG_PLOTTER::Text( aPos, aColor, aText, aAttributes.m_Angle, size, aAttributes.m_Halign,
aAttributes.m_Valign, aAttributes.m_StrokeWidth, aAttributes.m_Italic,
aAttributes.m_Bold, aAttributes.m_Multiline, aFont, aFontMetrics, aData );
}

View File

@ -153,7 +153,7 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
plotter->Text( text->GetTextPos(), color, text->GetShownText( true ),
text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(),
text->GetVertJustify(), penWidth, text->IsItalic(), text->IsBold(),
text->IsMultilineAllowed(), font );
text->IsMultilineAllowed(), font, text->GetFontMetrics() );
}
break;

View File

@ -712,19 +712,20 @@ void PLOTTER::PlotPoly( const SHAPE_LINE_CHAIN& aCornerList, FILL_T aFill, int a
}
void PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aPenWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
void* aData )
void PLOTTER::Text( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const EDA_ANGLE& aOrient,
const VECTOR2I& aSize,
enum GR_TEXT_H_ALIGN_T aH_justify,
enum GR_TEXT_V_ALIGN_T aV_justify,
int aPenWidth,
bool aItalic,
bool aBold,
bool aMultilineAllowed,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
@ -770,14 +771,16 @@ void PLOTTER::Text( const VECTOR2I& aPos,
if( !aFont )
aFont = KIFONT::FONT::GetFont();
aFont->Draw( &callback_gal, aText, aPos, attributes );
aFont->Draw( &callback_gal, aText, aPos, attributes, aFontMetrics );
}
void PLOTTER::PlotText( const VECTOR2I& aPos, const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
void* aData )
void PLOTTER::PlotText( const VECTOR2I& aPos,
const COLOR4D& aColor,
const wxString& aText,
const TEXT_ATTRIBUTES& aAttributes,
KIFONT::FONT* aFont,
const KIFONT::METRICS& aFontMetrics,
void* aData )
{
KIGFX::GAL_DISPLAY_OPTIONS empty_opts;
@ -812,5 +815,5 @@ void PLOTTER::PlotText( const VECTOR2I& aPos, const COLOR4D& aColor,
if( !aFont )
aFont = KIFONT::FONT::GetFont();
aFont->Draw( &callback_gal, aText, aPos, attributes );
aFont->Draw( &callback_gal, aText, aPos, attributes, aFontMetrics );
}

View File

@ -187,6 +187,6 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
for( const wxString& str : aStrings )
{
textPos.y += textDims.LinePitch;
font->Draw( gal, str, textPos, textAttrs );
font->Draw( gal, str, textPos, textAttrs, KIFONT::METRICS::Default() );
}
}

View File

@ -248,7 +248,7 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT
if( drawLabel )
{
wxString label = DimensionLabel( "", tickSpace * i, aIuScale, aUnits, false );
font->Draw( gal, label, tickPos + labelOffset, labelAttrs );
font->Draw( gal, label, tickPos + labelOffset, labelAttrs, KIFONT::METRICS::Default() );
}
}
}

View File

@ -110,6 +110,7 @@ bool PANEL_SETUP_FORMATTING::TransferDataToWindow()
ctrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale, units, value ) )
SET_VALUE( m_textOffsetRatioCtrl, EDA_UNITS::PERCENT, settings.m_TextOffsetRatio * 100.0 );
SET_VALUE( m_overbarHeightCtrl, EDA_UNITS::PERCENT, settings.m_FontMetrics.m_OverbarHeight * 100.0 );
SET_VALUE( m_dashLengthCtrl, EDA_UNITS::UNSCALED, settings.m_DashedLineDashRatio );
SET_VALUE( m_gapLengthCtrl, EDA_UNITS::UNSCALED, settings.m_DashedLineGapRatio );
SET_VALUE( m_labelSizeRatioCtrl, EDA_UNITS::PERCENT, settings.m_LabelSizeRatio * 100.0 );
@ -166,6 +167,7 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow()
#define GET_VALUE( units, str ) EDA_UNIT_UTILS::UI::DoubleValueFromString( unityScale, units, str )
settings.m_TextOffsetRatio = GET_VALUE( EDA_UNITS::PERCENT, m_textOffsetRatioCtrl->GetValue() ) / 100.0;
settings.m_FontMetrics.m_OverbarHeight = GET_VALUE( EDA_UNITS::PERCENT, m_overbarHeightCtrl->GetValue() ) / 100.0;
settings.m_DashedLineDashRatio = GET_VALUE( EDA_UNITS::UNSCALED, m_dashLengthCtrl->GetValue() );
settings.m_DashedLineGapRatio = GET_VALUE( EDA_UNITS::UNSCALED, m_gapLengthCtrl->GetValue() );
settings.m_LabelSizeRatio = GET_VALUE( EDA_UNITS::PERCENT, m_labelSizeRatioCtrl->GetValue() ) / 100.0;

View File

@ -63,6 +63,17 @@ PANEL_SETUP_FORMATTING_BASE::PANEL_SETUP_FORMATTING_BASE( wxWindow* parent, wxWi
m_textSizeUnits->Wrap( -1 );
fgSizer2->Add( m_textSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxFIXED_MINSIZE, 5 );
m_overbarHieghtLabel = new wxStaticText( sbSizer4->GetStaticBox(), wxID_ANY, _("Overbar offset ratio:"), wxDefaultPosition, wxDefaultSize, 0 );
m_overbarHieghtLabel->Wrap( -1 );
fgSizer2->Add( m_overbarHieghtLabel, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_overbarHeightCtrl = new wxTextCtrl( sbSizer4->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
fgSizer2->Add( m_overbarHeightCtrl, 0, wxEXPAND, 5 );
m_overbarHeightUnits = new wxStaticText( sbSizer4->GetStaticBox(), wxID_ANY, _("%"), wxDefaultPosition, wxDefaultSize, 0 );
m_overbarHeightUnits->Wrap( -1 );
fgSizer2->Add( m_overbarHeightUnits, 0, wxALIGN_CENTER_VERTICAL, 5 );
m_textOffsetRatioLabel = new wxStaticText( sbSizer4->GetStaticBox(), wxID_ANY, _("Label offset ratio:"), wxDefaultPosition, wxDefaultSize, 0 );
m_textOffsetRatioLabel->Wrap( -1 );
m_textOffsetRatioLabel->SetToolTip( _("Percentage of the text size to offset labels above (or below) a wire, bus, or pin") );
@ -78,7 +89,7 @@ PANEL_SETUP_FORMATTING_BASE::PANEL_SETUP_FORMATTING_BASE( wxWindow* parent, wxWi
m_offsetRatioUnits->Wrap( -1 );
fgSizer2->Add( m_offsetRatioUnits, 0, wxALIGN_CENTER_VERTICAL|wxFIXED_MINSIZE, 5 );
m_labelSizeRatioLabel = new wxStaticText( sbSizer4->GetStaticBox(), wxID_ANY, _("Global label margin:"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelSizeRatioLabel = new wxStaticText( sbSizer4->GetStaticBox(), wxID_ANY, _("Global label margin ratio:"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelSizeRatioLabel->Wrap( -1 );
m_labelSizeRatioLabel->SetToolTip( _("Percentage of the text size to use as space around a global label") );

View File

@ -430,6 +430,192 @@
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Overbar offset ratio:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_overbarHieghtLabel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_overbarHeightCtrl</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">%</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_overbarHeightUnits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL</property>
@ -648,7 +834,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Global label margin:</property>
<property name="label">Global label margin ratio:</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>

View File

@ -45,6 +45,9 @@ class PANEL_SETUP_FORMATTING_BASE : public wxPanel
wxStaticText* m_textSizeLabel;
wxTextCtrl* m_textSizeCtrl;
wxStaticText* m_textSizeUnits;
wxStaticText* m_overbarHieghtLabel;
wxTextCtrl* m_overbarHeightCtrl;
wxStaticText* m_overbarHeightUnits;
wxStaticText* m_textOffsetRatioLabel;
wxTextCtrl* m_textOffsetRatioCtrl;
wxStaticText* m_offsetRatioUnits;

View File

@ -155,7 +155,7 @@ void LIB_FIELD::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
font = KIFONT::FONT::GetFont( aSettings->GetDefaultFont(), IsBold(), IsItalic() );
GRPrintText( DC, text_pos, color, text, GetTextAngle(), GetTextSize(), GetHorizJustify(),
GetVertJustify(), penWidth, IsItalic(), IsBold(), font );
GetVertJustify(), penWidth, IsItalic(), IsBold(), font, GetFontMetrics() );
}
@ -402,7 +402,7 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffs
attrs.m_Angle = orient;
attrs.m_Multiline = false;
aPlotter->PlotText( textpos, color, GetShownText( true ), attrs, font );
aPlotter->PlotText( textpos, color, GetShownText( true ), attrs, font, GetFontMetrics() );
}

View File

@ -137,6 +137,12 @@ const wxString& LIB_ITEM::GetDefaultFont() const
}
const KIFONT::METRICS& LIB_ITEM::GetFontMetrics() const
{
return KIFONT::METRICS::Default();
}
void LIB_ITEM::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
const TRANSFORM& aTransform, bool aDimmed )
{

Some files were not shown because too many files have changed in this diff Show More