Package icyllis.modernui.graphics.text
Class GraphemeBreak
java.lang.Object
icyllis.modernui.graphics.text.GraphemeBreak
This class handles grapheme cluster break.
It is important to recognize that what the user thinks of as a "character"-a basic unit of a writing system for a language- may not be just a single Unicode code point. Instead, that basic unit may be made up of multiple Unicode code points. To avoid ambiguity with the computer use of the term character, this is called a user-perceived character. For example, "G" + grave-accent is a user-perceived character: users think of it as a single character, yet is actually represented by two Unicode code points. These user-perceived characters are approximated by what is called a grapheme cluster, which can be determined programmatically.
Note: this class is not completed, use ICU instead.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Compute the valid cursor after offset or the limit of the context, whichever is less.static final int
Return offset if the cursor at offset is valid, or -1 if it isn't.static final int
Compute the valid cursor at or after the offset or the limit of the context, whichever is less.static final int
Compute the valid cursor at or before offset or the start of the context, whichever is greater.static final int
Compute the valid cursor before offset or the start of the context, whichever is greater.static boolean
Config value, true to use ICU GCB, otherwise this -
Method Summary
Modifier and TypeMethodDescriptionstatic void
forTextRun
(char[] text, Locale locale, int contextStart, int contextEnd, GraphemeBreak.ClusterConsumer consumer) static int
getTextRunCursor
(String text, Locale locale, int contextStart, int contextEnd, int offset, int op) static int
getTextRunCursorICU
(CharacterIterator text, Locale locale, int offset, int op) static int
getTextRunCursorImpl
(float[] advances, char[] buf, int start, int count, int offset, int op) static boolean
isGraphemeBreak
(float[] advances, char[] buf, int start, int count, int offset) static boolean
isPureKiller
(int c) static int
tailoredGraphemeClusterBreak
(int c)
-
Field Details
-
AFTER
public static final int AFTERCompute the valid cursor after offset or the limit of the context, whichever is less.- See Also:
-
AT_OR_AFTER
public static final int AT_OR_AFTERCompute the valid cursor at or after the offset or the limit of the context, whichever is less.- See Also:
-
BEFORE
public static final int BEFORECompute the valid cursor before offset or the start of the context, whichever is greater.- See Also:
-
AT_OR_BEFORE
public static final int AT_OR_BEFORECompute the valid cursor at or before offset or the start of the context, whichever is greater.- See Also:
-
AT
public static final int ATReturn offset if the cursor at offset is valid, or -1 if it isn't.- See Also:
-
sUseICU
public static boolean sUseICUConfig value, true to use ICU GCB, otherwise this
-
-
Method Details
-
getTextRunCursor
-
forTextRun
public static void forTextRun(@Nonnull char[] text, @Nonnull Locale locale, int contextStart, int contextEnd, @Nonnull GraphemeBreak.ClusterConsumer consumer) -
getTextRunCursorICU
-
getTextRunCursorImpl
public static int getTextRunCursorImpl(@Nullable float[] advances, @Nonnull char[] buf, int start, int count, int offset, int op) -
isGraphemeBreak
public static boolean isGraphemeBreak(@Nullable float[] advances, @Nonnull char[] buf, int start, int count, int offset) -
isPureKiller
public static boolean isPureKiller(int c) -
tailoredGraphemeClusterBreak
public static int tailoredGraphemeClusterBreak(int c)
-