# HG changeset patch # User Carl Byington # Date 1405459042 25200 # Node ID edf4dacea9ff0f11774e4e41a4bc9e19a2a704a3 # Parent c3c11114885d0719bb196f610974deb32d0bfad5 allow both fixed rows/columns and specified font size diff -r c3c11114885d -r edf4dacea9ff src/com/five_ten_sg/connectbot/service/TerminalBridge.java --- 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) {