Author Topic: UIPopupList dimensions and font pixel size  (Read 2556 times)

ghost

  • Guest
UIPopupList dimensions and font pixel size
« on: February 04, 2013, 10:31:15 AM »
In our application, we have two separate font atlasses for SD and HD fonts and a single font reference, as proposed by http://www.youtube.com/watch?v=ARfmGCMbJr8. The application itself is built around the SD resolution, which is then scaled automatically to HD when on an HD capable device. Therefore, the atlas of the HD font has a pixel size of 0.5. I am not sure, but perhaps it is important to note that we have a separate atlasses for the fonts and the different scenes, so the font assets can be shared.

When using the font reference with the UIPopupList and switching to the HD font (with the 0.5 pixel size), the dimensions of the resulting popup are too big (approximately twice the size). The font itself, however, is rendered at the correct size. Poking through the source code of the UIPopupList, I noticed the line that calculates the font scale based on its size and the textScale property.

  1. float fontScale = font.size * textScale;

Judging that the font.size is used as the rendered pixel size of the font (before being scaled by the UIRoot), the resulting value will be wrong in the case of the HD font: the font size will return the pixel size set in the font itself (e.g. 38), but will ignore the size of the rendered pixels (0.5).

Currently, I have fixed this problem by replacing the code with the following snippet in UIPopupList:

  1. float fontScale = font.size * font.atlas.pixelSize * textScale;

Now, my question is this: have I stumbled upon a minor bug in UIPopupList, or am I using the component wrong (and possibly heading for a whole lot of more trouble down the road)? I am aware of the problems with using separate atlasses, and have already created a derivative of UIPopupList that deals with that. The problem, however, also appears with the original version of the component.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList dimensions and font pixel size
« Reply #1 on: February 04, 2013, 07:32:42 PM »
Minor bug. I added the font pixel size to the font only recently (in the last update or two), so not everything was polished yet. Thanks, I will patch it in.