wckdspn
Topic Author
Posts: 67
Joined: 18 Aug 2012, 23:14

Autoscaling Text

02 Apr 2014, 21:13

Historically, we've had issues with localized text in menus that takes up too much space (I'm looking at you German). Optimally, we restructure layout so things look correct for all of the locales we support, but sometimes things come in late and we are forced to make it work within our existing constraints. Our usual solution is to autoscale the text to fit into an area in which it is nested.

The question is, what is the best way to do this such that it is as painless as possible for artists. Ideally it would just be an additional property we can attach to Text objects that causes it to scale instead of truncate or wrap. The behavior can be implemented as long as we can determine the exact width of the text (in pixels) with the current font and scale. We'll need to execute it right after the text is set, without necessitating setting the text manually (as artists are relying on ViewModel classes).

Thoughts?
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: Autoscaling Text

02 Apr 2014, 22:01

Why don't just use a Viewbox to wrap the text?
 
wckdspn
Topic Author
Posts: 67
Joined: 18 Aug 2012, 23:14

Re: Autoscaling Text

02 Apr 2014, 23:47

The issue with Viewbox is that it scales up as well as down, whereas we really only want to scale the text if it *doesn't* fit.
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: Autoscaling Text

03 Apr 2014, 00:47

The Viewbox has the option to scale only in one direction:
<Viewbox StretchDirection="DownOnly" Width="200">
    <TextBlock Text="{Binding DisplayName}" FontSize="18"/>
</Viewbox>
The previous Viewbox will render the text on 18 pixels height while text fits inside the 200 pixel width. And will scale it down if text doesn't fit. I think this is exactly what you need ;)
 
wckdspn
Topic Author
Posts: 67
Joined: 18 Aug 2012, 23:14

Re: Autoscaling Text

03 Apr 2014, 00:54

That is indeed what we need, yes. Thank you.

Who is online

Users browsing this forum: No registered users and 1 guest