From e67f0c9712890f3af19d1213ff4c4b049c401226 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 28 Sep 2009 17:33:54 -0700 Subject: [PATCH] Hack to fix issue #2125365: Sports Trivia compatability with Eclair (do not merge) Adds a mechanism to tell Paint the scaling factor its target canvas will have, for it to compute font metrics based on the correct font size. Only TextView uses this, but that is enough for the large majority of apps. This is integrated from the Eclair branch. --- api/current.xml | 10 +- core/java/android/widget/TextView.java | 5 + core/jni/android/graphics/Paint.cpp | 10 +- graphics/java/android/graphics/Paint.java | 126 +++++++++++++++++++--- 4 files changed, 129 insertions(+), 22 deletions(-) diff --git a/api/current.xml b/api/current.xml index fc54859f73692..e79bd7e74a0aa 100644 --- a/api/current.xml +++ b/api/current.xml @@ -51157,7 +51157,7 @@ widths.length) { throw new ArrayIndexOutOfBoundsException(); } - return native_getTextWidths(mNativePaint, text, index, count, widths); + + if (!mHasCompatScaling) { + return native_getTextWidths(mNativePaint, text, index, count, widths); + } + final float oldSize = getTextSize(); + setTextSize(oldSize*mCompatScaling); + int res = native_getTextWidths(mNativePaint, text, index, count, widths); + setTextSize(oldSize); + for (int i=0; i widths.length) { throw new ArrayIndexOutOfBoundsException(); } - return native_getTextWidths(mNativePaint, text, start, end, widths); + + if (!mHasCompatScaling) { + return native_getTextWidths(mNativePaint, text, start, end, widths); + } + final float oldSize = getTextSize(); + setTextSize(oldSize*mCompatScaling); + int res = native_getTextWidths(mNativePaint, text, start, end, widths); + setTextSize(oldSize); + for (int i=0; i