1 /* 2 * Copyright 2019 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 17 package androidx.compose.ui.text.style 18 19 /** 20 * Defines the algorithm to be used while determining the text direction. 21 * 22 * @see ResolvedTextDirection 23 */ 24 @kotlin.jvm.JvmInline 25 value class TextDirection internal constructor(internal val value: Int) { 26 toStringnull27 override fun toString(): String { 28 return when (this) { 29 Ltr -> "Ltr" 30 Rtl -> "Rtl" 31 Content -> "Content" 32 ContentOrLtr -> "ContentOrLtr" 33 ContentOrRtl -> "ContentOrRtl" 34 Unspecified -> "Unspecified" 35 else -> "Invalid" 36 } 37 } 38 39 companion object { 40 /** Always sets the text direction to be Left to Right. */ 41 val Ltr = TextDirection(1) 42 43 /** Always sets the text direction to be Right to Left. */ 44 val Rtl = TextDirection(2) 45 46 /** 47 * This value indicates that the text direction depends on the first strong directional 48 * character in the text according to the Unicode Bidirectional Algorithm. If no strong 49 * directional character is present, then [androidx.compose.ui.unit.LayoutDirection] is used 50 * to resolve the final TextDirection. 51 * * if used while creating a Paragraph object, [androidx.compose.ui.text.intl.LocaleList] 52 * will be used to resolve the direction as a fallback instead of 53 * [androidx.compose.ui.unit.LayoutDirection]. 54 */ 55 val Content = TextDirection(3) 56 57 /** 58 * This value indicates that the text direction depends on the first strong directional 59 * character in the text according to the Unicode Bidirectional Algorithm. If no strong 60 * directional character is present, then Left to Right will be used as the default 61 * direction. 62 */ 63 val ContentOrLtr = TextDirection(4) 64 65 /** 66 * This value indicates that the text direction depends on the first strong directional 67 * character in the text according to the Unicode Bidirectional Algorithm. If no strong 68 * directional character is present, then Right to Left will be used as the default 69 * direction. 70 */ 71 val ContentOrRtl = TextDirection(5) 72 73 /** 74 * This represents an unset value, a usual replacement for "null" when a primitive value is 75 * desired. 76 */ 77 val Unspecified = TextDirection(Int.MIN_VALUE) 78 } 79 } 80