Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a font scaling problem #42

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/clap-saw-demo-editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,15 @@ void ClapSawDemoEditor::setupUI()
{
auto scaleFont = [this](VSTGUI::CFontRef font)
{
font->setSize(font->getSize() * uiScale);
return font;
auto res = VSTGUI::makeOwned<VSTGUI::CFontDesc>(*font);
res->setSize(res->getSize() * uiScale);
res->remember();
return res;
};
scaleFont(VSTGUI::kNormalFont);
scaleFont(VSTGUI::kNormalFontVeryBig);
scaleFont(VSTGUI::kNormalFontSmall);
scaleFont(VSTGUI::kNormalFontSmaller);
knF = scaleFont(VSTGUI::kNormalFont);
knFVeryBig = scaleFont(VSTGUI::kNormalFontVeryBig);
knFSmall = scaleFont(VSTGUI::kNormalFontSmall);
knFSmaller = scaleFont(VSTGUI::kNormalFontSmaller);

// Resize as we should now have our scale
frame->setSize(applyUIScale(ClapSawDemo::GUI_DEFAULT_W),
Expand All @@ -283,7 +285,7 @@ void ClapSawDemoEditor::setupUI()
auto l = new VSTGUI::CTextLabel(VSTGUI::CRect(0, 0, getFrame()->getWidth(), applyUIScale(40)),
"Clap Saw Synth Demo");
l->setTransparency(true);
l->setFont(VSTGUI::kNormalFontVeryBig);
l->setFont(knFVeryBig);
l->setHoriAlign(VSTGUI::CHoriTxtAlign::kCenterText);
topLabel = l;
frame->addView(topLabel);
Expand All @@ -293,7 +295,7 @@ void ClapSawDemoEditor::setupUI()
VSTGUI::CPoint(getFrame()->getWidth(), applyUIScale(20))),
"poly=0");
l->setTransparency(true);
l->setFont(VSTGUI::kNormalFont);
l->setFont(knF);
l->setHoriAlign(VSTGUI::CHoriTxtAlign::kCenterText);
statusLabel = l;
frame->addView(statusLabel);
Expand All @@ -303,7 +305,7 @@ void ClapSawDemoEditor::setupUI()
VSTGUI::CPoint(getFrame()->getWidth(), applyUIScale(20))),
"https://github.com/surge-synthesizer/clap-saw-demo");
l->setTransparency(true);
l->setFont(VSTGUI::kNormalFontSmall);
l->setFont(knFSmall);
l->setHoriAlign(VSTGUI::CHoriTxtAlign::kCenterText);
repoLabel = l;
frame->addView(repoLabel);
Expand All @@ -316,7 +318,7 @@ void ClapSawDemoEditor::setupUI()
VSTGUI::CPoint(getFrame()->getWidth(), applyUIScale(20))),
sl.c_str());
l->setTransparency(true);
l->setFont(VSTGUI::kNormalFontSmaller);
l->setFont(knFSmaller);
l->setHoriAlign(VSTGUI::CHoriTxtAlign::kCenterText);
bottomLabel = l;
frame->addView(bottomLabel);
Expand All @@ -338,7 +340,7 @@ void ClapSawDemoEditor::setupUI()
VSTGUI::CPoint(applyUIScale(x) - applyUIScale(10), applyUIScale(y) + applyUIScale(155)),
VSTGUI::CPoint(applyUIScale(45), applyUIScale(15))));
l->setText(label.c_str());
l->setFont(VSTGUI::kNormalFont);
l->setFont(knF);

frame->addView(l);
return q;
Expand Down
2 changes: 2 additions & 0 deletions src/clap-saw-demo-editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ struct ClapSawDemoEditor : public VSTGUI::VSTGUIEditorInterface, public VSTGUI::
VSTGUI::CTextLabel *topLabel{nullptr}, *repoLabel{nullptr}, *bottomLabel{nullptr},
*statusLabel{nullptr};

VSTGUI::CFontRef knF, knFVeryBig, knFSmall, knFSmaller;

VSTGUI::CTextLabel *ampLabel{nullptr};
VSTGUI::CCheckBox *ampToggle{nullptr};
VSTGUI::CSlider *ampAttack{nullptr}, *ampRelease{nullptr};
Expand Down
Loading