From 2c062da55a77bdb5284d0751a54e2d1309c9c9c4 Mon Sep 17 00:00:00 2001 From: Seigo Nonaka Date: Thu, 5 Oct 2023 16:43:08 +0900 Subject: Add NoBreakSpan that prevent line break the portion of text Bug: 283193586 Test: minikin_tests Test: atest StaticLayoutLineBreakingNoBreakSpanTest Change-Id: I9acd108537b73673316d0c126fff99a48a11f4ed --- .../java/android/graphics/text/LineBreakConfig.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'graphics/java/android') diff --git a/graphics/java/android/graphics/text/LineBreakConfig.java b/graphics/java/android/graphics/text/LineBreakConfig.java index e81525fb7d60..f5e5803d4796 100644 --- a/graphics/java/android/graphics/text/LineBreakConfig.java +++ b/graphics/java/android/graphics/text/LineBreakConfig.java @@ -134,10 +134,25 @@ public final class LineBreakConfig { */ public static final int LINE_BREAK_STYLE_STRICT = 3; + /** + * The line break style that used for preventing automatic line breaking. + * + * This is useful when you want to preserve some words in the same line by using + * {@link android.text.style.LineBreakConfigSpan} or + * {@link android.text.style.LineBreakConfigSpan.NoBreakSpan} as a shorthand. + * Note that even if this style is specified, the grapheme based line break is still performed + * for preventing clipping text. + * + * @see android.text.style.LineBreakConfigSpan + * @see android.text.style.LineBreakConfigSpan.NoBreakSpan + */ + @FlaggedApi(FLAG_NO_BREAK_NO_HYPHENATION_SPAN) + public static final int LINE_BREAK_STYLE_NO_BREAK = 4; + /** @hide */ @IntDef(prefix = { "LINE_BREAK_STYLE_" }, value = { LINE_BREAK_STYLE_NONE, LINE_BREAK_STYLE_LOOSE, LINE_BREAK_STYLE_NORMAL, - LINE_BREAK_STYLE_STRICT, LINE_BREAK_STYLE_UNSPECIFIED + LINE_BREAK_STYLE_STRICT, LINE_BREAK_STYLE_UNSPECIFIED, LINE_BREAK_STYLE_NO_BREAK }) @Retention(RetentionPolicy.SOURCE) public @interface LineBreakStyle {} -- cgit v1.2.3-59-g8ed1b