Make GLFont its own pixHeight, so don't provide it in drawString() anymore

This commit is contained in:
vsonnier
2016-06-21 19:13:48 +02:00
parent 26bf1d9927
commit f52bad6196
8 changed files with 53 additions and 73 deletions
+17 -29
View File
@@ -267,11 +267,17 @@ void GLFont::loadFontOnce() {
while (!info_param.eof()) {
std::wstring param = nextParam(info_param);
std::wstring paramKey = getParamKey(param);
std::wstring paramValue = getParamValue(param);
std::wstring paramKey = getParamKey(param);
if (paramKey == L"face") {
fontName = paramValue;
fontName = getParamValue(param);
}
param = nextParam(info_param);
paramKey = getParamKey(param);
if (paramKey == L"size") {
std::wistringstream paramValue(getParamValue(param));
paramValue >> pixHeight;
}
// std::cout << "[" << paramKey << "] = '" << paramValue << "'" << std::endl;
@@ -495,14 +501,13 @@ float GLFont::getStringWidth(const std::wstring& str, float size, float viewAspe
}
// Draw string, immediate
void GLFont::drawString(const std::wstring& str, float xpos, float ypos, int pxHeight, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
void GLFont::drawString(const std::wstring& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
//load pxHeight from the font itself, but because it is an "internal font", the scaling has already been applied.
int pxHeight = pixHeight;
// Why another scale ?
pxHeight *= 2;
//Rise the pixel hight by the scale factor
pxHeight *= getScaleFactor();
if (!vpx || !vpy) {
GLint vp[4];
glGetIntegerv( GL_VIEWPORT, vp);
@@ -625,7 +630,7 @@ void GLFont::drawString(const std::wstring& str, float xpos, float ypos, int pxH
}
// Draw string, immediate, 8 bit version
void GLFont::drawString(const std::string& str, float xpos, float ypos, int pxHeight, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
void GLFont::drawString(const std::string& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
//Displayed string is wstring, so use wxString to do the heavy lifting of converting str...
#ifdef WIN32
@@ -637,7 +642,7 @@ void GLFont::drawString(const std::string& str, float xpos, float ypos, int pxHe
wsTmp.assign(str);
drawString(wsTmp.ToStdWstring(), xpos, ypos, pxHeight, hAlign, vAlign, vpx, vpy, cacheable);
drawString(wsTmp.ToStdWstring(), xpos, ypos, hAlign, vAlign, vpx, vpy, cacheable);
}
// Draw cached GLFontCacheString
@@ -873,7 +878,6 @@ void GLFont::setScale(GLFontScale scale) {
userFontZoomMapping[GLFont::GLFONT_SIZE32] = GLFont::GLFONT_SIZE64;
userFontZoomMapping[GLFont::GLFONT_SIZE36] = GLFont::GLFONT_SIZE72;
userFontZoomMapping[GLFont::GLFONT_SIZE48] = GLFont::GLFONT_SIZE96;
}
//Not overridden mapping stays normal, like the biggest fonts.
@@ -882,22 +886,6 @@ void GLFont::setScale(GLFontScale scale) {
//and the new fonts will show up.
}
double GLFont::getScaleFactor() {
std::lock_guard<std::mutex> lock(g_userFontZoomMappingMutex);
if (currentScaleFactor == GLFONT_SCALE_MEDIUM) {
return 1.5;
}
else if (currentScaleFactor == GLFONT_SCALE_LARGE) {
return 2.0;
}
return 1.0;
}
GLFont::GLFontScale GLFont::getScale() {
std::lock_guard<std::mutex> lock(g_userFontZoomMappingMutex);