Skip to content

Commit 5476080

Browse files
author
larspalo
committed
Implemented a font scaling in the same way as GrandOrgue does.
1 parent a724bc6 commit 5476080

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ cmake_minimum_required(VERSION 3.10)
1919
# Set the project name and info
2020
project(
2121
GOODF
22-
VERSION 0.6.1
22+
VERSION 0.6.2
2323
DESCRIPTION "GOODF - Software for creating and editing GrandOrgue ODFs"
2424
LANGUAGES CXX C
2525
)

src/GUIPanelRepresentation.cpp

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ GUIPanelRepresentation::GUIPanelRepresentation(wxWindow *parent, const wxString&
3333
m_EnclosureY = 0;
3434
m_CenterY = 0;
3535
m_CenterWidth = 0;
36+
m_FontScale = 1.0;
37+
InitFont();
3638
}
3739

3840
GUIPanelRepresentation::~GUIPanelRepresentation() {
@@ -158,7 +160,11 @@ void GUIPanelRepresentation::RenderPanel(wxDC& dc) {
158160
TileBitmap(imgRect, dc, theBmp, btnElement->getTileOffsetX(), btnElement->getTileOffsetY());
159161

160162
if (btnElement->getTextBreakWidth()) {
161-
dc.SetFont(btnElement->getDispLabelFont());
163+
wxFont theFont = btnElement->getDispLabelFont();
164+
int pointSize = theFont.GetPointSize();
165+
pointSize *= m_FontScale;
166+
theFont.SetPointSize(pointSize);
167+
dc.SetFont(theFont);
162168
dc.SetBackgroundMode(wxTRANSPARENT);
163169
dc.SetTextForeground(btnElement->getDispLabelColour()->getColor());
164170
wxRect textRect(
@@ -233,7 +239,11 @@ void GUIPanelRepresentation::RenderPanel(wxDC& dc) {
233239
TileBitmap(imgRect, dc, theBmp, btnElement->getTileOffsetX(), btnElement->getTileOffsetY());
234240

235241
if (btnElement->getTextBreakWidth()) {
236-
dc.SetFont(btnElement->getDispLabelFont());
242+
wxFont theFont = btnElement->getDispLabelFont();
243+
int pointSize = theFont.GetPointSize();
244+
pointSize *= m_FontScale;
245+
theFont.SetPointSize(pointSize);
246+
dc.SetFont(theFont);
237247
dc.SetBackgroundMode(wxTRANSPARENT);
238248
dc.SetTextForeground(btnElement->getDispLabelColour()->getColor());
239249
wxRect textRect(
@@ -303,7 +313,11 @@ void GUIPanelRepresentation::RenderPanel(wxDC& dc) {
303313
TileBitmap(imgRect, dc, theBmp, encElement->getTileOffsetX(), encElement->getTileOffsetY());
304314

305315
if (encElement->getTextBreakWidth()) {
306-
dc.SetFont(encElement->getDispLabelFont());
316+
wxFont theFont = encElement->getDispLabelFont();
317+
int pointSize = theFont.GetPointSize();
318+
pointSize *= m_FontScale;
319+
theFont.SetPointSize(pointSize);
320+
dc.SetFont(theFont);
307321
dc.SetBackgroundMode(wxTRANSPARENT);
308322
dc.SetTextForeground(encElement->getDispLabelColour()->getColor());
309323
wxRect textRect(
@@ -370,7 +384,11 @@ void GUIPanelRepresentation::RenderPanel(wxDC& dc) {
370384
}
371385

372386
if (labelElement->getTextBreakWidth() && labelElement->getName() != wxEmptyString) {
373-
dc.SetFont(labelElement->getDispLabelFont());
387+
wxFont theFont = labelElement->getDispLabelFont();
388+
int pointSize = theFont.GetPointSize();
389+
pointSize *= m_FontScale;
390+
theFont.SetPointSize(pointSize);
391+
dc.SetFont(theFont);
374392
dc.SetBackgroundMode(wxTRANSPARENT);
375393
dc.SetTextForeground(labelElement->getDispLabelColour()->getColor());
376394
wxRect textRect(
@@ -709,3 +727,13 @@ void GUIPanelRepresentation::DoUpdateLayout() {
709727
UpdateLayout();
710728
DoPaintNow();
711729
}
730+
731+
void GUIPanelRepresentation::InitFont() {
732+
wxMemoryDC dc;
733+
wxFont font = *wxNORMAL_FONT;
734+
wxCoord cx, cy;
735+
font.SetPointSize(39);
736+
dc.SetFont(font);
737+
dc.GetTextExtent(wxT("M"), &cx, &cy);
738+
m_FontScale = 62.0 / cy;
739+
}

src/GUIPanelRepresentation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class GUIPanelRepresentation : public wxDialog {
4242
int m_EnclosureY;
4343
int m_CenterY;
4444
int m_CenterWidth;
45+
double m_FontScale;
4546

4647
wxPoint GetDrawstopPosition(int row, int col);
4748
wxPoint GetPushbuttonPosition(int row, int col);
@@ -73,6 +74,7 @@ class GUIPanelRepresentation : public wxDialog {
7374
void RenderPanel(wxDC& dc);
7475
void TileBitmap(wxRect rect, wxDC& dc, wxBitmap& bitmap, int tileOffsetX, int tileOffsetY);
7576
wxString BreakTextLine(wxString text, int textBreakWidth, wxDC& dc);
77+
void InitFont();
7678

7779
};
7880

0 commit comments

Comments
 (0)