From 62b6eaa7f3a8111311a7ee097f278eb55865a499 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Tue, 17 Jan 2012 14:52:13 -0800 Subject: Fix text encoding when drawing with drawPosText in software Change-Id: I0cd8ee526189c38c50953a1a08b50e0b31c55d8c --- tests/HwAccelerationTest/AndroidManifest.xml | 10 ++++ tests/HwAccelerationTest/res/values/strings.xml | 19 +++++++ .../src/com/android/test/hwui/PosTextActivity.java | 66 ++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 tests/HwAccelerationTest/res/values/strings.xml create mode 100644 tests/HwAccelerationTest/src/com/android/test/hwui/PosTextActivity.java (limited to 'tests') diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index 929b103..6f97ff0 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -466,6 +466,16 @@ + + + + + + + diff --git a/tests/HwAccelerationTest/res/values/strings.xml b/tests/HwAccelerationTest/res/values/strings.xml new file mode 100644 index 0000000..69e58aa --- /dev/null +++ b/tests/HwAccelerationTest/res/values/strings.xml @@ -0,0 +1,19 @@ + + + + + "ตำแหน่งของตัวชี้" + diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/PosTextActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/PosTextActivity.java new file mode 100644 index 0000000..f0ff737 --- /dev/null +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/PosTextActivity.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2010 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.test.hwui; + +import android.app.Activity; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.os.Bundle; +import android.view.View; + +@SuppressWarnings({"UnusedDeclaration"}) +public class PosTextActivity extends Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(new CustomTextView(this)); + } + + static class CustomTextView extends View { + private final Paint mLargePaint; + private final String mText; + private final float[] mPos; + + CustomTextView(Context c) { + super(c); + + mText = c.getResources().getString(R.string.complex_string); + mPos = new float[mText.length() * 2]; + for (int i = 0; i < mPos.length; i += 2) { + mPos[i] = i * 30.0f; + mPos[i + 1] = i * 10.0f; + } + + mLargePaint = new Paint(); + mLargePaint.setAntiAlias(true); + mLargePaint.setTextSize(36.0f); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + canvas.drawRGB(255, 255, 255); + + canvas.save(); + canvas.translate(100.0f, 100.0f); + canvas.drawPosText(mText, mPos, mLargePaint); + canvas.restore(); + } + } +} -- cgit v1.1