Mercurial > 510Connectbot
diff src/com/five_ten_sg/connectbot/service/TerminalBridge.java @ 188:cf677a6f586d
use floating point font size, change size by scaling factor rather than linear addition
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 02 Jul 2014 16:10:20 -0700 |
parents | 47412afe78dd |
children | ab6f64d1a24a |
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalBridge.java Wed Jul 02 15:40:18 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalBridge.java Wed Jul 02 16:10:20 2014 -0700 @@ -78,8 +78,8 @@ public class TerminalBridge implements VDUDisplay { public final static String TAG = "ConnectBot.TerminalBridge"; - public final static int DEFAULT_FONT_SIZE = 10; - private final static int FONT_SIZE_STEP = 2; + public final static float DEFAULT_FONT_SIZE = 10.0; + private final static float FONT_SIZE_FACTOR = 1.1; public Integer[] color; @@ -189,11 +189,12 @@ defaultPaint.setFakeBoldText(true); // more readable? localOutput = new LinkedList<String>(); fontSizeChangedListeners = new LinkedList<FontSizeChangedListener>(); - Integer defaultFontSize = Integer.parseInt(manager.prefs.getString(PreferenceConstants.DEFAULT_FONT_SIZE, "-1")); + float defaultFontSize = Float.parseFloat(manager.prefs.getString(PreferenceConstants.DEFAULT_FONT_SIZE, "-1")); Log.i(TAG, "fontSize: " + this.fontSize + ", defaultFontSize: " + defaultFontSize); - if (fontSize == -1) { - if (defaultFontSize > 0 && host.getFontSize() == -1) + float hostFontSize; + if (fontSize <= 0) { + if ((defaultFontSize > 0) && (host.getFontSize() <= 0)) hostFontSize = defaultFontSize; else hostFontSize = host.getFontSize(); @@ -468,7 +469,7 @@ for (FontSizeChangedListener ofscl : fontSizeChangedListeners) ofscl.onFontSizeChanged(size); - host.setFontSize((int) fontSize); + host.setFontSize(fontSize); manager.hostdb.updateFontSize(host); } @@ -993,14 +994,14 @@ * */ public void increaseFontSize() { - setFontSize(fontSize + FONT_SIZE_STEP); + setFontSize(fontSize * FONT_SIZE_FACTOR); } /** * */ public void decreaseFontSize() { - setFontSize(fontSize - FONT_SIZE_STEP); + setFontSize(fontSize / FONT_SIZE_FACTOR); } /** @@ -1008,9 +1009,9 @@ */ public void resetSize(TerminalView parent) { this.forcedSize = false; - Integer defaultFontSize = Integer.parseInt(manager.prefs.getString(PreferenceConstants.DEFAULT_FONT_SIZE, "-1")); + float defaultFontSize = Float.parseFloat(manager.prefs.getString(PreferenceConstants.DEFAULT_FONT_SIZE, "-1")); - if (this.fontSize != -1 && defaultFontSize > 0) + if (defaultFontSize > 0) setFontSize(defaultFontSize); else setFontSize(DEFAULT_FONT_SIZE);