1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-17 17:17:40 +02:00

Use the correct font to find lead size for custom fonts

This commit is contained in:
Paul Licameli 2020-01-23 13:39:22 -05:00
parent 99064d6dd5
commit a2babc646f
2 changed files with 12 additions and 5 deletions

View File

@ -344,7 +344,7 @@ MeterPanel::MeterPanel(AudacityProject *project,
wxColour backgroundColour = theTheme.Colour( clrMedium);
mBkgndBrush = wxBrush(backgroundColour, wxBRUSHSTYLE_SOLID);
SetBackgroundColour( backgroundColour );
mPeakPeakPen = wxPen(theTheme.Colour( clrMeterPeak), 1, wxPENSTYLE_SOLID);
mDisabledPen = wxPen(theTheme.Colour( clrMeterDisabledPen), 1, wxPENSTYLE_SOLID);

View File

@ -259,16 +259,23 @@ void Ruler::SetMinor(bool value)
namespace {
void FindFontHeights(
wxCoord &height, wxCoord &lead,
wxDC &dc, int fontSize, wxFontWeight weight = wxFONTWEIGHT_NORMAL )
wxCoord &height, wxCoord &lead, wxDC &dc, const wxFont &font )
{
wxCoord strW, strH, strD, strL;
static const wxString exampleText = wxT("0.9"); //ignored for height calcs on all platforms
dc.SetFont(wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, weight));
dc.SetFont( font );
dc.GetTextExtent(exampleText, &strW, &strH, &strD, &strL);
height = strH - strD - strL;
lead = strL;
}
void FindFontHeights(
wxCoord &height, wxCoord &lead,
wxDC &dc, int fontSize, wxFontWeight weight = wxFONTWEIGHT_NORMAL )
{
const wxFont font{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, weight };
FindFontHeights( height, lead, dc, font );
}
}
void Ruler::SetFonts(const wxFont &minorFont, const wxFont &majorFont, const wxFont &minorMinorFont)
@ -280,7 +287,7 @@ void Ruler::SetFonts(const wxFont &minorFont, const wxFont &majorFont, const wxF
wxScreenDC dc;
wxCoord height;
FindFontHeights( height, mpUserFonts->lead, dc, majorFont.GetPointSize() );
FindFontHeights( height, mpUserFonts->lead, dc, majorFont );
mpFonts.reset();
Invalidate();