Text properties of View

All properties listed in this section are inherited, i.e. the property will applynot only to the View for which it is set, but also to all Views nested in it.

The following properties are available to customize the text display options:

"font-name" property

Property "font-name" (constant FontName) - the text property specifies the name of the font to use.Multiple fonts can be specified. In this case, they are separated by a space.Fonts are applied in the order in which they are listed. Those, the first is applied first,if it is not available, then the second, third, etc.

You can get the value of this property using the function

func GetFontName(view View, subviewID ...string) string

"text-color" property

Property "text-color" (constant TextColor) - the Color property determines the color of the text.

You can get the value of this property using the function

func GetTextColor(view View, subviewID ...string) Color

"text-size" property

Property "text-size" (constant TextSize) - the SizeUnit property determines the size of the font.

You can get the value of this property using the function

func GetTextSize(view View, subviewID ...string) SizeUnit

"italic" property

The "italic" property (constant Italic) is the bool property. If the value is true, then italics are applied to the text

You can get the value of this property using the function

func IsItalic(view View, subviewID ...string) bool

"small-caps" property

The "small-caps" property (SmallCaps constant) is the bool property. If the value is true, then small-caps is applied to the text.

You can get the value of this property using the function

func IsSmallCaps(view View, subviewID ...string) bool

"white-space" property

The "white-space" (WhiteSpace constant) int property controls how whitespace is handled within the View.The "white-space" property can take the following values:

0 (constant WhiteSpaceNormal, name "normal") - sequences of spaces are concatenated into one space.Newlines in the source are treated as a single space. Applying this value optionally splits lines to fill inline boxes.

1 (constant WhiteSpaceNowrap, name "nowrap") - Concatenates sequences of spaces into one space,like a normal value, but does not wrap lines (text wrapping) within the text.

2 (constant WhiteSpacePre, name "pre") - sequences of spaces are saved as they are specified in the source.Lines are wrapped only where newlines are specified in the source and where "br" elements are specified in the source.

3 (constant WhiteSpacePreWrap, name "pre-wrap") - sequences of spaces are saved as they areindicated in the source. Lines are wrapped only where newlines are specified in the source and there,where "br" elements are specified in the source, and optionally to fill inline boxes.

4 (constant WhiteSpacePreLine, name "pre-line") - sequences of spaces are concatenated into one space.Lines are split on newlines, on "br" elements, and optionally to fill inline boxes.

5 (constant WhiteSpaceBreakSpaces, name "break-spaces") - the behavior is identical to pre-wrap with the following differences:

  • Sequences of spaces are preserved as specified in the source, including spaces at the end of lines.
  • Lines are wrapped on any spaces, including in the middle of a sequence of spaces.
  • Spaces take up space and do not hang at the ends of lines, which means they affect the internal dimensions (min-content and max-content).

The table below shows the behavior of various values of the "white-space" property.

New lines Spaces and Tabs Text wrapping End of line spaces End-of-line other space separators
WhiteSpaceNormal Collapse Collapse Wrap Remove Hang
WhiteSpaceNowrap Collapse Collapse No wrap Remove Hang
WhiteSpacePre Preserve Preserve No wrap Preserve No wrap
WhiteSpacePreWrap Preserve Preserve Wrap Hang Hang
WhiteSpacePreLine Preserve Collapse Wrap Remove Hang
WhiteSpaceBreakSpaces Preserve Preserve Wrap Wrap Wrap

"tab-size" property

The "tab-size" int property (TabSize constant) specifies the size of the tab character (U+0009) in spaces.The value of the "tab-size" property must be greater than 0. The default value is 8

"word-break" property

The "word-break" int property (WordBreak constant) determines where the newline will be set if the text exceeds the block boundaries.The "white-space" property can take the following values:

0 (WordBreak constant, "normal" name) - default behavior for linefeed placement.

1 (WordBreakAll constant, "break-all" name) - if the block boundaries are exceeded,a line break will be inserted between any two characters (except for Chinese/Japanese/Korean text).

