diff --git a/common/gal/stroke_font.cpp b/common/gal/stroke_font.cpp index efae66e271..2b397f3aac 100644 --- a/common/gal/stroke_font.cpp +++ b/common/gal/stroke_font.cpp @@ -30,6 +30,7 @@ #include #include // for KiROUND #include +#include using namespace KIGFX; diff --git a/common/gr_text.cpp b/common/gr_text.cpp index ee5adfd349..9fd571fd51 100644 --- a/common/gr_text.cpp +++ b/common/gr_text.cpp @@ -42,6 +42,22 @@ #include + +static int s_textMarkupFlags = 0; + + +void SetTextMarkupFlags( int aMarkupFlags ) +{ + s_textMarkupFlags = aMarkupFlags; +} + + +int GetTextMarkupFlags() +{ + return s_textMarkupFlags; +} + + /** * Function GetPensizeForBold * @return the "best" value for a pen size to draw/plot a bold text @@ -165,7 +181,7 @@ void GRText( wxDC* aDC, const wxPoint& aPos, COLOR4D aColor, const wxString& aTe basic_gal.m_Color = aColor; basic_gal.SetClipBox( nullptr ); - basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800 ); + basic_gal.StrokeText( aText, VECTOR2D( aPos ), aOrient * M_PI/1800, GetTextMarkupFlags() ); } diff --git a/common/plotters/DXF_plotter.cpp b/common/plotters/DXF_plotter.cpp index 29d40fec05..c98610d5f4 100644 --- a/common/plotters/DXF_plotter.cpp +++ b/common/plotters/DXF_plotter.cpp @@ -27,7 +27,6 @@ #include -#include #include #include #include @@ -879,7 +878,15 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) ) aMultilineAllowed = false; // the text has only one line. - if( textAsLines || containsNonAsciiChars( aText ) || aMultilineAllowed ) + bool processSuperSub = false; + + if( ( GetTextMarkupFlags() & ENABLE_SUBSCRIPT_MARKUP ) && aText.Contains( wxT( "#" ) ) ) + processSuperSub = true; + + if( ( GetTextMarkupFlags() & ENABLE_SUPERSCRIPT_MARKUP ) && aText.Contains( wxT( "^" ) ) ) + processSuperSub = true; + + if( textAsLines || containsNonAsciiChars( aText ) || aMultilineAllowed || processSuperSub ) { // output text as graphics. // Perhaps multiline texts could be handled as DXF text entity diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index 5ec3e66d48..7a80002892 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -998,9 +998,18 @@ void PS_PLOTTER::Text( const wxPoint& aPos, if( aMultilineAllowed && !aText.Contains( wxT( "\n" ) ) ) aMultilineAllowed = false; // the text has only one line. + bool processSuperSub = false; + + if( ( GetTextMarkupFlags() & ENABLE_SUBSCRIPT_MARKUP ) && aText.Contains( wxT( "#" ) ) ) + processSuperSub = true; + + if( ( GetTextMarkupFlags() & ENABLE_SUPERSCRIPT_MARKUP ) && aText.Contains( wxT( "^" ) ) ) + processSuperSub = true; + // Draw the native postscript text (if requested) // Currently: does not work: disable it - bool use_native = false; // = m_textMode == PLOT_TEXT_MODE::NATIVE && !aMultilineAllowed; + bool use_native = false; // = m_textMode == PLOT_TEXT_MODE::NATIVE + // && !aMultilineAllowed && !processSuperSub; if( use_native ) { diff --git a/eeschema/dialogs/panel_eeschema_display_options.cpp b/eeschema/dialogs/panel_eeschema_display_options.cpp index 3aa8c32f80..0303647e42 100644 --- a/eeschema/dialogs/panel_eeschema_display_options.cpp +++ b/eeschema/dialogs/panel_eeschema_display_options.cpp @@ -31,6 +31,7 @@ #include #include #include +#include PANEL_EESCHEMA_DISPLAY_OPTIONS::PANEL_EESCHEMA_DISPLAY_OPTIONS( SCH_EDIT_FRAME* aFrame, wxWindow* aWindow ) : @@ -76,7 +77,7 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataToWindow() m_junctionSize.SetValue( SCH_JUNCTION::GetSymbolSize() ); m_checkShowHiddenPins->SetValue( m_frame->GetShowAllPins() ); - int superSubFlags = KIGFX::ENABLE_SUBSCRIPT_MARKUP | KIGFX::ENABLE_SUPERSCRIPT_MARKUP; + int superSubFlags = ENABLE_SUBSCRIPT_MARKUP | ENABLE_SUPERSCRIPT_MARKUP; m_checkSuperSub->SetValue( GetTextMarkupFlags() & superSubFlags ); @@ -130,7 +131,7 @@ bool PANEL_EESCHEMA_DISPLAY_OPTIONS::TransferDataFromWindow() // Update canvas m_frame->GetRenderSettings()->m_ShowHiddenPins = m_checkShowHiddenPins->GetValue(); - int superSubFlags = KIGFX::ENABLE_SUBSCRIPT_MARKUP | KIGFX::ENABLE_SUPERSCRIPT_MARKUP; + int superSubFlags = ENABLE_SUBSCRIPT_MARKUP | ENABLE_SUPERSCRIPT_MARKUP; if( m_checkSuperSub->GetValue() ) SetTextMarkupFlags( GetTextMarkupFlags() | superSubFlags ); diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index f466301fe7..de549af706 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -44,13 +44,13 @@ #include #include #include +#include #include "sch_junction.h" static int s_defaultBusThickness = DEFAULTBUSTHICKNESS; static int s_defaultWireThickness = DEFAULTDRAWLINETHICKNESS; static int s_defaultTextSize = DEFAULT_SIZE_TEXT; static int s_drawDefaultLineThickness = -1; -static int s_textMarkupFlags = 0; static bool s_selectTextAsBox = false; static bool s_selectDrawChildren = true; static bool s_selectFillShapes = false; @@ -98,18 +98,6 @@ int GetDefaultLineThickness() } -void SetTextMarkupFlags( int aMarkupFlags ) -{ - s_textMarkupFlags = aMarkupFlags; -} - - -int GetTextMarkupFlags() -{ - return s_textMarkupFlags; -} - - void SetDefaultLineThickness( int aThickness ) { s_drawDefaultLineThickness = std::max( 1, aThickness ); diff --git a/eeschema/general.h b/eeschema/general.h index 6308c56acd..9608b6fa80 100644 --- a/eeschema/general.h +++ b/eeschema/general.h @@ -147,9 +147,6 @@ void SetSelectionFillShapes( bool aBool ); int GetSelectionThickness(); void SetSelectionThickness( int aThickness ); -int GetTextMarkupFlags(); -void SetTextMarkupFlags( int aMarkupFlags ); - COLOR4D GetLayerColor( SCH_LAYER_ID aLayer ); void SetLayerColor( COLOR4D aColor, SCH_LAYER_ID aLayer ); diff --git a/include/gal/graphics_abstraction_layer.h b/include/gal/graphics_abstraction_layer.h index 862fe18616..4a03a7c99f 100644 --- a/include/gal/graphics_abstraction_layer.h +++ b/include/gal/graphics_abstraction_layer.h @@ -46,12 +46,6 @@ class BITMAP_BASE; namespace KIGFX { -enum TEXT_MARKUP_FLAGS -{ - ENABLE_SUBSCRIPT_MARKUP = 1 << 0, - ENABLE_SUPERSCRIPT_MARKUP = 1 << 1 -}; - /** * @brief Class GAL is the abstract interface for drawing on a 2D-surface. * diff --git a/include/gr_text.h b/include/gr_text.h index 3ef54a67ac..7794f80968 100644 --- a/include/gr_text.h +++ b/include/gr_text.h @@ -50,6 +50,15 @@ class PLOTTER; +enum TEXT_MARKUP_FLAGS +{ + ENABLE_SUBSCRIPT_MARKUP = 1 << 0, + ENABLE_SUPERSCRIPT_MARKUP = 1 << 1 +}; + +int GetTextMarkupFlags(); +void SetTextMarkupFlags( int aMarkupFlags ); + /** * Function Clamp_Text_PenSize *As a rule, pen width should not be >1/4em, otherwise the character diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index afae54520a..39c3b90347 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -976,7 +976,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer ) m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetTextAttributes( aText ); - m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians() ); + m_gal->StrokeText( shownText, position, aText->GetTextAngleRadians(), GetTextMarkupFlags() ); } @@ -1008,7 +1008,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer ) m_gal->SetIsFill( false ); m_gal->SetIsStroke( true ); m_gal->SetTextAttributes( aText ); - m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians() ); + m_gal->StrokeText( shownText, position, aText->GetDrawRotationRadians(), GetTextMarkupFlags() ); // Draw the umbilical line if( aText->IsSelected() ) @@ -1138,7 +1138,8 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer ) m_gal->SetLineWidth( text.GetThickness() ); m_gal->SetTextAttributes( &text ); - m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians() ); + m_gal->StrokeText( text.GetShownText(), position, text.GetTextAngleRadians(), + GetTextMarkupFlags() ); }