diff --git a/game/Start.Paint.cpp b/game/Start.Paint.cpp index 46f9ef3..03cc443 100644 --- a/game/Start.Paint.cpp +++ b/game/Start.Paint.cpp @@ -71,6 +71,25 @@ void copyBlock(Dpi::Canvas &dst, int x, int y, int w, int h, Dpi::Canvas &src, i dst.copyRect(QRect(x, y, w, h), src, QRect(xSrc, ySrc, w, h)); } +// TabSize (like several other layout constants here) is a fixed pixel +// width inherited from the original Windows build, sized for English +// text - longer translations (e.g. French "Nouveau livre") can overflow +// it and overlap the neighboring tab. Shrink the font just for this one +// label, rather than changing the fixed tab layout, so every language +// still fits without touching unrelated pixel-perfect positioning. +void risedTextOutFitted(Dpi::Canvas &canvas, int x, int y, int maxWidth, const QString &text) +{ + constexpr int MinPixelSize = 8; + const Dpi::Font original = canvas.font(); + int pixelSize = original.toQFont().pixelSize(); + while (pixelSize > MinPixelSize && biColorTextWidth(canvas, text) > maxWidth) { + --pixelSize; + canvas.font().setHeight(pixelSize); + } + risedTextOut(canvas, x + (maxWidth - biColorTextWidth(canvas, text)) / 2, y, text); + canvas.font().assign(original); +} + } // namespace void StartDlg::drawAction(int y, int iconIndex, const QString &headerItem, const QString &textItem) @@ -146,8 +165,7 @@ void StartDlg::offscreenPaint() canvas.font().assign(UniFont[static_cast(FontType::Normal)]); for (int tab2 = static_cast(Tab::Map); tab2 <= static_cast(Tab::PreviousGame); ++tab2) { const QString s = startControl(tabNames[tab2]); - risedTextOut(canvas, TabOffset + tab2 * TabSize + 1 + (TabSize - biColorTextWidth(canvas, s)) / 2, - 10 + 2 * (tabIndex != tab2 ? 1 : 0), s); + risedTextOutFitted(canvas, TabOffset + tab2 * TabSize + 1, 10 + 2 * (tabIndex != tab2 ? 1 : 0), TabSize, s); } frame(canvas, TabOffset + 4 * TabSize + 1, -1, clientWidth, TabHeight, Qt::black, Qt::black); frame(canvas, 1, TabHeight + 1, clientWidth - 2, clientHeight - 2, light, shade);