mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-22 11:49:38 -05:00
DONE. Now GLFont.getFont() retturns a proxy that automatically selects the best font for the required size
This commit is contained in:
parent
83b62cddeb
commit
78cfe9c755
@ -214,15 +214,15 @@ void SpectrumPanel::drawPanelContents() {
|
||||
double hPos = 1.0 - (16.0 / viewHeight);
|
||||
double lMhzPos = 1.0 - (5.0 / viewHeight);
|
||||
|
||||
GLFont::GLFontSize fontEnumSize = GLFont::GLFONT_SIZE12;
|
||||
int fontSize = 12;
|
||||
|
||||
if (viewHeight > 135) {
|
||||
|
||||
fontEnumSize = GLFont::GLFONT_SIZE16;
|
||||
fontSize = 16;
|
||||
hPos = 1.0 - (18.0 / viewHeight);
|
||||
}
|
||||
|
||||
GLFont& refDrawingFont = GLFont::getFont(fontEnumSize);
|
||||
GLFont::Drawer refDrawingFont = GLFont::getFont(fontSize, GLFont::getScaleFactor());
|
||||
|
||||
for (double m = -1.0 + mhzStart, mMax = 1.0 + ((mhzStart>0)?mhzStart:-mhzStart); m <= mMax; m += mhzStep) {
|
||||
if (m < -1.0) {
|
||||
|
@ -390,63 +390,30 @@ GLTextPanel::GLTextPanel() : GLPanel() {
|
||||
|
||||
void GLTextPanel::drawPanelContents() {
|
||||
glColor4f(1, 1, 1, 1.0);
|
||||
|
||||
|
||||
GLFont::GLFontSize sz;
|
||||
|
||||
//beware here: the really applied font may have been scaled up compared to the "user" requested one, so that
|
||||
//we must negate it here to compute "user" font selection.
|
||||
float pdimy = pdim.y;
|
||||
|
||||
double appliedScaleFactor = GLFont::getScaleFactor();
|
||||
|
||||
if (!useNativeFont) {
|
||||
pdimy /= GLFont::getScaleFactor();
|
||||
}
|
||||
|
||||
if (pdimy <= 14) {
|
||||
sz = GLFont::GLFONT_SIZE12;
|
||||
|
||||
} else if (pdimy <= 18) {
|
||||
sz = GLFont::GLFONT_SIZE16;
|
||||
|
||||
} else if(pdimy <= 24) {
|
||||
sz = GLFont::GLFONT_SIZE18;
|
||||
|
||||
}else if (pdimy <= 27) {
|
||||
sz = GLFont::GLFONT_SIZE24;
|
||||
}
|
||||
else if (pdimy <= 32) {
|
||||
sz = GLFont::GLFONT_SIZE27;
|
||||
}
|
||||
else if (pdimy <= 36) {
|
||||
sz = GLFont::GLFONT_SIZE32;
|
||||
|
||||
}
|
||||
else if (pdimy <= 48) {
|
||||
sz = GLFont::GLFONT_SIZE36;
|
||||
|
||||
}
|
||||
else if (pdimy <= 64) {
|
||||
sz = GLFont::GLFONT_SIZE48;
|
||||
|
||||
}
|
||||
else if (pdimy <= 72) {
|
||||
sz = GLFont::GLFONT_SIZE64;
|
||||
|
||||
}
|
||||
else if (pdimy <= 96) {
|
||||
sz = GLFont::GLFONT_SIZE72;
|
||||
|
||||
}
|
||||
else {
|
||||
sz = GLFont::GLFONT_SIZE48;
|
||||
|
||||
}
|
||||
|
||||
if (useNativeFont) {
|
||||
GLFont::getRawFont(sz).drawString(textVal, mid, mid, horizAlign, vertAlign, (int)pdim.x, (int)pdim.y);
|
||||
}
|
||||
else {
|
||||
GLFont::getFont(sz).drawString(textVal, mid, mid, horizAlign, vertAlign, (int)pdim.x, (int)pdim.y);
|
||||
appliedScaleFactor = 1.0;
|
||||
}
|
||||
|
||||
//pdimy is considered un-scaled
|
||||
pdimy = round(pdimy / appliedScaleFactor);
|
||||
|
||||
//target font size: a bit smaller than pdimy:
|
||||
int sz = 12;
|
||||
|
||||
if (pdimy > 14) {
|
||||
//make the font a little smaller that the TextPanel
|
||||
sz = pdimy - 2;
|
||||
|
||||
}
|
||||
|
||||
GLFont::getFont(sz, appliedScaleFactor).drawString(textVal, mid, mid, horizAlign, vertAlign, (int)pdim.x, (int)pdim.y);
|
||||
}
|
||||
|
||||
void GLTextPanel::setText(std::string text, GLFont::Align hAlign, GLFont::Align vAlign, bool useNative) {
|
||||
|
@ -26,6 +26,8 @@ GLFontStringCache::GLFontStringCache() {
|
||||
|
||||
//Static initialization of all available fonts,
|
||||
//using aggregate syntax (Cx11+)
|
||||
|
||||
//Fonts must be listed in increasing size for Drawer to work !
|
||||
GLFont GLFont::fonts[GLFont::GLFontSize::GLFONT_SIZE_MAX] = {
|
||||
|
||||
{ GLFont::GLFontSize::GLFONT_SIZE12, L"fonts/vera_sans_mono12.fnt" },
|
||||
@ -42,25 +44,9 @@ GLFont GLFont::fonts[GLFont::GLFontSize::GLFONT_SIZE_MAX] = {
|
||||
|
||||
};
|
||||
|
||||
//default mapping: one-to-one (normal scale factor)
|
||||
GLFont::GLFontSize GLFont::userFontZoomMapping[GLFont::GLFontSize::GLFONT_SIZE_MAX] = {
|
||||
GLFont::GLFontSize::GLFONT_SIZE12,
|
||||
GLFont::GLFontSize::GLFONT_SIZE16,
|
||||
GLFont::GLFontSize::GLFONT_SIZE18,
|
||||
GLFont::GLFontSize::GLFONT_SIZE24,
|
||||
GLFont::GLFontSize::GLFONT_SIZE27,
|
||||
GLFont::GLFontSize::GLFONT_SIZE32,
|
||||
GLFont::GLFontSize::GLFONT_SIZE36,
|
||||
GLFont::GLFontSize::GLFONT_SIZE48,
|
||||
GLFont::GLFontSize::GLFONT_SIZE64,
|
||||
GLFont::GLFontSize::GLFONT_SIZE72,
|
||||
GLFont::GLFontSize::GLFONT_SIZE96
|
||||
};
|
||||
|
||||
std::atomic<GLFont::GLFontScale> GLFont::currentScale{ GLFont::GLFontScale::GLFONT_SCALE_NORMAL };
|
||||
|
||||
std::mutex GLFont::g_userFontZoomMappingMutex;
|
||||
|
||||
|
||||
GLFontChar::GLFontChar() :
|
||||
id(0), x(0), y(0), width(0), height(0), xoffset(0), yoffset(0), xadvance(0), aspect(1), index(0) {
|
||||
@ -460,13 +446,13 @@ void GLFont::loadFontOnce() {
|
||||
}
|
||||
|
||||
std::cout << "Loaded font '" << fontName << "' from '" << fontFileSource << "', parsed " << characters.size() << " characters." << std::endl;
|
||||
|
||||
loaded = true;
|
||||
} else {
|
||||
std::cout << "Error loading font file " << fontFileSource << std::endl;
|
||||
}
|
||||
|
||||
input.close();
|
||||
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
@ -501,10 +487,7 @@ 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, 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;
|
||||
void GLFont::drawString(const std::wstring& str, int pxHeight, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
|
||||
|
||||
pxHeight *= 2;
|
||||
|
||||
@ -630,7 +613,7 @@ void GLFont::drawString(const std::wstring& str, float xpos, float ypos, Align h
|
||||
}
|
||||
|
||||
// Draw string, immediate, 8 bit version
|
||||
void GLFont::drawString(const std::string& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
|
||||
void GLFont::drawString(const std::string& str, int pxHeight, 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
|
||||
@ -642,7 +625,7 @@ void GLFont::drawString(const std::string& str, float xpos, float ypos, Align hA
|
||||
|
||||
wsTmp.assign(str);
|
||||
|
||||
drawString(wsTmp.ToStdWstring(), xpos, ypos, hAlign, vAlign, vpx, vpy, cacheable);
|
||||
drawString(wsTmp.ToStdWstring(), pxHeight, xpos, ypos, hAlign, vAlign, vpx, vpy, cacheable);
|
||||
}
|
||||
|
||||
// Draw cached GLFontCacheString
|
||||
@ -818,32 +801,11 @@ void GLFont::clearAllCaches() {
|
||||
}
|
||||
|
||||
|
||||
GLFont &GLFont::getFont(GLFontSize esize) {
|
||||
GLFont::Drawer GLFont::getFont(int requestedSize, double scaleFactor) {
|
||||
|
||||
//really load the internal font instead!
|
||||
|
||||
GLFontSize internalFontSize = GLFONT_SIZE12;
|
||||
{ //guard block
|
||||
std::lock_guard<std::mutex> lock(g_userFontZoomMappingMutex);
|
||||
internalFontSize = userFontZoomMapping[esize];
|
||||
}
|
||||
|
||||
//load lazily...
|
||||
fonts[internalFontSize].loadFontOnce();
|
||||
|
||||
return fonts[internalFontSize];
|
||||
return GLFont::Drawer(requestedSize, scaleFactor);
|
||||
}
|
||||
|
||||
GLFont &GLFont::getRawFont(GLFontSize esize) {
|
||||
|
||||
//Do not apply the scaling, really returns the requested font.
|
||||
|
||||
|
||||
//load lazily...
|
||||
fonts[esize].loadFontOnce();
|
||||
|
||||
return fonts[esize];
|
||||
}
|
||||
|
||||
|
||||
void GLFont::setScale(GLFontScale scale) {
|
||||
@ -853,60 +815,6 @@ void GLFont::setScale(GLFontScale scale) {
|
||||
|
||||
scale = GLFontScale::GLFONT_SCALE_NORMAL;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(g_userFontZoomMappingMutex);
|
||||
|
||||
//Normal font (1:1 matching)
|
||||
if (scale == GLFontScale::GLFONT_SCALE_NORMAL) {
|
||||
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE12] = GLFont::GLFONT_SIZE12;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE16] = GLFont::GLFONT_SIZE16;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE18] = GLFont::GLFONT_SIZE18;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE24] = GLFont::GLFONT_SIZE24;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE27] = GLFont::GLFONT_SIZE27;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE32] = GLFont::GLFONT_SIZE32;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE36] = GLFont::GLFONT_SIZE36;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE48] = GLFont::GLFONT_SIZE48;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE64] = GLFont::GLFONT_SIZE64;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE72] = GLFont::GLFONT_SIZE72;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE96] = GLFont::GLFONT_SIZE96;
|
||||
|
||||
//override depending of zoom level:
|
||||
//Medium : more or less 1.5 x
|
||||
}
|
||||
else if (scale == GLFontScale::GLFONT_SCALE_MEDIUM) {
|
||||
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE12] = GLFont::GLFONT_SIZE18;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE16] = GLFont::GLFONT_SIZE24;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE18] = GLFont::GLFONT_SIZE27;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE24] = GLFont::GLFONT_SIZE36;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE27] = GLFont::GLFONT_SIZE36;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE32] = GLFont::GLFONT_SIZE48;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE36] = GLFont::GLFONT_SIZE48;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE48] = GLFont::GLFONT_SIZE72;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE64] = GLFont::GLFONT_SIZE96;
|
||||
|
||||
//too big: not-scaled properly and saturating:
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE72] = GLFont::GLFONT_SIZE96;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE96] = GLFont::GLFONT_SIZE96;
|
||||
}
|
||||
//Large : 2x normal, more or less
|
||||
else if (scale == GLFontScale::GLFONT_SCALE_LARGE) {
|
||||
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE12] = GLFont::GLFONT_SIZE24;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE16] = GLFont::GLFONT_SIZE32;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE18] = GLFont::GLFONT_SIZE36;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE24] = GLFont::GLFONT_SIZE48;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE27] = GLFont::GLFONT_SIZE48;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE32] = GLFont::GLFONT_SIZE64;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE36] = GLFont::GLFONT_SIZE72;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE48] = GLFont::GLFONT_SIZE96;
|
||||
|
||||
//too big: not-scaled properly or saturating:
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE64] = GLFont::GLFONT_SIZE96;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE72] = GLFont::GLFONT_SIZE96;
|
||||
userFontZoomMapping[GLFont::GLFONT_SIZE96] = GLFont::GLFONT_SIZE96;
|
||||
}
|
||||
|
||||
currentScale.store(scale);
|
||||
|
||||
@ -935,3 +843,50 @@ double GLFont::getScaleFactor() {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
GLFont::Drawer::Drawer(int basicFontSize, double scaleFactor) {
|
||||
|
||||
//Selection of the final font: scan GLFont::fonts to find the biggest font such as
|
||||
// its pixHeight <= basicFontSize * scaleFactor.
|
||||
//then compute finalScaleFactor the zooming factor of renderingFont to reach a
|
||||
//final font size of basicFontSize* scaleFactor:
|
||||
renderingFontIndex = 0;
|
||||
|
||||
double targetSize = basicFontSize * scaleFactor;
|
||||
|
||||
fonts[0].loadFontOnce();
|
||||
|
||||
for (int i = 0; i < GLFONT_SIZE_MAX - 1; i++) {
|
||||
|
||||
fonts[i + 1].loadFontOnce();
|
||||
|
||||
if (fonts[i + 1].pixHeight <= targetSize) {
|
||||
|
||||
renderingFontIndex = i + 1;
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
} //end for
|
||||
|
||||
//
|
||||
double rawSize = fonts[renderingFontIndex].pixHeight;
|
||||
|
||||
//targetSize may not be reached yet, so the effective rendering font: fonts[renderingFontIndex] must be scaled up a bit.
|
||||
renderingFontScaleFactor = targetSize / rawSize;
|
||||
}
|
||||
|
||||
void GLFont::Drawer::drawString(const std::wstring& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
|
||||
|
||||
GLFont& appliedFont = fonts[renderingFontIndex];
|
||||
|
||||
appliedFont.drawString(str, round(appliedFont.pixHeight * renderingFontScaleFactor), xpos, ypos, hAlign, vAlign, vpx, vpy, cacheable);
|
||||
}
|
||||
|
||||
//Public drawing font, 8 bit char version.
|
||||
void GLFont::Drawer::drawString(const std::string& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) {
|
||||
|
||||
GLFont& appliedFont = fonts[renderingFontIndex];
|
||||
|
||||
appliedFont.drawString(str, round(appliedFont.pixHeight * renderingFontScaleFactor), xpos, ypos, hAlign, vAlign, vpx, vpy, cacheable);
|
||||
}
|
||||
|
||||
|
@ -68,20 +68,26 @@ private:
|
||||
int index;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class GLFont {
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
enum Align {
|
||||
GLFONT_ALIGN_LEFT, GLFONT_ALIGN_RIGHT, GLFONT_ALIGN_CENTER, GLFONT_ALIGN_TOP, GLFONT_ALIGN_BOTTOM
|
||||
};
|
||||
enum GLFontSize {
|
||||
GLFONT_SIZE12,
|
||||
GLFONT_SIZE16,
|
||||
GLFONT_SIZE12,
|
||||
GLFONT_SIZE16,
|
||||
GLFONT_SIZE18,
|
||||
GLFONT_SIZE24,
|
||||
GLFONT_SIZE24,
|
||||
GLFONT_SIZE27, //new
|
||||
GLFONT_SIZE32,
|
||||
GLFONT_SIZE32,
|
||||
GLFONT_SIZE36, //new
|
||||
GLFONT_SIZE48,
|
||||
GLFONT_SIZE48,
|
||||
GLFONT_SIZE64, //new
|
||||
GLFONT_SIZE72, //new
|
||||
GLFONT_SIZE96, //new
|
||||
@ -98,13 +104,7 @@ public:
|
||||
GLFont(GLFontSize size, std::wstring fontFileName);
|
||||
~GLFont();
|
||||
|
||||
//The User request a font to display, but internally
|
||||
//it will be translated to another font depending of the scale level
|
||||
static GLFont& getFont(GLFontSize esize);
|
||||
|
||||
//Return the requested raw font, without applying scaling.
|
||||
static GLFont &GLFont::getRawFont(GLFontSize esize);
|
||||
|
||||
|
||||
//Called to change the scale of the rendered fonts
|
||||
static void setScale(GLFontScale scale);
|
||||
|
||||
@ -113,14 +113,9 @@ public:
|
||||
//Mean current scale factor: 1.0 in normal, 1.5 medium, 2.0 for large
|
||||
static double getScaleFactor();
|
||||
|
||||
//Public drawing font, 16 bit char version.
|
||||
void drawString(const std::wstring& str, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx=0, int vpy=0, bool cacheable = false);
|
||||
|
||||
//Public drawing font, 8 bit char version.
|
||||
void drawString(const std::string& str, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
std::wstring nextParam(std::wistringstream &str);
|
||||
std::wstring getParamKey(const std::wstring& param_str);
|
||||
std::wstring getParamValue(const std::wstring& param_str);
|
||||
@ -128,17 +123,17 @@ private:
|
||||
//Repository of all loaded fonts
|
||||
static GLFont fonts[GLFontSize::GLFONT_SIZE_MAX];
|
||||
|
||||
//Map of user requested font to internal font, which changes
|
||||
//changes with the requested scale.
|
||||
// this is rebuilt by the user calling setScale(GLFontScale) and changed atomically,
|
||||
//which map a user-requested font to a final one depending of the zoom level.
|
||||
static GLFontSize userFontZoomMapping[GLFontSize::GLFONT_SIZE_MAX];
|
||||
|
||||
static std::atomic<GLFontScale> currentScale;
|
||||
|
||||
//load a given font file, (lazy loading)
|
||||
void loadFontOnce();
|
||||
|
||||
//private drawing font, 16 bit char version, called by Drawer object
|
||||
void drawString(const std::wstring& str, int pxHeight, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false);
|
||||
|
||||
//private drawing font, 8 bit char version, called by Drawer object
|
||||
void drawString(const std::string& str, int pxHeight, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false);
|
||||
|
||||
GLFontStringCache *cacheString(const std::wstring& str, int pxHeight, int vpx, int vpy);
|
||||
void drawCacheString(GLFontStringCache *fc, float xpos, float ypos, Align hAlign, Align vAlign);
|
||||
|
||||
@ -147,7 +142,7 @@ private:
|
||||
|
||||
//force GC of all available fonts
|
||||
static void clearAllCaches();
|
||||
|
||||
|
||||
float getStringWidth(const std::wstring& str, float size, float viewAspect);
|
||||
|
||||
//the string cache is per-front (internal font)
|
||||
@ -171,5 +166,33 @@ private:
|
||||
int gcCounter;
|
||||
std::mutex cache_busy;
|
||||
|
||||
static std::mutex g_userFontZoomMappingMutex;
|
||||
public:
|
||||
|
||||
//Proxy class computing and caching the selection of the underlying fonts
|
||||
//depending of the user input and requested scale for the fonts.
|
||||
class Drawer {
|
||||
|
||||
private:
|
||||
|
||||
//result of the computation
|
||||
int renderingFontIndex = 0;
|
||||
|
||||
double renderingFontScaleFactor = 1.0;
|
||||
|
||||
public:
|
||||
|
||||
Drawer(int basicFontSize, double scaleFactor);
|
||||
|
||||
//Public drawing font, 16 bit char version.
|
||||
void drawString(const std::wstring& str, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false);
|
||||
|
||||
//Public drawing font, 8 bit char version.
|
||||
void drawString(const std::string& str, float xpos, float ypos, Align hAlign = GLFONT_ALIGN_LEFT, Align vAlign = GLFONT_ALIGN_TOP, int vpx = 0, int vpy = 0, bool cacheable = false);
|
||||
|
||||
}; //end class Drawer
|
||||
|
||||
//The User request a font of size requestedSize to display, with an additional
|
||||
//optional scale factor scaleFactor.
|
||||
static GLFont::Drawer getFont(int requestedSize, double scaleFactor = 1.0);
|
||||
|
||||
};
|
||||
|
@ -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() {
|
||||
|
@ -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,
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user