2 (WordBreakKeepAll constant, "keep-all" name) - Line break will not be used in Chinese/Japanese/ Korean text.For text in other languages, the default behavior (normal) will be applied.

3 (WordBreakWord constant, "break-word" name) - when the block boundaries are exceeded,the remaining whole words can be broken in an arbitrary place, if a more suitable place for line break is not found.

"strikethrough", "overline", "underline" properties

These bool properties set decorative lines on the text:

Property Constant Decorative line type
"strikethrough" Strikethrough Strikethrough line text
"overline" Overline Line above the text
"underline" Underline Line under the text

You can get the value of these properties using the functions

func IsStrikethrough(view View, subviewID ...string) bool
func IsOverline(view View, subviewID ...string) bool
func IsUnderline(view View, subviewID ...string) bool

"text-line-thickness" property

The "text-line-thickness" SizeUnit property (TextLineThickness constant) sets the thicknessof decorative lines on the text set using the "strikethrough", "overline" and "underline" properties.

You can get the value of this property using the function

GetTextLineThickness(view View, subviewID ...string) SizeUnit

"text-line-style" property

The "text-line-style" int property (constant TextLineStyle) sets the style of decorative lineson the text set using the "strikethrough", "overline" and "underline" properties.

Possible values are:

Value Constant Name Description
1 SolidLine "solid" Solid line (default value)
2 DashedLine "dashed" Dashed line
3 DottedLine "dotted" Dotted line
4 DoubleLine "double" Double solid line
5 WavyLine "wavy" Wavy line

You can get the value of this property using the function

func GetTextLineStyle(view View, subviewID ...string) int

"text-line-color" property

The "text-line-color" Color property (constant TextLineColor) sets the color of decorative lineson the text set using the "strikethrough", "overline" and "underline" properties.If the property is not defined, then the text color specified by the "text-color" property is used for lines.

You can get the value of this property using the function

func GetTextLineColor(view View, subviewID ...string) Color

"text-weight" property

The "text-weight" int property (TextWeight constant) sets the font style. Valid values:

Value Constant Common name of the face
1 ThinFont Thin (Hairline)
2 ExtraLightFont Extra Light (Ultra Light)
3 LightFont Light
4 NormalFont Normal. Default value
5 MediumFont Medium
6 SemiBoldFont Semi Bold (Demi Bold)
7 BoldFont Bold
8 ExtraBoldFont Extra Bold (Ultra Bold)
9 BlackFont Black (Heavy)

Some fonts are only available in normal or bold style. In this case, the value of this property is ignored.

You can get the value of this property using the function

func GetTextWeight(view View, subviewID ...string) int

"text-shadow" property

The "text-shadow" property allows you to set shadows for the text. There may be several shadows.The shadow is described using the ViewShadow interface (see above, section "The 'shadow' property").For text shadow, only the "color", "x-offset", "y-offset" and "blur" properties are used.The "inset" and "spread-radius" properties are ignored (i.e. setting them is not an error, they just have no effect on the text shadow).

To create a ViewShadow for the text shadow, the following functions are used:

func NewTextShadow(offsetX, offsetY, blurRadius SizeUnit, color Color) ViewShadow
func NewShadowWithParams(params Params) ViewShadow

The NewShadowWithParams function is used when constants must be used as parameters. For example:

shadow := NewShadowWithParams(rui.Params{
	rui.ColorTag  : "@shadowColor",
	rui.BlurRadius: 8.0,
})

ViewShadow, ViewShadow array, ViewShadow textual representation can be assigned as a value to the "text-shadow" property (see above, section "The 'shadow' property").

You can get the value of this property using the function

func GetTextShadows(view View, subviewID ...string) []ViewShadow

If no shadow is specified, then this function will return an empty array

"text-align" property

The "text-align" int property (constant TextAlign) sets the alignment of the text. Valid values:

