1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
Description: Fix GUI font size for high-DPI displays
Author: Anton Gladky <gladk@debian.org>
Last-Update: 2025-10-14
Index: sumo-1_24_0/src/utils/gui/div/GLHelper.cpp
===================================================================
--- sumo-1_24_0.orig/src/utils/gui/div/GLHelper.cpp
+++ sumo-1_24_0/src/utils/gui/div/GLHelper.cpp
@@ -22,12 +22,16 @@
#include <config.h>
#include <cassert>
+#include <algorithm>
+#include <iostream>
+#include <fstream>
#include <utils/geom/GeomHelper.h>
#include <utils/common/StdDefs.h>
#include <utils/common/MsgHandler.h>
#include <utils/common/ToString.h>
#include <utils/options/OptionsCont.h>
#include <utils/gui/div/GUIGeometry.h>
+#include <utils/foxtools/fxheader.h>
#define FONTSTASH_IMPLEMENTATION // Expands implementation
#ifdef _MSC_VER
#pragma warning(disable: 4505 5219) // do not warn about unused functions and implicit float conversions
@@ -66,7 +70,7 @@ int GLHelper::myNameCounter = 0;
std::vector<std::pair<double, double> > GLHelper::myCircleCoords;
std::vector<RGBColor> GLHelper::myDottedcontourColors;
FONScontext* GLHelper::myFont = nullptr;
-double GLHelper::myFontSize = 50.0;
+double GLHelper::myFontSize = 25.0;
bool GLHelper::myGL2PSActive = false;
void CALLBACK combCallback(GLdouble coords[3],
@@ -707,6 +711,7 @@ GLHelper::drawSpaceOccupancies(const dou
bool
GLHelper::initFont() {
if (myFont == nullptr) {
+ myFontSize = 25.0;
myFont = glfonsCreate(2048, 2048, FONS_ZERO_BOTTOMLEFT);
if (myFont != nullptr) {
const int fontNormal = fonsAddFontMem(myFont, "medium", data_font_Roboto_Medium_ttf, data_font_Roboto_Medium_ttf_len, 0);
@@ -760,7 +765,7 @@ GLHelper::drawText(const std::string& te
}
#endif
glTranslated(pos.x(), pos.y(), layer);
- glScaled(width / myFontSize, size / myFontSize, 1.);
+ glScaled(width / myFontSize * 2.0, size / myFontSize * 2.0, 1.);
glRotated(-angle, 0, 0, 1);
fonsSetAlign(myFont, align == 0 ? FONS_ALIGN_CENTER | FONS_ALIGN_MIDDLE : align);
fonsSetColor(myFont, glfonsRGBA(col.red(), col.green(), col.blue(), col.alpha()));
Index: sumo-1_24_0/src/guisim_main.cpp
===================================================================
--- sumo-1_24_0.orig/src/guisim_main.cpp
+++ sumo-1_24_0/src/guisim_main.cpp
@@ -76,6 +76,15 @@ main(int argc, char** argv) {
FXApp application("SUMO GUI", "sumo-gui");
// Open display
application.init(argc, argv);
+
+ // Increase application font size for menus/UI
+ FXFont* normalFont = application.getNormalFont();
+ FXFontDesc fdesc;
+ normalFont->getFontDesc(fdesc);
+ fdesc.size = (int)(fdesc.size * 1.5);
+ FXFont* bigFont = new FXFont(&application, fdesc);
+ bigFont->create();
+ application.setNormalFont(bigFont);
int minor, major;
if (!FXGLVisual::supported(&application, major, minor)) {
throw ProcessError(TL("This system has no OpenGL support. Exiting."));
|