Reproduction Steps
Steps to reproduce:
- Play this experience on mobile (iOS or Android): TextBox UIScale Test - Roblox
- Tap the text field in the middle of the screen
- Try typing something
Observe that the text is too large when typed in.
This project reproduces the issue:
TextBox UIScale Test.rbxl (40.0 KB)
The setup for this project is very simple:
Expected Behavior
TextBox entry should work on mobile as it does on desktop, as closely as possible. The font should be rendered to look the same when text is being entered as when it is not in text entry mode. UIScale should not stop the TextBox from working.
Actual Behavior
If a TextBox has a UIScale applied to it then the native text input field on iOS and Android is incorrectly scaled. For example, with a scale set to 0.3, the text on the native input appears to be around 3.3 times too big.
Additionally, the font is also shown incorrectly in the text entry box:
- The font is shown in bold even if a non-bold font is selected (with the Zekton/Sci-fi font at least)
- The font vertical vertical alignment doesn’t work the same way as Roblox’s font alignment if the text box is smaller than the height of the font. This causes the text entered to jump up and down as you enter it. This can be partly resolved by setting the vertical alignment to ‘bottom’ (or making sure the text box is tall enough)
When not entering text:
When entering text, observe that only part of the text is shown and the text is shown in bold:
Workaround
This can be worked around with the following (convoluted) steps:
- Add a UIScale object to the text field
- Each time the UIScales in the hierarchy above change, or the absolute size of the parent of the text box changes, calculate the overall scale of the text box by multiplying the scales of all the UIScale values in the hierarchy above the text box together
- Set the UIScale inside the text box to the inverse of the scale calculated above
- Set the font size of the text box to the original font size multiplied by the scale calculated above
- Scale the size of the text box by multiplying each value in the UDim2 by the scale calculated above
This effectively cancels out the UIScale above the text box and then reapplies the UIScale manually.
Issue Area: Mobile App
Issue Type: Display
Impact: Moderate
Frequency: Constantly
Date First Experienced: 2022-10-17 00:10:00 (+01:00)
Date Last Experienced: 2022-10-18 00:10:00 (+01:00)