-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Button CharacterSpacing Fix #20537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?xml version="1.0" encoding="utf-8" ?> | ||
| <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
| x:Class="Maui.Controls.Sample.Issues.Issue18832" | ||
| xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues"> | ||
| <VerticalStackLayout> | ||
| <Label Text="Button: "/> | ||
| <Button AutomationId="button" Text="Hello, World!" CharacterSpacing="10" FontSize="30" FontFamily="OpenSansRegular" TextColor="DarkBlue"/> | ||
| <Label Text="Label: "/> | ||
| <Label AutomationId="label" Text="Hello, World!" CharacterSpacing="10" FontSize="30" FontFamily="OpenSansRegular"/> | ||
| </VerticalStackLayout> | ||
| </ContentPage> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using Microsoft.Maui.Controls; | ||
| using Microsoft.Maui.Controls.Xaml; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues | ||
| { | ||
| [XamlCompilation(XamlCompilationOptions.Compile)] | ||
| [Issue(IssueTracker.Github, 18832, "[iOS] Button CharacterSpacing makes FontSize fixed and large", PlatformAffected.iOS)] | ||
| public partial class Issue18832 : ContentPage | ||
| { | ||
| public Issue18832() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues | ||
| { | ||
| public class Issue18832 : _IssuesUITest | ||
| { | ||
| public override string Issue => "[iOS] Button CharacterSpacing makes FontSize fixed and large"; | ||
|
|
||
| public Issue18832(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.Button)] | ||
| public void SizesOfBothTextsShouldHaveTheSameAndCharacterSpacing() | ||
| { | ||
| _ = App.WaitForElement("button"); | ||
|
|
||
| // The test passes if both "Hello, World!" texts are of the same size | ||
| // and have the same character spacing | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -98,7 +98,8 @@ public static void MapText(IButtonHandler handler, IText button) | |||
| handler.PlatformView?.UpdateText(button); | ||||
|
|
||||
| // Any text update requires that we update any attributed string formatting | ||||
| MapFormatting(handler, button); | ||||
| var fontManager = handler.GetRequiredService<IFontManager>(); | ||||
| handler.PlatformView?.UpdateAttributedTitle(fontManager, button); | ||||
| } | ||||
|
|
||||
| public static void MapTextColor(IButtonHandler handler, ITextStyle button) | ||||
|
|
@@ -116,11 +117,17 @@ public static void MapTextColor(IButtonHandler handler, ITextStyle button) | |||
| { | ||||
| handler.PlatformView?.UpdateTextColor(button); | ||||
| } | ||||
|
|
||||
| var fontManager = handler.GetRequiredService<IFontManager>(); | ||||
| handler.PlatformView?.UpdateAttributedTitle(fontManager, button!); | ||||
| } | ||||
|
|
||||
| public static void MapCharacterSpacing(IButtonHandler handler, ITextStyle button) | ||||
| { | ||||
| handler.PlatformView?.UpdateCharacterSpacing(button); | ||||
|
|
||||
|
Comment on lines
123
to
+128
|
||||
| handler.PlatformView?.UpdateCharacterSpacing(button); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,5 @@ | ||||||||||||||||||||||||||||||
| using System; | ||||||||||||||||||||||||||||||
| using Foundation; | ||||||||||||||||||||||||||||||
| using UIKit; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| namespace Microsoft.Maui.Platform | ||||||||||||||||||||||||||||||
|
|
@@ -112,5 +113,32 @@ internal static void UpdateContentEdgeInsets(this UIButton platformButton, Thick | |||||||||||||||||||||||||||||
| #pragma warning restore CA1422 // Validate platform compatibility | ||||||||||||||||||||||||||||||
| #pragma warning restore CA1416 | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| internal static void UpdateAttributedTitle(this UIButton platformButton, IFontManager fontManager, ITextStyle textStyle) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| if(platformButton.CurrentTitle == null) | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| if(platformButton.CurrentTitle == null) | |
| if (platformButton.CurrentTitle == null) |
Copilot
AI
Jan 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment contains typo with duplicated word "Update". Should be "Update CharacterSpacing" instead of "Update UpdateCharacterSpacing".
| //Update UpdateCharacterSpacing | |
| // Update CharacterSpacing |
Copilot
AI
Jan 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment style inconsistency. Use double-slash comment syntax with a space after the slashes, like "// Update Text Color" to match the project's code style.
| //Update UpdateCharacterSpacing | |
| if (textStyle.CharacterSpacing != 0) | |
| { | |
| attributedString = attributedString.WithCharacterSpacing(textStyle.CharacterSpacing); | |
| } | |
| //Update Text Color | |
| // Update UpdateCharacterSpacing | |
| if (textStyle.CharacterSpacing != 0) | |
| { | |
| attributedString = attributedString.WithCharacterSpacing(textStyle.CharacterSpacing); | |
| } | |
| // Update Text Color |
Uh oh!
There was an error while loading. Please reload this page.