Home > Software engineering >  Why the text rendering is different between "default text" and "user typed text"
Why the text rendering is different between "default text" and "user typed text"

Time:04-29

You can see that the 2nd TextBox (user typed text) text is wider than the 1st TextBox text.

enter image description here

I found this in WinUI 3 but got the same result in UWP. I couldn't reproduce this in WPF.

This is the XAML.

<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <TextBlock
        Grid.Row="0"
        Grid.Column="0"
        Text="Default text" />
    <TextBox
        Grid.Row="0"
        Grid.Column="1"
        Text="TestTestTestTestTestTestTestTestTestTest" />
    <TextBlock
        Grid.Row="1"
        Grid.Column="0"
        Text="Typed text" />
    <TextBox Grid.Row="1" Grid.Column="1" />
</Grid>

My question is in the title but I'd like to know if there is a way to make them identically.

UPDATE

Thanks @Niko Zhu ! I tried your suggestion and as you mentioned, this seems to be an IME? or Google Japanese Input problem.

enter image description here

CodePudding user response:

Why the text rendering is different between "default text" and "user typed text" in UWP TextBox control?

I could reproduce this problem with chinses keyboard input, and it looks IME problem that uppercase characters are larger than the default. Please use US keyboard to replace, it will solve the problem.

  • Related