librelist archives

« back to archive

Problems with TUITextRenderer

Problems with TUITextRenderer

From:
Павел
Date:
2012-10-03 @ 15:21
I have a custom TUITableViewCell that contains TUIImageView and TUILabel
The problem is when i set TUILabel background color to  [NSColor
clearColor] (or opaque - NO) -> text is not anti-aliasing,
(twui Example TUITextRenderer using directly and draw in drawRect of
TUITableViewCell, but in my task i need z-index of views)

Maybe I missed something from view, so any advice really helped me.

--------
Paul

Re: [twui] Problems with TUITextRenderer

From:
Jonathan Willing
Date:
2012-10-03 @ 15:25
TUILabel does not support text anti-aliasing. That's what TUITextRenderer 
sets out to accomplish.

If you absolutely must have a separate view hierarchy, look into something
like VELLabel, perhaps.
https://github.com/bitswift/Velvet/blob/master/Velvet/VELLabel.h

- Jonathan

On Oct 3, 2012, at 10:21 AM, Павел <pavel.matyukov@gmail.com> wrote:

> I have a custom TUITableViewCell that contains TUIImageView and TUILabel
> The problem is when i set TUILabel background color to  [NSColor
> clearColor] (or opaque - NO) -> text is not anti-aliasing,
> (twui Example TUITextRenderer using directly and draw in drawRect of
> TUITableViewCell, but in my task i need z-index of views)
> 
> Maybe I missed something from view, so any advice really helped me.
> 
> --------
> Paul

Re: [twui] Problems with TUITextRenderer

From:
Павел Матюков
Date:
2012-10-03 @ 15:55
Ok, but why if i set background color of TUILabel  to white or other it's
looks good.

See screenshots :
Bad   - http://dl.dropbox.com/u/3387125/TWUI/bad.png
Good - http://dl.dropbox.com/u/3387125/TWUI/good.png
also  if i select text something goes wrong.

Before this, i created TUIView in my custom TUITableViewCell and in block
drawRect directly draw TUITextrenderer like in ExampleApp in github ->  the
same problem;

Thank's!
-----
Paul Matukov

2012/10/3 Jonathan Willing <jwilling@me.com>

> TUILabel does not support text anti-aliasing. That's what TUITextRenderer
> sets out to accomplish.
>
> If you absolutely must have a separate view hierarchy, look into something
> like VELLabel, perhaps.
> https://github.com/bitswift/Velvet/blob/master/Velvet/VELLabel.h
>
> - Jonathan
>
> On Oct 3, 2012, at 10:21 AM, Павел <pavel.matyukov@gmail.com> wrote:
>
> I have a custom TUITableViewCell that contains TUIImageView and TUILabel
> The problem is when i set TUILabel background color to  [NSColor
> clearColor] (or opaque - NO) -> text is not anti-aliasing,
> (twui Example TUITextRenderer using directly and draw in drawRect of
> TUITableViewCell, but in my task i need z-index of views)
>
> Maybe I missed something from view, so any advice really helped me.
>
> --------
> Paul
>
>
>

Re: [twui] Problems with TUITextRenderer

From:
Loren Brichter
Date:
2012-10-03 @ 16:02
Yep, specifically TUILabel only supports *subpixel*-antialiasing when you 
have an opaque background set. (It supports regular grayscale antialiasing
at all times).

The reason is CoreText – it needs to know the color that the text is going
to be rendered against in order to draw the correct sub pixel "fringes". 
If your background color is clear, the compositing happens later (by Core 
Animation), so all CoreText sees is the transparent color.

AppKit on 10.8 has a pretty clever workaround for this, when you need to 
sub pixel antialias some text in a label with a clear background, it 
actually walks up the view hierarchy until it finds an opaque ancestor and
uses that as sort of a "hint" to draw the correct fringes against. I don't
understand 100% what it does yet, but it might be worth checking out and 
mimicking.

For now, as long as you have an opaque background for your TUILabel, or 
use TUITextRenderer to draw directly onto an opaque surface you can work 
around it. Or lose the sub pixel antialiasing and just use regular 
antialiasing for those specific views.

Loren

On Oct 3, 2012, at 11:55 AM, "Павел Матюков" <pavel.matyukov@gmail.com> wrote:

