Add font scale support to meter panel

This commit is contained in:
Charles J. Cliffe
2016-07-21 18:43:11 -04:00
parent 3d5757d8d8
commit 95fd357c72
3 changed files with 38 additions and 15 deletions
+24
View File
@@ -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
+3
View File
@@ -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: