Quantcast
VGInterface.com
Search Downloads


Go Back   LoTROInterface > LotRO Tools & Utilities for Developers

Category: LotRO Tools & Utilities for DevelopersFont Metrics
Interface Information
Download
How do I install this? (FAQ)
Name: Font Metrics   Popular!
Author:
Date: 12-30-2014 09:49 PM
Size: 11.56 Kb
Version: 0.1
Rate File: 5 out of 5 with 1 votes  
Description
This provides a function to calculate the width in pixels of a given string for a given font. For example, if we have a label "label", a string "s", and a font "f", we can use moebius92.FontMetrics.FontWidth to determine the width of the label, if we want to fit the entire string onto a single line:

Code:
label:SetText(s);
label:SetFont(f);
label:SetWidth(moebius92.FontMetric.FontWidth(f, Turbine.UI.FontStyle.None, false, s));
The arguments to FontWidth are: font, font style, markup enabled?, and text.

Currently, font style is ignored (outlined characters don't actually seem to take up more space (or they do - but labels won't require more space for them)).

Markup enabled simply indicates whether or not to ignore markups when calculating the font length.

The actual width is calculated by adding together the widths of the characters in the string ("width" table for the font), adding an optional amount of space if required by the first character in the string ("head" table for the font), and modifying the width by the amount of space needed or not needed by the last character in the string ("tail" table for the font). These values are stored by Font ID in moebius92.FontMetrics.fontWidth.

(Technically the way the tail of a string is handled is slightly more complicated - Qs in TrajanPro have fairly long tails, such that they can actually extend past the character that follows them. moebius92.FontMetrics.FontWidth will handle this correctly.)

Currently only handles characters between 0x30 and 0x7F (basic ASCII) - higher unicode characters will use the default width. Also, when it encounters UTF-8 unicode characters, it only pays attention to the head byte to determine the number of bytes in the character. I.e., if it encounter "\195" it'll assume the next byte is part of a two byte UTF-8 character, regardless of whether or not the next byte has the correct high order bits. Which is to say, make sure you get your UTF-8 correct in any string that you give to FontWidth, or else it may return an incorrect result.
File Statistics
User Rating:
5 out of 5 with 1 votes
Downloads: 2728
Views: 7805
Favorites: 0
Uploaded By:
 
Last Modified: N/A

View Pictures. Download Now! Post A Comment

There have been no comments posted to this file.
Be the first to add one.

 
Category Jump:
Search this Category:
 

All times are GMT -5. The time now is 02:45 PM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | VGInterface | LoTROInterface | MMOInterface | Swtorui