X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2Fio%2FSwingScreen.java;h=3d0729e4feecd719b78431d93e1e54da46c9e30a;hb=55d2b2c2b29ce51f4f910448a115073371deeae8;hp=b7c8410993ce8647e23eacc8c5f8aad3545ece8f;hpb=f5a270d54562ae1205f31a9ea49d5aa17257851c;p=fanfix.git diff --git a/src/jexer/io/SwingScreen.java b/src/jexer/io/SwingScreen.java index b7c8410..3d0729e 100644 --- a/src/jexer/io/SwingScreen.java +++ b/src/jexer/io/SwingScreen.java @@ -165,6 +165,11 @@ public final class SwingScreen extends Screen { */ SwingScreen screen; + /** + * If true, we were successful getting Terminus. + */ + private boolean gotTerminus = false; + /** * Width of a character cell. */ @@ -329,8 +334,9 @@ public final class SwingScreen extends Screen { getContextClassLoader(); InputStream in = loader.getResourceAsStream(FONTFILE); Font terminusRoot = Font.createFont(Font.TRUETYPE_FONT, in); - Font terminus = terminusRoot.deriveFont(Font.PLAIN, 22); + Font terminus = terminusRoot.deriveFont(Font.PLAIN, 20); setFont(terminus); + gotTerminus = true; } catch (Exception e) { e.printStackTrace(); // setFont(new Font("Liberation Mono", Font.PLAIN, 24)); @@ -375,15 +381,24 @@ public final class SwingScreen extends Screen { Rectangle2D bounds = fm.getMaxCharBounds(gr); int leading = fm.getLeading(); textWidth = (int)Math.round(bounds.getWidth()); - textHeight = (int)Math.round(bounds.getHeight()) - maxDescent; - // This also produces the same number, but works better for ugly + // textHeight = (int)Math.round(bounds.getHeight()) - maxDescent; + + // This produces the same number, but works better for ugly // monospace. textHeight = fm.getMaxAscent() + maxDescent - leading; + if (gotTerminus == true) { + textHeight++; + } + if (System.getProperty("os.name").startsWith("Windows")) { textAdjustY = -1; textAdjustX = 0; } + if (System.getProperty("os.name").startsWith("Mac")) { + textAdjustY = -1; + textAdjustX = 0; + } } /** @@ -857,4 +872,13 @@ public final class SwingScreen extends Screen { return ((y - frame.top) / frame.textHeight); } + /** + * Set the window title. + * + * @param title the new title + */ + public void setTitle(final String title) { + frame.setTitle(title); + } + }