Codejock Forums Homepage
Forum Home Forum Home > General > XAML Snippets
  New Posts New Posts RSS Feed - HOW TO: Dynamically size markup font
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

HOW TO: Dynamically size markup font

 Post Reply Post Reply
Author
Message
markr View Drop Down
Senior Member
Senior Member


Joined: 01 August 2004
Status: Offline
Points: 442
Post Options Post Options   Thanks (0) Thanks(0)   Quote markr Quote  Post ReplyReply Direct Link To This Post Topic: HOW TO: Dynamically size markup font
    Posted: 23 July 2008 at 12:24pm
Let's say I have a rectangle, the size of which has been computed at runtime. Now, I want to use XTP / XAML to draw a string into that rectangle using the largest font size that will fit.

Does anyone have any suggestions for computing the maximum font size as efficiently as possible?

My first thought was to use XTPMarkupMeasureElement to measure an CXTPMarkupUIElement object in a loop, increasing the XAML FontSize attribute until it no longer fits. But this strikes me as being fairly inefficient. I suppose this could be further improved through use of a binary search technique (e.g. to reduce the number of test cases).

Anyone know a better way?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 24 July 2008 at 5:00am
I also see only this way.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.