You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Control.CharacterSpacing is a [NotImplemented("__SKIA__")] stub on Skia (Control.cs). The property can be set and read back, but it has no effect, and it doesn't reach the text inside the control's template.
In WinUI, Control.CharacterSpacing is an inherited text property: the value flows down to every TextBlock/ContentPresenter inside the control, so <TextBox CharacterSpacing="200"/> and <Button CharacterSpacing="200" Content="Hello"/> space their text.
Expected, as in WinUI: setting CharacterSpacing on a Button, TextBox, ComboBox, DatePicker, TimePicker, AutoSuggestBox, etc. spaces the text they display.
Why is this needed? 🤔
Any library that wraps Uno controls and forwards a letter-spacing setting to them hits this. In our case, a cross-platform UI library that maps a "character spacing" property onto TextBox, ComboBox, DatePicker and TimePicker finds it silently ignored. Setting it on the control is also the only way to space text in control templates you don't own.
The Uno0001 analyzer only fires when you set the property from C#, and as a warning it is easy to miss. An older dev build (7.0.0-dev.763) didn't flag it at all, so code that sets it just silently did nothing. Values set in XAML don't warn.
WinUI reference (WinUI C++ sources from microsoft-ui-xaml):
dxaml/xcp/components/metadata/StaticMetadata.g.cpp: Control_CharacterSpacing is declared with IsInheritedProperty.
dxaml/xcp/core/core/elements/Control.cpp: when Control_CharacterSpacing is at its default, m_pTextFormatting->m_nCharacterSpacing is taken from the parent's text formatting, and children read it from there.
Repro
Create an Uno app with Uno.WinUI7.0.0-dev.1434 (net10.0-desktop, Skia). The same behavior shows up on master at 7a22141 (tested with a SamplesApp runtime test).
Put this in the window content (or a runtime test) and read the sizes after load:
TextBlocktb0=new(){Text="AVAILABILITY",FontSize=48};TextBlocktb200=new(){Text="AVAILABILITY",FontSize=48,CharacterSpacing=200};Buttonb0=new(){Content="AVAILABILITY",FontSize=48};Buttonb200=new(){Content="AVAILABILITY",FontSize=48,CharacterSpacing=200};// Uno0001TextBoxx200=new(){Text="AVAILABILITY",FontSize=48,CharacterSpacing=200};// Uno0001// add all to a StackPanel, wait for load, then compare b0.ActualWidth and b200.ActualWidth,// and walk VisualTreeHelper from b200 / x200 printing each TextBlock.CharacterSpacing
Build: the compiler reports warning Uno0001: Microsoft.UI.Xaml.Controls.Control.CharacterSpacing is not implemented in Uno.
Results on Skia Desktop (master runtime test; the dev package gives the same, with a 318.67 button width):
In WinUI the inner TextBlocks see the inherited CharacterSpacing and the button gets wider (12 characters at 48px with 200 = 0.2em should add roughly 115px).
Backing: confirmed at runtime on Skia Desktop (master runtime test and a throwaway app on the dev package), and the WinUI inheritance behavior comes from the WinUI C++ sources above. I did not run a native WinUI repro.
Anything else we need to know? 💬
Related: TextBlock.CharacterSpacing is silently ignored on the Skia renderer (no analyzer warning) #24363 reports that TextBlock.CharacterSpacing itself has no effect on Skia. My runs agree: a plain TextBlock did not widen either (294.67 for both 0 and 200), and neither did a Run with CharacterSpacing set in Inlines (dev package). So this request depends on that one: inheriting the value into templates is only useful once TextBlock/Run honor it. The Skia layout code already has CharacterSpacing plumbing (ParsedText, RenderSegmentSpan, TextFormatting.CharacterSpacing), so that part may be a small fix.
Suggested approach: make Control.CharacterSpacing a real inherited property (same pattern as FontSize/FontFamily inheritance into TextBlock/ContentPresenter/TextBox) and remove the [NotImplemented] marker.
Workaround: none for templated controls, short of walking the template and setting CharacterSpacing on each inner TextBlock yourself (which, per the related issue, is currently ignored too).
Renderer: Skia. Platforms: Desktop (Windows tested); the code is shared across the Skia heads.
What would you like to be added? 💡
Control.CharacterSpacingis a[NotImplemented("__SKIA__")]stub on Skia (Control.cs). The property can be set and read back, but it has no effect, and it doesn't reach the text inside the control's template.In WinUI,
Control.CharacterSpacingis an inherited text property: the value flows down to everyTextBlock/ContentPresenterinside the control, so<TextBox CharacterSpacing="200"/>and<Button CharacterSpacing="200" Content="Hello"/>space their text.Expected, as in WinUI: setting
CharacterSpacingon aButton,TextBox,ComboBox,DatePicker,TimePicker,AutoSuggestBox, etc. spaces the text they display.Why is this needed? 🤔
Any library that wraps Uno controls and forwards a letter-spacing setting to them hits this. In our case, a cross-platform UI library that maps a "character spacing" property onto
TextBox,ComboBox,DatePickerandTimePickerfinds it silently ignored. Setting it on the control is also the only way to space text in control templates you don't own.The
Uno0001analyzer only fires when you set the property from C#, and as a warning it is easy to miss. An older dev build (7.0.0-dev.763) didn't flag it at all, so code that sets it just silently did nothing. Values set in XAML don't warn.WinUI reference (WinUI C++ sources from
microsoft-ui-xaml):dxaml/xcp/components/metadata/StaticMetadata.g.cpp:Control_CharacterSpacingis declared withIsInheritedProperty.dxaml/xcp/core/core/elements/Control.cpp: whenControl_CharacterSpacingis at its default,m_pTextFormatting->m_nCharacterSpacingis taken from the parent's text formatting, and children read it from there.Repro
Uno.WinUI7.0.0-dev.1434(net10.0-desktop, Skia). The same behavior shows up onmasterat 7a22141 (tested with a SamplesApp runtime test).warning Uno0001: Microsoft.UI.Xaml.Controls.Control.CharacterSpacing is not implemented in Uno.Results on Skia Desktop (master runtime test; the dev package gives the same, with a 318.67 button width):
In WinUI the inner
TextBlocks see the inheritedCharacterSpacingand the button gets wider (12 characters at 48px with 200 = 0.2em should add roughly 115px).Backing: confirmed at runtime on Skia Desktop (master runtime test and a throwaway app on the dev package), and the WinUI inheritance behavior comes from the WinUI C++ sources above. I did not run a native WinUI repro.
Anything else we need to know? 💬
TextBlock.CharacterSpacingitself has no effect on Skia. My runs agree: a plainTextBlockdid not widen either (294.67 for both 0 and 200), and neither did aRunwithCharacterSpacingset inInlines(dev package). So this request depends on that one: inheriting the value into templates is only useful onceTextBlock/Runhonor it. The Skia layout code already hasCharacterSpacingplumbing (ParsedText,RenderSegmentSpan,TextFormatting.CharacterSpacing), so that part may be a small fix.Control.CharacterSpacinga real inherited property (same pattern asFontSize/FontFamilyinheritance intoTextBlock/ContentPresenter/TextBox) and remove the[NotImplemented]marker.CharacterSpacingon each innerTextBlockyourself (which, per the related issue, is currently ignored too).Renderer: Skia. Platforms: Desktop (Windows tested); the code is shared across the Skia heads.