blob: b150b6ea992f59cbf96ae01f06431e5d04ca4373 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.text;
18
19/**
20 * AndroidCharacter exposes some character properties that are not
21 * easily accessed from java.lang.Character.
22 */
23public class AndroidCharacter
24{
Kenny Rootbb9a5172010-02-13 00:07:38 -080025 public static final int EAST_ASIAN_WIDTH_NEUTRAL = 0;
26 public static final int EAST_ASIAN_WIDTH_AMBIGUOUS = 1;
27 public static final int EAST_ASIAN_WIDTH_HALF_WIDTH = 2;
28 public static final int EAST_ASIAN_WIDTH_FULL_WIDTH = 3;
29 public static final int EAST_ASIAN_WIDTH_NARROW = 4;
30 public static final int EAST_ASIAN_WIDTH_WIDE = 5;
31
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032 /**
33 * Fill in the first <code>count</code> bytes of <code>dest</code> with the
34 * directionalities from the first <code>count</code> chars of <code>src</code>.
35 * This is just like Character.getDirectionality() except it is a
36 * batch operation.
37 */
38 public native static void getDirectionalities(char[] src, byte[] dest,
39 int count);
Kenny Rootbb9a5172010-02-13 00:07:38 -080040
41 /**
42 * Calculate the East Asian Width of a character according to
43 * <a href="http://unicode.org/reports/tr11/">Unicode TR#11</a>. The return
44 * will be one of {@link #EAST_ASIAN_WIDTH_NEUTRAL},
45 * {@link #EAST_ASIAN_WIDTH_AMBIGUOUS}, {@link #EAST_ASIAN_WIDTH_HALF_WIDTH},
46 * {@link #EAST_ASIAN_WIDTH_FULL_WIDTH}, {@link #EAST_ASIAN_WIDTH_NARROW},
47 * or {@link #EAST_ASIAN_WIDTH_WIDE}.
48 *
49 * @param input the character to measure
50 * @return the East Asian Width for input
51 */
52 public native static int getEastAsianWidth(char input);
53
54 /**
55 * Fill the first <code>count</code> bytes of <code>dest</code> with the
Kenny Root18b221a2010-05-27 06:41:59 -070056 * East Asian Width from <code>count</code> chars of <code>src</code>
57 * starting at <code>start</code>. East Asian Width is calculated based on
Kenny Rootbb9a5172010-02-13 00:07:38 -080058 * <a href="http://unicode.org/reports/tr11/">Unicode TR#11</a>. Each entry
Kenny Root18b221a2010-05-27 06:41:59 -070059 * in <code>dest</code> will be one of {@link #EAST_ASIAN_WIDTH_NEUTRAL},
Kenny Rootbb9a5172010-02-13 00:07:38 -080060 * {@link #EAST_ASIAN_WIDTH_AMBIGUOUS}, {@link #EAST_ASIAN_WIDTH_HALF_WIDTH},
61 * {@link #EAST_ASIAN_WIDTH_FULL_WIDTH}, {@link #EAST_ASIAN_WIDTH_NARROW},
62 * or {@link #EAST_ASIAN_WIDTH_WIDE}.
63 *
64 * @param src character array of input to measure
65 * @param start first character in array to measure
66 * @param count maximum number of characters to measure
67 * @param dest byte array of results for each character in src
68 */
69 public native static void getEastAsianWidths(char[] src, int start,
70 int count, byte[] dest);
71
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072 /**
73 * Replace the specified slice of <code>text</code> with the chars'
74 * right-to-left mirrors (if any), returning true if any
75 * replacements were made.
Kenny Root073a3d52010-02-17 08:25:47 -080076 *
77 * @param text array of characters to apply mirror operation
78 * @param start first character in array to mirror
79 * @param count maximum number of characters to mirror
80 * @return true if replacements were made
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081 */
82 public native static boolean mirror(char[] text, int start, int count);
83
84 /**
85 * Return the right-to-left mirror (or the original char if none)
86 * of the specified char.
87 */
88 public native static char getMirror(char ch);
89}