mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-03 06:24:49 -04:00
Add font scale support to meter panel
This commit is contained in:
@@ -857,6 +857,30 @@ double GLFont::getScaleFactor() {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
int GLFont::getScaledPx(int basicFontSize, double scaleFactor) {
|
||||
//try to align on an integer pixel size if the targetSize font is available
|
||||
int targetSize = round(basicFontSize * scaleFactor);
|
||||
int resultIndex = 0;
|
||||
|
||||
fonts[0].loadFontOnce();
|
||||
|
||||
for (int i = 0; i < GLFONT_SIZE_MAX - 1; i++) {
|
||||
|
||||
fonts[i + 1].loadFontOnce();
|
||||
|
||||
if (fonts[i + 1].pixHeight <= targetSize) {
|
||||
resultIndex = i + 1;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
} //end for
|
||||
|
||||
// return font height px
|
||||
return fonts[resultIndex].pixHeight;
|
||||
}
|
||||
|
||||
|
||||
GLFont::Drawer::Drawer(int basicFontSize, double scaleFactor) {
|
||||
|
||||
//Selection of the final font: scan GLFont::fonts to find the biggest font such as
|
||||
|
||||
@@ -112,6 +112,9 @@ public:
|
||||
|
||||
//Mean current scale factor: 1.0 in normal, 1.5 medium, 2.0 for large
|
||||
static double getScaleFactor();
|
||||
|
||||
//Return a valid font px height given the font size and scale factor
|
||||
static int getScaledPx(int basicFontSize, double scaleFactor);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user