From 078b44c59e22fa6b14548dcdd1dc5694a57cc1c7 Mon Sep 17 00:00:00 2001 From: Ryan Hansberry Date: Mon, 5 Oct 2015 17:07:24 -0700 Subject: Correctly match font size changes in bridge to TextView font size changes. --- app/src/main/java/org/connectbot/TerminalView.java | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/org/connectbot/TerminalView.java b/app/src/main/java/org/connectbot/TerminalView.java index 0c9ec54..0afa969 100644 --- a/app/src/main/java/org/connectbot/TerminalView.java +++ b/app/src/main/java/org/connectbot/TerminalView.java @@ -46,6 +46,7 @@ import android.os.AsyncTask; import android.os.Build; import android.support.v4.view.MotionEventCompat; import android.text.ClipboardManager; +import android.util.Log; import android.view.ActionMode; import android.view.GestureDetector; import android.view.InputDevice; @@ -421,7 +422,7 @@ public class TerminalView extends TextView implements FontSizeChangedListener { private void copyBufferToText() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { - // It is pointless to run this function because the textView is not selectable pre-Honeycomb. + // Do not run this function because the textView is not selectable pre-Honeycomb. return; } @@ -463,7 +464,27 @@ public class TerminalView extends TextView implements FontSizeChangedListener { public void onFontSizeChanged(float size) { scaleCursors(); setTextSize(size); - setLineSpacing(0.0f, 1.1f); // KLUDGE: doesnt work on certain font sizes + + int iterationGuard = 100; + int heightDifference = 100; + float lineSpacingMultiplier = 1.0f; + + while (Math.abs(heightDifference) > 0) { + if (heightDifference > 0) { + lineSpacingMultiplier += 0.01f; + } else { + lineSpacingMultiplier -= 0.01f; + } + + setLineSpacing(0.0f, lineSpacingMultiplier); + heightDifference = bridge.charHeight - getLineHeight(); + + iterationGuard--; + if (iterationGuard < 0) { + break; + } + } + copyBufferToText(); } -- cgit v1.2.3