DONE. Now GLFont.getFont() retturns a proxy that automatically selects the best font for the required size

This commit is contained in:
vsonnier
2016-06-23 21:17:02 +02:00
parent 83b62cddeb
commit 78cfe9c755
8 changed files with 142 additions and 196 deletions
+3 -3
View File
@@ -29,10 +29,10 @@ void ModeSelectorContext::DrawSelector(std::string label, int c, int cMax, bool
float viewHeight = (float) vp[3];
float viewWidth = (float) vp[2];
GLFont::GLFontSize fontSize = GLFont::GLFONT_SIZE18;
int fontSize = 18;
if (viewWidth < 30 || viewHeight < 200) {
fontSize = GLFont::GLFONT_SIZE16;
fontSize = 16;
}
glColor4f(r, g, b, a);
@@ -60,7 +60,7 @@ void ModeSelectorContext::DrawSelector(std::string label, int c, int cMax, bool
}
//Do not zoom the selectors
GLFont::getRawFont(fontSize).drawString(label, 0.0, y + height / 2.0, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
GLFont::getFont(fontSize).drawString(label, 0.0, y + height / 2.0, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER);
}
void ModeSelectorContext::DrawEnd() {
+5 -5
View File
@@ -166,11 +166,11 @@ void PrimaryGLContext::DrawDemodInfo(DemodulatorInstance *demod, RGBA4f color, l
}
if (demod->getDemodulatorType() == "USB") {
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
GLFont::getFont(16, GLFont::getScaleFactor()).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_LEFT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
} else if (demod->getDemodulatorType() == "LSB") {
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
GLFont::getFont(16, GLFont::getScaleFactor()).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
} else {
GLFont::getFont(GLFont::GLFONT_SIZE16).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
GLFont::getFont(16, GLFont::getScaleFactor()).drawString(demodLabel, uxPos, hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
}
glDisable(GL_BLEND);
@@ -253,7 +253,7 @@ void PrimaryGLContext::DrawFreqBwInfo(long long freq, int bw, RGBA4f color, long
double shadowOfsX = 4.0 / viewWidth, shadowOfsY = 2.0 / viewHeight;
GLFont& refDrawingFont = GLFont::getFont(GLFont::GLFONT_SIZE16);
GLFont::Drawer refDrawingFont = GLFont::getFont(16, GLFont::getScaleFactor());
if (lastType == "USB") {
glColor4f(0,0,0, 1.0);
@@ -407,7 +407,7 @@ void PrimaryGLContext::DrawDemod(DemodulatorInstance *demod, RGBA4f color, long
void PrimaryGLContext::drawSingleDemodLabel(const std::wstring& demodStr, float uxPos, float hPos, float xOfs, float yOfs, GLFont::Align demodAlign) {
GLFont& refDrawingFont = GLFont::getFont(GLFont::GLFONT_SIZE16);
GLFont::Drawer refDrawingFont = GLFont::getFont(16, GLFont::getScaleFactor());
glColor3f(0, 0, 0);
refDrawingFont.drawString(demodStr, 2.0 * (uxPos - 0.5) + xOfs,
+3 -2
View File
@@ -35,7 +35,7 @@ void ScopeContext::DrawTunerTitles(bool ppmMode) {
glColor3f(0.65f, 0.65f, 0.65f);
GLFont& refDrawingFont = GLFont::getFont(GLFont::GLFONT_SIZE12);
GLFont::Drawer refDrawingFont = GLFont::getFont(12, GLFont::getScaleFactor());
refDrawingFont.drawString(ppmMode?"Device PPM":"Frequency", -0.66f, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
refDrawingFont.drawString("Bandwidth", 0.0, -1.0+hPos, GLFont::GLFONT_ALIGN_CENTER, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
@@ -49,7 +49,8 @@ void ScopeContext::DrawDeviceName(std::string deviceName) {
float hPos = (float) (viewHeight - 20) / viewHeight;
glColor3f(0.65f, 0.65f, 0.65f);
GLFont::getFont(GLFont::GLFONT_SIZE12).drawString(deviceName.c_str(), 1.0, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
GLFont::getFont(12, GLFont::getScaleFactor()).drawString(deviceName.c_str(), 1.0, hPos, GLFont::GLFONT_ALIGN_RIGHT, GLFont::GLFONT_ALIGN_CENTER, 0, 0, true);
}
void ScopeContext::DrawEnd() {
+6 -6
View File
@@ -74,28 +74,28 @@ void TuningContext::DrawTuner(long long freq, int count, float displayPos, float
freqStr << freq;
std::string freqChars = freqStr.str();
GLFont::GLFontSize fontSize = GLFont::GLFONT_SIZE24;
int fontSize = 32;
if (viewHeight < 28) {
fontSize = GLFont::GLFONT_SIZE18;
fontSize = 18;
}
if (viewHeight < 24) {
fontSize = GLFont::GLFONT_SIZE16;
fontSize = 16;
}
if (viewHeight < 18) {
fontSize = GLFont::GLFONT_SIZE12;
fontSize = 12;
}
glColor3f(ThemeMgr::mgr.currentTheme->text.r, ThemeMgr::mgr.currentTheme->text.g, ThemeMgr::mgr.currentTheme->text.b);
int numChars = freqChars.length();
int ofs = count - numChars;
//do not zoom this one:
GLFont& refDrawingFont = GLFont::getRawFont(fontSize);
GLFont::Drawer refDrawingFont = GLFont::getFont(fontSize);
for (int i = ofs; i < count; i++) {
float xpos = displayPos + (displayWidth / (float) count) * (float) i + ((displayWidth / 2.0) / (float) count);