MCPcopy Create free account
hub / github.com/NetHack/NetHack / SetupTextmapFont

Method SetupTextmapFont

win/Qt/qt_map.cpp:102–124  ·  view source on GitHub ↗

pick a font to use for text map; rogue level is always displayed as text

Source from the content-addressed store, hash-verified

100
101// pick a font to use for text map; rogue level is always displayed as text
102void NetHackQtMapViewport::SetupTextmapFont(QPainter &painter)
103{
104 QString fontfamily = iflags.wc_font_map ? iflags.wc_font_map
105 : "Monospace";
106 int maybebold = QFont::Normal;
107 if (fontfamily.right(5).toLower() == "-bold") {
108 fontfamily.truncate(fontfamily.length() - 5);
109 maybebold = QFont::Bold;
110 }
111 // Find font...
112 int pts = 5;
113 while (pts < 32) {
114 QFont f(fontfamily, pts, maybebold);
115 painter.setFont(QFont(fontfamily, pts));
116 QFontMetrics fm = painter.fontMetrics();
117 if (fm.QFM_WIDTH("M") > qt_settings->glyphs().width())
118 break;
119 if (fm.height() > qt_settings->glyphs().height())
120 break;
121 pts++;
122 }
123 rogue_font = new QFont(fontfamily, pts - 1);
124}
125
126void NetHackQtMapViewport::paintEvent(QPaintEvent* event)
127{

Callers

nothing calls this directly

Calls 3

setFontMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45

Tested by

no test coverage detected