Value Constant Name Value
0 LeftAlign "left" Left alignment
1 RightAlign "right" Right alignment
2 CenterAlign "center" Center alignment
3 JustifyAlign "justify" Justify alignment

You can get the value of this property using the function

func GetTextAlign(view View, subviewID ...string) int

"text-indent" property

The "text-indent" (TextIndent constant) SizeUnit property determines the size of the indent (empty space)before the first line of text.

You can get the value of this property using the function

func GetTextIndent(view View, subviewID ...string) SizeUnit

"letter-spacing" property

The "Letter-spacing" (LetterSpacing constant) SizeUnit property determines the letter spacing in the text.The value can be negative, but there can be implementation-specific restrictions.The user agent can choose not to increase or decrease the letter spacing to align the text.

You can get the value of this property using the function

func GetLetterSpacing(view View, subviewID ...string) SizeUnit

"word-spacing" property

The "word-spacing" (WordSpacing constant) SizeUnit property determines the length of the space between words.If the value is specified as a percentage, then it defines the extra spacing as a percentage of the preliminary character width.Otherwise, it specifies additional spacing in addition to the inner word spacing as defined by the font.

You can get the value of this property using the function

func GetWordSpacing(view View, subviewID ...string) SizeUnit

"line-height" property

The "line-height" (LineHeight constant) SizeUnit property sets the amount of space between lines.

You can get the value of this property using the function

func GetLineHeight(view View, subviewID ...string) SizeUnit

"text-transform" property

The "text-transform" (TextTransform constant) int property defines the case of characters. Valid values:

Value Constant Case conversion
0 NoneTextTransform Original case of characters
1 CapitalizeTextTransform Every word starts with a capital letter
2 LowerCaseTextTransform All characters are lowercase
3 UpperCaseTextTransform All characters are uppercase

You can get the value of this property using the function

func GetTextTransform(view View, subviewID ...string) int

"text-direction" property

The "text-direction" (TextDirection constant) int property determines the direction of text output. Valid values:

Value Constant Text output direction
0 SystemTextDirection Systemic direction. Determined by the language of the operating system.
1 LeftToRightDirection From left to right. Used for English and most other languages.
2 RightToLeftDirection From right to left. Used for Hebrew, Arabic and some others.

You can get the value of this property using the function

func GetTextDirection(view View, subviewID ...string) int

"writing-mode" property

The "writing-mode" (WritingMode constant) int property defines how the lines of text are arrangedvertically or horizontally, as well as the direction in which the lines are displayed.Possible values are:

Value Constant Description
0 HorizontalTopToBottom Horizontal lines are displayed from top to bottom. Default value
1 HorizontalBottomToTop Horizontal lines are displayed from bottom to top.
2 VerticalRightToLeft Vertical lines are output from right to left.
3 VerticalLeftToRight Vertical lines are output from left to right.

You can get the value of this property using the function

func GetWritingMode(view View, subviewID ...string) int

"vertical-text-orientation" property

The "vertical-text-orientation" (VerticalTextOrientation constant) int property is used only if "writing-mode"is set to VerticalRightToLeft (2) or VerticalLeftToRight (3) and determines the position of the vertical line characters.Possible values are:

Value Constant Value
0 MixedTextOrientation Symbols rotated 90 clockwise. Default value.
1 UprightTextOrientation Symbols are arranged normally (vertically).

You can get the value of this property using the function

func GetVerticalTextOrientation(view View, subviewID ...string) int

"user-select" property

The "user-select" property (UserSelect constant) of type bool determines whether the user can select text.Accordingly, if the property is set to true, then the user can select text. If it's false, then it can't.

The default value depends on the value of the "semantics" property. If "semantics" is set to "p", "h1"..."h6","blockquote" or "code", then the default value is "true", otherwise the default value is "false".The exception is TableView. Its default value is "true".

Like all text properties, the "user-select" property is inherited, i.e. if you set it for a container,it will also apply to all child elements

You can get the value of this property using the function

func IsUserSelect(view View, subviewID ...string) bool