Summary
On macOS, textSetColor has no visible effect on a Text() label. The label always renders in the default labelColor (white in dark appearance), regardless of the color passed.
Cause
Text() creates an NSTextField.labelWithString (crates/perry-ui-macos/src/widgets/text.rs), then install_label_cell (crates/perry-ui-macos/src/widgets/padding.rs:208) captures and re-sets the field's attributedStringValue (line 219). An NSTextField with an attributedStringValue ignores setTextColor: — the attributed string's baked-in color attribute (the default labelColor) wins. So perry_ui_text_set_color → setTextColor: is silently overridden.
Reproduce
- macOS, Perry 0.5.1622 (local build), Darwin 25.6.0 arm64.
const t = Text("hi"); textSetFontSize(t, 40); textSetColor(t, 1, 0, 0, 1) on a white background.
- The label renders in the default color (white in dark appearance / invisible on white), not red. A pure-red, -green, -blue label all render white on a dark background — the color argument is ignored entirely.
Expected
textSetColor colors the label.
Workaround
Re-set the string after coloring (textSetString(widget, text)), which replaces the stale attributedStringValue with a plain stringValue, so textColor applies.
Suggested fix
Have set_color (and the other text setters) update the attributed string's color attribute when the label carries an attributedStringValue, or have install_label_cell not bake a color attribute into it.
Summary
On macOS,
textSetColorhas no visible effect on aText()label. The label always renders in the defaultlabelColor(white in dark appearance), regardless of the color passed.Cause
Text()creates anNSTextField.labelWithString(crates/perry-ui-macos/src/widgets/text.rs), theninstall_label_cell(crates/perry-ui-macos/src/widgets/padding.rs:208) captures and re-sets the field'sattributedStringValue(line 219). AnNSTextFieldwith anattributedStringValueignoressetTextColor:— the attributed string's baked-in color attribute (the defaultlabelColor) wins. Soperry_ui_text_set_color→setTextColor:is silently overridden.Reproduce
const t = Text("hi"); textSetFontSize(t, 40); textSetColor(t, 1, 0, 0, 1)on a white background.Expected
textSetColorcolors the label.Workaround
Re-set the string after coloring (
textSetString(widget, text)), which replaces the staleattributedStringValuewith a plainstringValue, sotextColorapplies.Suggested fix
Have
set_color(and the other text setters) update the attributed string's color attribute when the label carries anattributedStringValue, or haveinstall_label_cellnot bake a color attribute into it.