> Ok, but why if i set background color of TUILabel  to white or other 
it's looks good.
> 
> See screenshots :
> Bad   - http://dl.dropbox.com/u/3387125/TWUI/bad.png
> Good - http://dl.dropbox.com/u/3387125/TWUI/good.png
> also  if i select text something goes wrong.
> 
> Before this, i created TUIView in my custom TUITableViewCell and in 
block drawRect directly draw TUITextrenderer like in ExampleApp in github 
->  the same problem;
> 
> Thank's!
> -----
> Paul Matukov
> 
> 2012/10/3 Jonathan Willing <jwilling@me.com>
> TUILabel does not support text anti-aliasing. That's what 
TUITextRenderer sets out to accomplish.
> 
> If you absolutely must have a separate view hierarchy, look into 
something like VELLabel, perhaps.
> https://github.com/bitswift/Velvet/blob/master/Velvet/VELLabel.h
> 
> - Jonathan
> 
> On Oct 3, 2012, at 10:21 AM, Павел <pavel.matyukov@gmail.com> wrote:
> 
>> I have a custom TUITableViewCell that contains TUIImageView and TUILabel
>> The problem is when i set TUILabel background color to  [NSColor
>> clearColor] (or opaque - NO) -> text is not anti-aliasing,
>> (twui Example TUITextRenderer using directly and draw in drawRect of
>> TUITableViewCell, but in my task i need z-index of views)
>> 
>> Maybe I missed something from view, so any advice really helped me.
>> 
>> --------
>> Paul
> 
> 

Re: [twui] Problems with TUITextRenderer

From:
Павел Матюков
Date:
2012-10-03 @ 16:56
Thank's a lot! Solution for my problems was draw NSIImage in drawRect
method of my custom TUITableViewCell.

2012/10/3 Loren Brichter <loren.brichter@gmail.com>

> Yep, specifically TUILabel only supports *subpixel*-antialiasing when you
> have an opaque background set. (It supports regular grayscale antialiasing
> at all times).
>
> The reason is CoreText - it needs to know the color that the text is going
> to be rendered against in order to draw the correct sub pixel "fringes". If
> your background color is clear, the compositing happens later (by Core
> Animation), so all CoreText sees is the transparent color.
>
> AppKit on 10.8 has a pretty clever workaround for this, when you need to
> sub pixel antialias some text in a label with a clear background, it
> actually walks up the view hierarchy until it finds an opaque ancestor and
> uses that as sort of a "hint" to draw the correct fringes against. I don't
> understand 100% what it does yet, but it might be worth checking out and
> mimicking.
>
> For now, as long as you have an opaque background for your TUILabel, or
> use TUITextRenderer to draw directly onto an opaque surface you can work
> around it. Or lose the sub pixel antialiasing and just use regular
> antialiasing for those specific views.
>
> Loren
>
> On Oct 3, 2012, at 11:55 AM, "Павел Матюков" <pavel.matyukov@gmail.com>
> wrote:
>
> Ok, but why if i set background color of TUILabel  to white or other it's
> looks good.
>
> See screenshots :
> Bad   - http://dl.dropbox.com/u/3387125/TWUI/bad.png
> Good - http://dl.dropbox.com/u/3387125/TWUI/good.png
> also  if i select text something goes wrong.
>
> Before this, i created TUIView in my custom TUITableViewCell and in block
> drawRect directly draw TUITextrenderer like in ExampleApp in github ->  the
> same problem;
>
> Thank's!
> -----
> Paul Matukov
>
> 2012/10/3 Jonathan Willing <jwilling@me.com>
>
>> TUILabel does not support text anti-aliasing. That's what TUITextRenderer
>> sets out to accomplish.
>>
>> If you absolutely must have a separate view hierarchy, look into
>> something like VELLabel, perhaps.
>> https://github.com/bitswift/Velvet/blob/master/Velvet/VELLabel.h
>>
>> - Jonathan
>>
>> On Oct 3, 2012, at 10:21 AM, Павел <pavel.matyukov@gmail.com> wrote:
>>
>> I have a custom TUITableViewCell that contains TUIImageView and TUILabel
>> The problem is when i set TUILabel background color to  [NSColor
>> clearColor] (or opaque - NO) -> text is not anti-aliasing,
>> (twui Example TUITextRenderer using directly and draw in drawRect of
>> TUITableViewCell, but in my task i need z-index of views)
>>
>> Maybe I missed something from view, so any advice really helped me.
>>
>> --------
>> Paul
>>
>>
>>
>
>