Search Issue Tracker
Won't Fix
Votes
8
Found in
5.3.3p3
Issue ID
788820
Regression
No
GetCharacterInfo does not work when Canvas Scaler is set to "Scale With Screen Size"
Reproduction steps:
1. Open User's project
-Notice that Canvas scaler is set to "Scale With Screen Size"
2. Run "TestScene" scene
3. Press "Wrap it" UI button
-Notice that all the values in console are 0s.
Expected behaviour: All the CharacterInfo.advance values got from Font.GetCharacterInfo are greater than 0.
Workaround: Set Canvas Scaler to "Constant Pixel Size" and run the scene. This way all the lines will log values greater than 0.
Reproduced in versions: Unity 5.2.4f1, 5.3.3f1, 5.3.4f1, 5.3.5f1, 5.4.0b12, 5.4.0b17, 5.4.0b18
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Paul-Sinnett
Apr 25, 2017 12:03
I have a workaround: use the RectTransform of the Game Object with the Canvas Scaler on it to calculate the font scale factor.
e.g.
char glyph = 'A';
CharacterInfo characterInfo;
float fontScale = scaler.localScale.x;
int fontSize = Mathf.FloorToInt(myText.fontSize * fontScale);
font.GetCharacterInfo(glyph, out characterInfo, fontSize, myText.fontStyle);
float advance = characterInfo.advance / fontScale;
k0mbain
Jun 17, 2016 07:04
Confirmed, doesn't work in 5.3.4p1.