Mercurial > 510Connectbot
diff src/com/five_ten_sg/connectbot/service/TerminalBridge.java @ 260:edf4dacea9ff
allow both fixed rows/columns and specified font size
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 15 Jul 2014 14:17:22 -0700 |
parents | e13878bb3ddf |
children | 79e6adde6fde |
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/service/TerminalBridge.java Mon Jul 14 14:39:36 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/service/TerminalBridge.java Tue Jul 15 14:17:22 2014 -0700 @@ -750,37 +750,40 @@ float step = 8.0f; float limit = 0.125f; int direction; + boolean fixed = true; - while ((direction = fontSizeCompare(size, cols, rows, width, height)) < 0) - size += step; + if (!fixed) { + while ((direction = fontSizeCompare(size, cols, rows, width, height)) < 0) + size += step; - if (direction == 0) { - Log.d("fontsize", String.format("Found match at %f", size)); - return; - } + if (direction == 0) { + Log.d("fontsize", String.format("Found match at %f", size)); + return; + } - step /= 2.0f; - size -= step; + step /= 2.0f; + size -= step; - while ((direction = fontSizeCompare(size, cols, rows, width, height)) != 0 - && step >= limit) { - step /= 2.0f; + while ((direction = fontSizeCompare(size, cols, rows, width, height)) != 0 + && step >= limit) { + step /= 2.0f; - if (direction > 0) { - size -= step; + if (direction > 0) { + size -= step; + } + else { + size += step; + } } - else { - size += step; - } + + if (direction > 0) size -= step; } - if (direction > 0) - size -= step; - this.columns = cols; this.rows = rows; forcedSize = true; - setFontSize(size); + if (fixed) setFontSize(host.getFontSize()); + else setFontSize(size); } private int fontSizeCompare(float size, int cols, int rows, int width, int height) {