NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 20 21 22 23 24 … 93 Next »
Determining text size and available space

 
  • 0 Vote(s) - 0 Average
Determining text size and available space
Ommina
Offline

Senior Member

Posts: 330
Threads: 39
Joined: Feb 2006
#1
2010-03-11, 09:37 AM
Ok. So.

Sometimes the text that I need to display in a plugin can be... quite long. Far longer than is going to fit in even the most generous of displays, to say nothing of more typical examples of screen real-estate.

That means I have to truncate the text at some useful position if I don't want it running off the end, or, alternately, if I want to append some suffix before sending it out to be rendered. (Say, for example, the resolution or the codec of the video.)

Just the same, if the user is using a widescreen, they have more width available than those that are not. Further, smaller font sizes will provide space for more text. In these cases, I would like to tailor the length of the displayed string based on what space is available, instead of taking a "well, this works for me, hope it works for you too!" approach.

.net provides the .measureString() method, but I need to know the font and a UI element's available width. The first I can likely get through some creative reading of the skin xml files. As for the latter, I'm not as sure.

Read the percentages from the xml and apply them to the current screen's resolution? Seems a bit flakey -- is there a better way? (Or an alternate approach entirely?)
Ommina
Offline

Senior Member

Posts: 330
Threads: 39
Joined: Feb 2006
#2
2010-03-15, 04:20 AM
Replying to myself in case somebody else wants to to do the same.

After randomly poking through the various objects supplied to plugins by GBPVR, I stumbled across skinhelper2, which happily returns (pretty much) all the values I needed, without me fussing around with the XML.

For the font:

SkinHelper.getNamedFont(String name)

where name = a TextStyle in the skin.

and for the available size for the string:

SkinHelper.getNamedImagePixelSize(String name).Width

where name = a CompositeImage in the skin.

I have not been able to find a way to get the DrawText node from within the CompositeImage (which is a few percent smaller than the image), but for my purposes, I can work very well with the above.
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,677
Threads: 767
Joined: Nov 2003
#3
2010-03-15, 05:34 AM
Sorry, I didnt see your original post, but it sounds like you've managed to find all the bits you'd probably need.

I've not really tried the same myself, but I have thought about it from time to time.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Actual size of inner element in NPVR scb147 2 1,756 2010-11-02, 06:40 PM
Last Post: scb147
  International Space Station and Shuttle Watching Snooze 13 3,989 2009-08-19, 01:54 AM
Last Post: Snooze
  INI, Text File Reader... zehd 68 16,790 2009-02-25, 05:12 AM
Last Post: whurlston
  "Natural" size of a CompositeImage? PartialGestalt 2 1,882 2008-10-24, 03:30 PM
Last Post: PartialGestalt
  Record to File Size "Segments" h0st1le 13 4,155 2008-05-20, 10:48 PM
Last Post: mvallevand
  get esitimated final MPG size zehd 8 2,663 2008-04-08, 10:15 PM
Last Post: whurlston
  Determining the comskip rate. pastro 2 1,575 2007-10-07, 08:05 PM
Last Post: pastro
  AutoDelete (Delete old recordings to make room for new ones as disk space gets low) lopazopy 8 3,962 2007-07-05, 06:46 AM
Last Post: alexeyalexey
  MVP mp3 file size problem ubu 10 3,568 2007-01-26, 12:51 AM
Last Post: sub
  CommunitySkin common text styles McBainUK 35 8,114 2007-01-17, 01:21 PM
Last Post: Fatman_do

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode