diff options
author | Romain Guy <romainguy@google.com> | 2013-02-26 19:10:14 -0800 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2013-02-27 15:49:57 -0800 |
commit | c74f45a334f0e3725c23cdd270cbcb0efac4ea75 (patch) | |
tree | 1b198e8b6b7d6d4a69237116a580236836744294 /tests/HwAccelerationTest/src | |
parent | d80806b305ce337283c24f14522cc58fea090b8c (diff) | |
download | frameworks_base-c74f45a334f0e3725c23cdd270cbcb0efac4ea75.zip frameworks_base-c74f45a334f0e3725c23cdd270cbcb0efac4ea75.tar.gz frameworks_base-c74f45a334f0e3725c23cdd270cbcb0efac4ea75.tar.bz2 |
Properly scale text
This change does not apply to drawPosText() and drawTextOnPath() yet.
Prior to this change, glyphs were always rasterized based on the
font size specified in the paint. All transforms were then applied
on the resulting texture. This creates rather ugly results when
text is scaled and/or rotated.
With this change, the font renderer will apply the current transform
matrix to the glyph before they are rasterized. This generates much
better looking results.
Change-Id: I0141b6ff18db35e1213e7a3ab9db1ecaf03d7a9c
Diffstat (limited to 'tests/HwAccelerationTest/src')
-rw-r--r-- | tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java index e1bf3ea..a4e9b52 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ScaledTextActivity.java @@ -54,6 +54,7 @@ public class ScaledTextActivity extends Activity { public ScaledTextView(Context c) { super(c); + setLayerType(LAYER_TYPE_HARDWARE, null); mPath = makePath(); @@ -92,11 +93,28 @@ public class ScaledTextActivity extends Activity { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); - canvas.drawARGB(255, 255, 255, 255); canvas.drawText(TEXT, 30.0f, 30.0f, mPaint); + mPaint.setTextAlign(Paint.Align.CENTER); + canvas.drawText(TEXT, 30.0f, 50.0f, mPaint); + mPaint.setTextAlign(Paint.Align.RIGHT); + canvas.drawText(TEXT, 30.0f, 70.0f, mPaint); - canvas.translate(0.0f, 50.0f); + canvas.save(); + canvas.translate(400.0f, 0.0f); + canvas.scale(3.0f, 3.0f); + mPaint.setTextAlign(Paint.Align.LEFT); + mPaint.setStrikeThruText(true); + canvas.drawText(TEXT, 30.0f, 30.0f, mPaint); + mPaint.setStrikeThruText(false); + mPaint.setTextAlign(Paint.Align.CENTER); + canvas.drawText(TEXT, 30.0f, 50.0f, mPaint); + mPaint.setTextAlign(Paint.Align.RIGHT); + canvas.drawText(TEXT, 30.0f, 70.0f, mPaint); + canvas.restore(); + + mPaint.setTextAlign(Paint.Align.LEFT); + canvas.translate(0.0f, 100.0f); canvas.save(); canvas.scale(mScale, mScale); |