LoTROInterface - View Single Post - Rig's assorted offerings thread
View Single Post
Unread 02-09-2018, 12:28 PM
Garan's Avatar
Garan Garan is offline
The Undying
Interface Author - Click to view interfaces
Join Date: Oct 2010
Posts: 281
Originally Posted by Rigantona
Next! In typical fashion, I started working on font metrics before checking to see whether anyone else had already. This is what happens when you just love the hunt. Lo and behold, a very nice Font Metrics upload by moebius92. The number of downloads shows how valuable this has been. According to the download page:

"Currently only handles characters between 0x30 and 0x7F (basic ASCII) - higher unicode characters will use the default width."

I can provide font metrics for all the fonts in the Turbine.UI.Lotro.Font enum including all Unicode characters that I have found in these fonts. Two and three byte UTF-8 strings are handled correctly - results with French, German, and Russian (well, and some others) should be as good as with English. The metrics also include heights.

Hunting Unicode characters depends on the fact that the game displays "?" if a character we request is not available. We can create a huge Label and fill it with a sequence of UTF-8 encodings, then quickly pick out anything that isn't a question mark.

Is the upload by moebius92 sufficient for people's needs, or can anyone use this extra data?
Thanks for sharing the data you've accumulated. Info is always good, even if some is duplicated.

FWIW, there's already a couple of font metric solutions. The FontSupport.lua file in my plugins dynamically calculates the actual space required for any string in any of the supported fonts. The FontMetric class supports GetTextWidth to determine the actual width of a single line, or you can provide a width and use GetTextHeight to determine the height. It uses a simple trick based on scrollable controls and scrollbar visibility to determine the actual space required to render the text in the client; no guesswork or estimates and since it is based on actual client rendering, special characters also work correctly. The class is based on a technique I believe I first encountered used by Whiteberry in Compendium (not Plugin Compendium, she authored both) which I then expanded to a reusable class with additional font support features.

I haven't had any issue with the speed of the size calculation (I may revisit it at some point to make it a bit more efficient) and it handles large blocks of text well - it is used extensively in Anthology to allow the reader to select any font they want and the plugin automatically adjusts all controls - there are a few exceptions due to limits imposed by the fixed height and maximum width of certain Turbine controls, most notably Buttons, but those are easily accounted for. It also includes enumerations for the fonts that Turbine includes but never added to their enumeration.

Last edited by Garan : 02-09-2018 at 12:38 PM.
Reply With Quote