UXTextStyle
Rich text in UXKit is a Foundation
AttributedString. UXTextStyle names the
attributes UXKit draws and reads them as one value:
| Attribute | Value | Default |
|---|---|---|
bold, italic, underline, monospace | Number booleans | off |
pen | Number, the colour pen | 1, ink |
color | Number, 0xRRGGBB | none: the view’s ink |
size | Number, the point size | 0: the view’s own |
alignment | Number, UX_ALIGN_* | UX_ALIGN_LEFT |
UXTextView applies alignment to whole
paragraphs and draws color; the drawn text views use pen. Other attributes
are kept by the string and ignored when drawing. From 0.72.
#import "UXTextStyle.xc"Overview
Section titled “Overview”AttributedString* s = AttributedString.withString(String.withCString("The quick fox"));UXTextStyle.setBold(s, true, (i32)4, (i32)5); // "quick"UXTextStyle.setPen(s, (i32)2, (i32)10, (i32)3); // "fox" in redUXTextStyle* st = UXTextStyle.at(s, (i32)4); // st.bold is trueUXTextLayout measures and wraps each run
in its own style, and UXMarkdown produces
strings styled this way.
Topics
Section titled “Topics”of · at · sameAs · setBold · setItalic · setUnderline · setMonospace · setPen · setColor · setSize · setAlignment
static UXTextStyle* of(Map* attrs)The style an attribute set describes. Names it does not have keep their
defaults. The fields are bold, italic, underline, monospace, pen,
color (-1 for none), size and alignment.
static UXTextStyle* at(AttributedString* as, i32 i)The style of the byte at i.
sameAs
Section titled “sameAs”bool sameAs(UXTextStyle* o)Whether two styles draw the same.
setBold / setItalic / setUnderline / setMonospace / setPen / setColor / setSize / setAlignment
Section titled “setBold / setItalic / setUnderline / setMonospace / setPen / setColor / setSize / setAlignment”static void setBold(AttributedString* as, bool v, i32 start, i32 len)static void setItalic(AttributedString* as, bool v, i32 start, i32 len)static void setUnderline(AttributedString* as, bool v, i32 start, i32 len)static void setMonospace(AttributedString* as, bool v, i32 start, i32 len)static void setPen(AttributedString* as, i32 pen, i32 start, i32 len)static void setColor(AttributedString* as, i32 rgb, i32 start, i32 len)static void setSize(AttributedString* as, i16 size, i32 start, i32 len)static void setAlignment(AttributedString* as, i32 align, i32 start, i32 len)Set one attribute over len bytes from start. setColor with -1 takes
the colour off, back to the view’s ink.