Refinement of commit 355575e4
(drawing shadow texts of RULER_ITEM and pin names)
Also handle non Kicad fonts (that do not use shadow texts) Fixes #15019 https://gitlab.com/kicad/code/kicad/-/issues/15019
This commit is contained in:
parent
3a0f8214fa
commit
1698fb6608
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019-2021 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2019-2023 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* 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
|
||||
|
@ -158,6 +158,13 @@ void KIGFX::PREVIEW::DrawTextNextToCursor( KIGFX::VIEW* aView, const VECTOR2D& a
|
|||
// around the basic text
|
||||
int shadowXoffset = aDrawingDropShadows ? textDims.ShadowWidth : 0;
|
||||
|
||||
// Due to the fact a shadow text is drawn left or right aligned,
|
||||
// it needs an offset = shadowWidth/2 to be drawn at the same place as normal text
|
||||
// But for some reason we need to slightly modify this offset
|
||||
// for a better look for KiCad font (better alignment of shadow shape)
|
||||
const float adjust = 1.2f; // Value chosen after tests
|
||||
shadowXoffset *= adjust;
|
||||
|
||||
if( ( textAttrs.m_Halign == GR_TEXT_H_ALIGN_LEFT ) != viewFlipped )
|
||||
textPos.x -= shadowXoffset;
|
||||
else
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017-2022 Kicad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2017-2023 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -175,6 +175,12 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT
|
|||
{
|
||||
labelDims.StrokeWidth += 2 * labelDims.ShadowWidth;
|
||||
shadowXoffset = labelDims.ShadowWidth;
|
||||
// Due to the fact a shadow text is drawn left or right aligned,
|
||||
// it needs an offset = shadowXoffset to be drawn at the same place as normal text
|
||||
// But for some reason we need to slightly modify this offset
|
||||
// for a better look for KiCad font (better alignment of shadow shape)
|
||||
const float adjust = 1.2f; // Value chosen after tests
|
||||
shadowXoffset *= adjust;
|
||||
}
|
||||
|
||||
if( aView->IsMirroredX() )
|
||||
|
|
|
@ -1628,11 +1628,18 @@ void SCH_PAINTER::draw( const LIB_PIN* aPin, int aLayer, bool aDimmed )
|
|||
for( float& t : thickness )
|
||||
t += shadowWidth;
|
||||
|
||||
// Due to the fact a shadow text in position ISIDE or OUTSIDE is drawn left or right aligned,
|
||||
// it needs an offset = shadowWidth/2 to be drawn at the same place as normal text
|
||||
// Due to the fact a shadow text in position INSIDE or OUTSIDE is drawn left or right aligned,
|
||||
// it needs an offset = shadowWidth/2 to be drawn at the same place as normal text
|
||||
// texts drawn as GR_TEXT_H_ALIGN_CENTER do not need a specific offset.
|
||||
insideOffset -= shadowWidth/2.0f;
|
||||
outsideOffset -= shadowWidth/2.0f;
|
||||
// this offset is shadowWidth/2 but for some reason we need to slightly modify this offset
|
||||
// for a better look (better alignment of shadow shape), for KiCad font only
|
||||
if( !KIFONT::FONT::GetFont( eeconfig()->m_Appearance.default_font )->IsOutline() )
|
||||
{
|
||||
const float adjust = 1.2f; // Value chosen after tests
|
||||
float shadowOffset = shadowWidth/2.0f * adjust;
|
||||
insideOffset -= shadowOffset;
|
||||
outsideOffset -= shadowOffset;
|
||||
}
|
||||
}
|
||||
|
||||
auto drawText =
|
||||
|
|
Loading…
Reference in New Issue