Loading core/java/android/text/Layout.java +29 −18 Original line number Diff line number Diff line Loading @@ -530,32 +530,42 @@ public abstract class Layout { */ public abstract int getBottomPadding(); // return the level of the character at offset. // XXX remove if not needed private int getRunLevelAtOffset(int offset) { /** * Returns true if the character at offset and the preceding character * are at different run levels (and thus there's a split caret). * @param offset the offset * @return true if at a level boundary */ private boolean isLevelBoundary(int offset) { int line = getLineForOffset(offset); int lineStart = getLineStart(line); int lineEnd = getLineVisibleEnd(line); int[] runs = getLineDirections(line).mDirections; for (int i = 0; i < runs.length; i += 2) { int start = runs[i]; if (offset >= start) { int limit = start + (runs[i+1] & RUN_LENGTH_MASK); if (limit > lineEnd) { limit = lineEnd; Directions dirs = getLineDirections(line); if (dirs == DIRS_ALL_LEFT_TO_RIGHT || dirs == DIRS_ALL_RIGHT_TO_LEFT) { return false; } if (offset < limit) { return (runs[i+1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK; int[] runs = dirs.mDirections; int lineStart = getLineStart(line); int lineEnd = getLineEnd(line); if (offset == lineStart || offset == lineEnd) { int paraLevel = getParagraphDirection(line) == 1 ? 0 : 1; int runIndex = offset == lineStart ? 0 : runs.length - 2; return ((runs[runIndex + 1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK) != paraLevel; } offset -= lineStart; for (int i = 0; i < runs.length; i += 2) { if (offset == runs[i]) { return true; } } return getParagraphDirection(line) == 1 ? 0 : 1; return false; } private boolean primaryIsTrailingPrevious(int offset) { int line = getLineForOffset(offset); int lineStart = getLineStart(line); int lineEnd = getLineVisibleEnd(line); int lineEnd = getLineEnd(line); int[] runs = getLineDirections(line).mDirections; int levelAt = -1; Loading Loading @@ -1161,7 +1171,7 @@ public abstract class Layout { /** * Fills in the specified Path with a representation of a cursor * at the specified offset. This will often be a vertical line * but can be multiple discontinous lines in text with multiple * but can be multiple discontinuous lines in text with multiple * directionalities. */ public void getCursorPath(int point, Path dest, Loading @@ -1173,7 +1183,8 @@ public abstract class Layout { int bottom = getLineTop(line+1); float h1 = getPrimaryHorizontal(point) - 0.5f; float h2 = getSecondaryHorizontal(point) - 0.5f; float h2 = isLevelBoundary(point) ? getSecondaryHorizontal(point) - 0.5f : h1; int caps = TextKeyListener.getMetaState(editingBuffer, KeyEvent.META_SHIFT_ON) | Loading core/java/android/text/StaticLayout.java +20 −18 Original line number Diff line number Diff line Loading @@ -16,14 +16,15 @@ package android.text; import com.android.internal.util.ArrayUtils; import android.graphics.Bitmap; import android.graphics.Paint; import com.android.internal.util.ArrayUtils; import android.util.Log; import android.text.style.LeadingMarginSpan; import android.text.style.LineHeightSpan; import android.text.style.MetricAffectingSpan; import android.text.style.ReplacementSpan; import android.util.Log; /** * StaticLayout is a Layout for text that will not be edited after it Loading @@ -31,7 +32,8 @@ import android.text.style.ReplacementSpan; * <p>This is used by widgets to control text layout. You should not need * to use this class directly unless you are implementing your own widget * or custom display object, or would be tempted to call * {@link android.graphics.Canvas#drawText(java.lang.CharSequence, int, int, float, float, android.graphics.Paint) * {@link android.graphics.Canvas#drawText(java.lang.CharSequence, int, int, * float, float, android.graphics.Paint) * Canvas.drawText()} directly.</p> */ public class Loading Loading @@ -377,7 +379,7 @@ extends Layout whichPaint = mWorkPaint; } float wid = (float) bm.getWidth() * float wid = bm.getWidth() * -whichPaint.ascent() / bm.getHeight(); Loading Loading
core/java/android/text/Layout.java +29 −18 Original line number Diff line number Diff line Loading @@ -530,32 +530,42 @@ public abstract class Layout { */ public abstract int getBottomPadding(); // return the level of the character at offset. // XXX remove if not needed private int getRunLevelAtOffset(int offset) { /** * Returns true if the character at offset and the preceding character * are at different run levels (and thus there's a split caret). * @param offset the offset * @return true if at a level boundary */ private boolean isLevelBoundary(int offset) { int line = getLineForOffset(offset); int lineStart = getLineStart(line); int lineEnd = getLineVisibleEnd(line); int[] runs = getLineDirections(line).mDirections; for (int i = 0; i < runs.length; i += 2) { int start = runs[i]; if (offset >= start) { int limit = start + (runs[i+1] & RUN_LENGTH_MASK); if (limit > lineEnd) { limit = lineEnd; Directions dirs = getLineDirections(line); if (dirs == DIRS_ALL_LEFT_TO_RIGHT || dirs == DIRS_ALL_RIGHT_TO_LEFT) { return false; } if (offset < limit) { return (runs[i+1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK; int[] runs = dirs.mDirections; int lineStart = getLineStart(line); int lineEnd = getLineEnd(line); if (offset == lineStart || offset == lineEnd) { int paraLevel = getParagraphDirection(line) == 1 ? 0 : 1; int runIndex = offset == lineStart ? 0 : runs.length - 2; return ((runs[runIndex + 1] >>> RUN_LEVEL_SHIFT) & RUN_LEVEL_MASK) != paraLevel; } offset -= lineStart; for (int i = 0; i < runs.length; i += 2) { if (offset == runs[i]) { return true; } } return getParagraphDirection(line) == 1 ? 0 : 1; return false; } private boolean primaryIsTrailingPrevious(int offset) { int line = getLineForOffset(offset); int lineStart = getLineStart(line); int lineEnd = getLineVisibleEnd(line); int lineEnd = getLineEnd(line); int[] runs = getLineDirections(line).mDirections; int levelAt = -1; Loading Loading @@ -1161,7 +1171,7 @@ public abstract class Layout { /** * Fills in the specified Path with a representation of a cursor * at the specified offset. This will often be a vertical line * but can be multiple discontinous lines in text with multiple * but can be multiple discontinuous lines in text with multiple * directionalities. */ public void getCursorPath(int point, Path dest, Loading @@ -1173,7 +1183,8 @@ public abstract class Layout { int bottom = getLineTop(line+1); float h1 = getPrimaryHorizontal(point) - 0.5f; float h2 = getSecondaryHorizontal(point) - 0.5f; float h2 = isLevelBoundary(point) ? getSecondaryHorizontal(point) - 0.5f : h1; int caps = TextKeyListener.getMetaState(editingBuffer, KeyEvent.META_SHIFT_ON) | Loading
core/java/android/text/StaticLayout.java +20 −18 Original line number Diff line number Diff line Loading @@ -16,14 +16,15 @@ package android.text; import com.android.internal.util.ArrayUtils; import android.graphics.Bitmap; import android.graphics.Paint; import com.android.internal.util.ArrayUtils; import android.util.Log; import android.text.style.LeadingMarginSpan; import android.text.style.LineHeightSpan; import android.text.style.MetricAffectingSpan; import android.text.style.ReplacementSpan; import android.util.Log; /** * StaticLayout is a Layout for text that will not be edited after it Loading @@ -31,7 +32,8 @@ import android.text.style.ReplacementSpan; * <p>This is used by widgets to control text layout. You should not need * to use this class directly unless you are implementing your own widget * or custom display object, or would be tempted to call * {@link android.graphics.Canvas#drawText(java.lang.CharSequence, int, int, float, float, android.graphics.Paint) * {@link android.graphics.Canvas#drawText(java.lang.CharSequence, int, int, * float, float, android.graphics.Paint) * Canvas.drawText()} directly.</p> */ public class Loading Loading @@ -377,7 +379,7 @@ extends Layout whichPaint = mWorkPaint; } float wid = (float) bm.getWidth() * float wid = bm.getWidth() * -whichPaint.ascent() / bm.getHeight(); Loading