Print Page | Close Window

HOW TO: Dynamically size markup font

Printed From: Codejock Forums
Category: General
Forum Name: XAML Snippets
Forum Description: Post your XAML snippets here for everyone to enjoy :)
URL: http://forum.codejock.com/forum_posts.asp?TID=11553
Printed Date: 07 May 2024 at 9:55am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: HOW TO: Dynamically size markup font
Posted By: markr
Subject: HOW TO: Dynamically size markup font
Date 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?



Replies:
Posted By: Oleg
Date Posted: 24 July 2008 at 5:00am
I also see only this way.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net