Author Topic: UILabel  (Read 109697 times)

Tulrath

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UILabel
« Reply #105 on: September 06, 2014, 11:30:08 PM »
That worked.  Thank you!

Andresfdezb

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UILabel
« Reply #106 on: September 18, 2014, 05:59:12 AM »
Hi there,
I cant' figure out about the keep crisp option. I have a panel that holds a Scroll View with a Table inside. All table rows are basically UILabels, with some text. The problem comes whenever I resize the window, when some of the labels get blurry. My UIRoot is set to Flexible since I want my UI widgets to maintain it's size (which includes the labels), and all the labels have the keep crips set to always. Does this option only works for dynamic fonts? Because I'm using an embebbed font (arial) and labels get blurry when I resize the screen (and also text doesn't appear much crisp without even resizing).

Thanks in advance for the help.
« Last Edit: September 18, 2014, 06:04:44 AM by Andresfdezb »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #107 on: September 18, 2014, 05:26:38 PM »
The dimensions of the window need to be dividable by two. Meaning if your window is something like 479x500, then the width part of is is not dividable by 2, resulting in a blurred UI.

And yes, the crisp option is only for dynamic fonts.

Andresfdezb

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UILabel
« Reply #108 on: September 22, 2014, 01:32:16 AM »
The dimensions of the window need to be dividable by two. Meaning if your window is something like 479x500, then the width part of is is not dividable by 2, resulting in a blurred UI.

And yes, the crisp option is only for dynamic fonts.

Thanks, I'll have to run some more tests (and also look for a dynamic font, I guess).

Andresfdezb

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UILabel
« Reply #109 on: September 22, 2014, 02:28:01 AM »
So, here's one last follow up question. I have imported one font from windows (ttf) and set it as dynamic. Is this setting correct? I mean, can ttf fonts be used as dynamic?

(Also I'm running some tests to check how well the crisp option works with different aspect ratios and screen sizes).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #110 on: September 22, 2014, 10:41:31 AM »
TTF is TrueType Font. TTF and OTF files are both imported by Unity as Fonts, and yes you can use them as dynamic fonts for labels. Just keep in mind there are a lot of issues with dynamic fonts, and I don't advise using them. Stick to bitmap fonts by creating one via the NGUI's Font Maker.

Andresfdezb

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UILabel
« Reply #111 on: September 23, 2014, 01:19:17 AM »
TTF is TrueType Font. TTF and OTF files are both imported by Unity as Fonts, and yes you can use them as dynamic fonts for labels. Just keep in mind there are a lot of issues with dynamic fonts, and I don't advise using them. Stick to bitmap fonts by creating one via the NGUI's Font Maker.

Ok, thanks.

Maxii

  • Jr. Member
  • **
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 55
    • View Profile
    • Strategic Forge
Re: UILabel
« Reply #112 on: September 26, 2014, 08:51:08 AM »
From reading the different threads here, I was expecting MakePixelPerfect (from code) and the Snap Button to adjust the size of the label (widget dimensions) to fit the size of the font and Text currently present in the Text box. It doesn't seem to be doing the above, aka what I expect.

Can you give me a rundown of what I SHOULD expect, since obviously my current expectation is erroneous. I'm using the built in Arial Regular 12 (UIFont).

Does the Overflow setting make a difference in what to expect?
I'm looking for an artist partner to complement my programming skill in developing a space-based Civilization-like empire building game, ala GalCiv2 or Distant Worlds based on Unity3D.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #113 on: September 27, 2014, 07:28:54 PM »
Using that function will resize the label if its text currently doesn't fit. If the text fits, nothing will happen.

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: UILabel
« Reply #114 on: October 27, 2014, 09:34:07 AM »
What would be a proper way to force UILabels to render dynamic fonts at a different resolution? Use of Flexible + Adjust by DPI UIRoot can lead the labels to believe they have to be rasterized at, say, 14px height, when in reality they occupy 28px on a physical screen (in case of 2x DPI adjustment). I take it I have to alter the arguments in RequestCharactersInTexture calls in NGUIText to do that? For example, by multiplying them by reliable static multiplier that will correct the rasterized resolution to proper one if UIRoot is scaled by DPI adjustment.

There is quite a lot of these calls, through, and I'm not seeing immediate changes to resolution after altering finalSize arguments, so I might be wrong.

P.S.: I know it would've been easier with bitmaps, but I'm afraid I don't have an option of using them (full Unicode support multiplied by reasonably big set of sizes and thicknesses requested by guidelines multiplied by six screen densities would produce quite a mess with bitmaps, so I think dynamic font labels win in convenience in my case).
« Last Edit: October 27, 2014, 09:42:39 AM by bac9 »

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: UILabel
« Reply #115 on: October 27, 2014, 10:10:16 AM »
I think I almost got it, just need to fix alignment issues now. I changed:

Line 235 in NGUIText.GetGlyph
Quote
if (dynamicFont.GetCharacterInfo ((char) ch, out mTempChar, Mathf.RoundToInt (finalSize * screenMultiplier), fontStyle))

Line 258 in NGUIText.GetGlyph
Quote
float pd = fontScale * pixelDensity / screenMultiplier;



I think I need to alter Update in the beginning, but adding multiplier into baseline variable is not entirely fixing it, so I might be missing someplace else.

_________________

Edit: Still a bit wrong, but it's very close. Am I altering the right place in this baseline calculation?

Quote
float y0 = mTempChar.vert.yMax;
float y1 = mTempChar.vert.yMin;
baseline = Mathf.Round (y0 + (finalSize - y0 + y1) * 0.5f * screenMultiplier);



Both y0 and y1 are not changed when GetGlyph encounters non-1 screenMultiplier, so it's unlikely I need to multiply those by anything. Multiplying finalSize doesn't look right either, as well as multiplying the whole thing before rounding. I'm probably overlooking something.

_________________

Edit 2: Or maybe baseline is alright all along and I should only alter something else in the GetGlyph method. For example, adding this comes extremely close to the desired result:

Line 246 in NGUIText.GetGlyph
Quote
glyph.v0.y = (mTempChar.vert.yMax - baseline) * screenMultiplier;



Except the result seems to deviate undesirably between glyphs, breaking proper vertical alignment. Ugh. :)

