pick a font to use for text map; rogue level is always displayed as text
| 100 | |
| 101 | // pick a font to use for text map; rogue level is always displayed as text |
| 102 | void 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 | |
| 126 | void NetHackQtMapViewport::paintEvent(QPaintEvent* event) |
| 127 | { |