Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

Hyphenator

public class Hyphenator
extends Object

java.lang.Object
   ↳ android.text.Hyphenator


Provides constants and pack/unpack methods for the HyphenEdit. Hyphenator provides constant values for start of line and end of line modification. For example, by passing END_HYPHEN_EDIT_INSERT_HYPHEN like as follows, HYPHEN(U+2010) character is appended at the end of line.

 
   Paint paint = new Paint();
   paint.setHyphenEdit(Hyphenator.packHyphenEdit(
       Hyphenator.START_HYPHEN_EDIT_NO_EDIT,
       Hyphenator.END_HYPHEN_EDIT_INSERT_HYPHEN));
   paint.measureText("abc", 0, 3);  // Returns the width of "abc‐"
   Canvas.drawText("abc", 0, 3, 0f, 0f, paint);  // Draws "abc‐"
 
 

Summary

Constants

int END_HYPHEN_EDIT_INSERT_ARMENIAN_HYPHEN

An integer representing the end of the line has Armentian hyphen (U+058A).

int END_HYPHEN_EDIT_INSERT_HYPHEN

An integer representing the end of the line has normal hyphen character (U+002D).

int END_HYPHEN_EDIT_INSERT_MAQAF

An integer representing the end of the line has maqaf (Hebrew hyphen, U+05BE).

int END_HYPHEN_EDIT_INSERT_UCAS_HYPHEN

An integer representing the end of the line has Canadian Syllabics hyphen (U+1400).

int END_HYPHEN_EDIT_INSERT_ZWJ_AND_HYPHEN

An integer representing the end of the line has Zero-Width-Joiner (U+200D) followed by normal hyphen character (U+002D).

int END_HYPHEN_EDIT_NO_EDIT

An integer representing the end of the line has no modification for hyphenation.

int END_HYPHEN_EDIT_REPLACE_WITH_HYPHEN

An integer representing the character at the end of the line is replaced with hyphen character (U+002D).

int START_HYPHEN_EDIT_INSERT_HYPHEN

An integer representing the starting of the line has normal hyphen character (U+002D).

int START_HYPHEN_EDIT_INSERT_ZWJ

An integer representing the starting of the line has Zero-Width-Joiner (U+200D).

int START_HYPHEN_EDIT_NO_EDIT

An integer representing the starting of the line has no modification for hyphenation.

Public methods

static int packHyphenEdit(int startHyphenEdit, int endHyphenEdit)

Pack the start hyphen edit and end hyphen edit into single integer.

static int unpackEndHyphenEdit(int hyphenEdit)

Extract end hyphen edit from packed value.

static int unpackStartHyphenEdit(int hyphenEdit)

Extract start hyphen edit from packed value.

Inherited methods

Constants

END_HYPHEN_EDIT_INSERT_ARMENIAN_HYPHEN

public static final int END_HYPHEN_EDIT_INSERT_ARMENIAN_HYPHEN

An integer representing the end of the line has Armentian hyphen (U+058A).

Constant Value: 3 (0x00000003)

END_HYPHEN_EDIT_INSERT_HYPHEN

public static final int END_HYPHEN_EDIT_INSERT_HYPHEN

An integer representing the end of the line has normal hyphen character (U+002D).

Constant Value: 2 (0x00000002)

END_HYPHEN_EDIT_INSERT_MAQAF

public static final int END_HYPHEN_EDIT_INSERT_MAQAF

An integer representing the end of the line has maqaf (Hebrew hyphen, U+05BE).

Constant Value: 4 (0x00000004)

END_HYPHEN_EDIT_INSERT_UCAS_HYPHEN

public static final int END_HYPHEN_EDIT_INSERT_UCAS_HYPHEN

An integer representing the end of the line has Canadian Syllabics hyphen (U+1400).

Constant Value: 5 (0x00000005)

END_HYPHEN_EDIT_INSERT_ZWJ_AND_HYPHEN

public static final int END_HYPHEN_EDIT_INSERT_ZWJ_AND_HYPHEN

An integer representing the end of the line has Zero-Width-Joiner (U+200D) followed by normal hyphen character (U+002D).

Constant Value: 6 (0x00000006)

END_HYPHEN_EDIT_NO_EDIT

public static final int END_HYPHEN_EDIT_NO_EDIT

An integer representing the end of the line has no modification for hyphenation.

Constant Value: 0 (0x00000000)

END_HYPHEN_EDIT_REPLACE_WITH_HYPHEN

public static final int END_HYPHEN_EDIT_REPLACE_WITH_HYPHEN

An integer representing the character at the end of the line is replaced with hyphen character (U+002D).

Constant Value: 1 (0x00000001)

START_HYPHEN_EDIT_INSERT_HYPHEN

public static final int START_HYPHEN_EDIT_INSERT_HYPHEN

An integer representing the starting of the line has normal hyphen character (U+002D).

Constant Value: 1 (0x00000001)

START_HYPHEN_EDIT_INSERT_ZWJ

public static final int START_HYPHEN_EDIT_INSERT_ZWJ

An integer representing the starting of the line has Zero-Width-Joiner (U+200D).

Constant Value: 2 (0x00000002)

START_HYPHEN_EDIT_NO_EDIT

public static final int START_HYPHEN_EDIT_NO_EDIT

An integer representing the starting of the line has no modification for hyphenation.

Constant Value: 0 (0x00000000)

Public methods

packHyphenEdit

public static int packHyphenEdit (int startHyphenEdit, 
                int endHyphenEdit)

Pack the start hyphen edit and end hyphen edit into single integer.

Parameters
startHyphenEdit int: Value is START_HYPHEN_EDIT_NO_EDIT, START_HYPHEN_EDIT_INSERT_HYPHEN, or START_HYPHEN_EDIT_INSERT_ZWJ

endHyphenEdit int: Value is END_HYPHEN_EDIT_NO_EDIT, END_HYPHEN_EDIT_REPLACE_WITH_HYPHEN, END_HYPHEN_EDIT_INSERT_HYPHEN, END_HYPHEN_EDIT_INSERT_ARMENIAN_HYPHEN, END_HYPHEN_EDIT_INSERT_MAQAF, END_HYPHEN_EDIT_INSERT_UCAS_HYPHEN, or END_HYPHEN_EDIT_INSERT_ZWJ_AND_HYPHEN

Returns
int

unpackEndHyphenEdit

public static int unpackEndHyphenEdit (int hyphenEdit)

Extract end hyphen edit from packed value.

Parameters
hyphenEdit int

Returns
int Value is END_HYPHEN_EDIT_NO_EDIT, END_HYPHEN_EDIT_REPLACE_WITH_HYPHEN, END_HYPHEN_EDIT_INSERT_HYPHEN, END_HYPHEN_EDIT_INSERT_ARMENIAN_HYPHEN, END_HYPHEN_EDIT_INSERT_MAQAF, END_HYPHEN_EDIT_INSERT_UCAS_HYPHEN, or END_HYPHEN_EDIT_INSERT_ZWJ_AND_HYPHEN

unpackStartHyphenEdit

public static int unpackStartHyphenEdit (int hyphenEdit)

Extract start hyphen edit from packed value.

Parameters
hyphenEdit int

Returns
int Value is START_HYPHEN_EDIT_NO_EDIT, START_HYPHEN_EDIT_INSERT_HYPHEN, or START_HYPHEN_EDIT_INSERT_ZWJ