_________________

Edit 3: Ugh, so close yet wrong again!

Line 246 in NGUIText.GetGlyph
Quote
glyph.v0.y = (mTempChar.vert.yMax - baseline) * screenMultiplier;
glyph.v1.y = (glyph.v0.y - mTempChar.vert.height) / screenMultiplier;



Letter U no longer sinks, but now O fails to raise above other quads like it does in properly aligned x1 scaling. What the hell am I missing?

_________________

Edit 4: Okay, I'm starting to have a suspicion I have missed an already present pixel density correction that's right under my nose. Never saw the existing pixel density parameter in NGUIText be anything other than 1, but figuring out where it's assigned might be the right way to approach the issue instead of tinkering with delicate stuff in NGUIText.

_________________

Edit 5: Christ, that's completely right!



I forgot that I bypassed the way standard UIRoot DPI adjustment works, which is why labels never received any notice about changed density, - as the property of UIRoot they were reading was not changed by screen density logic anymore. Very simple fix.

Line 1792 in UILabel
Quote
if (rt != null) NGUIText.pixelDensity = (rt != null) ? 1f / screenMultiplier : 1f;
« Last Edit: October 28, 2014, 04:39:20 AM by bac9 »

meowikanz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UILabel
« Reply #116 on: November 04, 2014, 05:58:58 PM »
hi, i have looked at the reference for uilabel.alignment but i cant find out how to change it in code....

(UIlabel).alignment = ? i can work out how to set it, sometimes its really confusing for me to find examples of how to change things in code, its always clear as crystal via the unity environment.
Maybe im not looking in the right places :(

thanks for any help! jus a simple example of changing a uilabel's alignment to left upper would be really appreciated.


meowikanz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UILabel
« Reply #117 on: November 04, 2014, 06:06:05 PM »
ok i worked it out sorry i used the search function for the forum will do that from now on.
in case anyone wants to know its UIlabel.alignment = NGUIText.Alignment.(pick ur side)

PoN

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 111
    • View Profile
Re: UILabel
« Reply #118 on: December 04, 2014, 09:50:55 PM »
Why i can't set Overflow of UILabel to - "Resize freely" , when i set anchor at the label. if anchors are off , it can be set to Resize freely.

What's wrong ?

thanks.
Worked on Doc&DogAge Of Fury 3D. Actually working on WarMach.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UILabel
« Reply #119 on: December 05, 2014, 01:06:35 AM »
Because you are anchoring all sides. How can it resize freely if you are anchoring all sides?

Try using advanced anchoring, and set only 2 sides, such as Top and Left.