Re: UILabel is maiming my Character

2015-10-15 Thread Gerriet M. Denkmann

> On 15 Oct 2015, at 00:03, David Duncan  wrote:
> 
> 
>> On Oct 14, 2015, at 4:02 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> I put into some iOS 9 app (Xcode 7.0)  4 UILabels.
>> All have Clip Subviews = off, font size 96 with a coloured background, text 
>> plain = “ฟี้กุฎุมพี”.
>> 
>> The difference is the font:
>> 
>> System: ok (but is too bold for my taste)
>> Thonburi and Thonburi Light: bottom get cut off 
>> System Light: bottom gets cut off rather much
>> 
>> System also uses Thonburi as font substitution.
>> 
>> With Clip Subviews = on the characters get clipped to the coloured 
>> background, which is even worse.
>> Note: some characters go well beyond the descender line (as specified by the 
>> font) and also above the line height.
>> 
>> How can I get a UILabel which does not maim my characters?
>> (Another question would be: how to get a background which covers all of the 
>> characters. But this is not important to me right now)
>> 
>> These UILabels are ultimately meant to go into UITableViewCells (without 
>> coloured background).
> 
> You will probably need to use an attributed string that specifies a taller 
> line height than normal. This happens automatically when the system language 
> is set to languages such as Thai, but not for other languages, as it would 
> apply to all text strings.

Thanks for this hint.
And thanks a lot to Alex for his very helpful code example!

Moving the baseLine up by about 8 % and increasing the LineHeight by 5 %  
finally (after lots of fiddling) gives me an acceptable UILabel with SystemFont 
Light.

CGFloat baseChangePercent = +8; 
CGFloat lineChangePercent = +5; 

CGFloat baselineOffset = fontSize * baseChangePercent / 100 ;
CGFloat lineHeightMultiple = 1 + lineChangePercent / 100;

NSMutableParagraphStyle *paragraph = [ [ NSMutableParagraphStyle alloc ] init ];
paragraph.lineHeightMultiple = lineHeightMultiple;

attributes =@{  NSBaselineOffsetAttributeName:  @(baselineOffset),
NSFontAttributeName:
font,
NSParagraphStyleAttributeName:  
paragraph,
 };
But of course these values are heavily dependent on the font (and maybe even on 
fontSize).

How to compute these numbers directly (as opposed to trial and error)?


Kind regards,

Gerriet.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: UILabel is maiming my Character

2015-10-15 Thread Alex Zavatone
Gerriet, what I noticed at the time of writing those methods was that there was 
no predefined way to create superscripted text for NSAttributedText.

What my premise was to simulate/create superscripted text was to raise the 
baseline a % of the text's font size and reduce the font size used for the 
superscript by a fixed percentage.

What this lead to was declaring preset settings in the form of attribute 
dictionaries for the desired font styles I wished to achieve and then just 
applying those to ranges to create what we used to call style runs.

You'll notice that I started with method1, method2, etc and moved from the 
simplest approach to more structured approaches.

One nice little thing that I didn't know I pasted in there was a context 
sensitive currency formatter for US currency which superscripts the appropriate 
values if the amount is < 1 dollar or >= than 1 dollar.  It might seem trivial, 
but it handles superscripting the cents and the cent sign in cases less than a 
dollar and the $ in cases of one dollar or more.

Honestly, working with the formatting options in NSAttributedText and creating 
these text formatters was as much fun as I'd had coding since ye olde Director 
days.


Gerriet, I hate to tell you, but I forgot how I got the results.  I'll toss you 
the whole project so you can rip it apart and see if it helps you at all.

Cheers.


On Oct 15, 2015, at 2:28 AM, Gerriet M. Denkmann wrote:

> 
>> On 15 Oct 2015, at 00:03, David Duncan  wrote:
>> 
>> 
>>> On Oct 14, 2015, at 4:02 AM, Gerriet M. Denkmann  
>>> wrote:
>>> 
>>> I put into some iOS 9 app (Xcode 7.0)  4 UILabels.
>>> All have Clip Subviews = off, font size 96 with a coloured background, text 
>>> plain = “ฟี้กุฎุมพี”.
>>> 
>>> The difference is the font:
>>> 
>>> System: ok (but is too bold for my taste)
>>> Thonburi and Thonburi Light: bottom get cut off 
>>> System Light: bottom gets cut off rather much
>>> 
>>> System also uses Thonburi as font substitution.
>>> 
>>> With Clip Subviews = on the characters get clipped to the coloured 
>>> background, which is even worse.
>>> Note: some characters go well beyond the descender line (as specified by 
>>> the font) and also above the line height.
>>> 
>>> How can I get a UILabel which does not maim my characters?
>>> (Another question would be: how to get a background which covers all of the 
>>> characters. But this is not important to me right now)
>>> 
>>> These UILabels are ultimately meant to go into UITableViewCells (without 
>>> coloured background).
>> 
>> You will probably need to use an attributed string that specifies a taller 
>> line height than normal. This happens automatically when the system language 
>> is set to languages such as Thai, but not for other languages, as it would 
>> apply to all text strings.
> 
> Thanks for this hint.
> And thanks a lot to Alex for his very helpful code example!
> 
> Moving the baseLine up by about 8 % and increasing the LineHeight by 5 %  
> finally (after lots of fiddling) gives me an acceptable UILabel with 
> SystemFont Light.
> 
> CGFloat baseChangePercent = +8;   
> CGFloat lineChangePercent = +5;   
>   
> CGFloat baselineOffset = fontSize * baseChangePercent / 100 ;
> CGFloat lineHeightMultiple = 1 + lineChangePercent / 100;
> 
> NSMutableParagraphStyle *paragraph = [ [ NSMutableParagraphStyle alloc ] init 
> ];
> paragraph.lineHeightMultiple = lineHeightMultiple;
> 
> attributes =  @{  NSBaselineOffsetAttributeName:  @(baselineOffset),
>   NSFontAttributeName:
> font,
>   NSParagraphStyleAttributeName:  
> paragraph,
>};
> But of course these values are heavily dependent on the font (and maybe even 
> on fontSize).
> 
> How to compute these numbers directly (as opposed to trial and error)?
> 
> 
> Kind regards,
> 
> Gerriet.
> 


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: UILabel is maiming my Character

2015-10-14 Thread David Duncan

> On Oct 14, 2015, at 4:02 AM, Gerriet M. Denkmann  wrote:
> 
> I put into some iOS 9 app (Xcode 7.0)  4 UILabels.
> All have Clip Subviews = off, font size 96 with a coloured background, text 
> plain = “ฟี้กุฎุมพี”.
> 
> The difference is the font:
> 
> System: ok (but is too bold for my taste)
> Thonburi and Thonburi Light: bottom get cut off 
> System Light: bottom gets cut off rather much
> 
> System also uses Thonburi as font substitution.
> 
> With Clip Subviews = on the characters get clipped to the coloured 
> background, which is even worse.
> Note: some characters go well beyond the descender line (as specified by the 
> font) and also above the line height.
> 
> How can I get a UILabel which does not maim my characters?
> (Another question would be: how to get a background which covers all of the 
> characters. But this is not important to me right now)
> 
> These UILabels are ultimately meant to go into UITableViewCells (without 
> coloured background).

You will probably need to use an attributed string that specifies a taller line 
height than normal. This happens automatically when the system language is set 
to languages such as Thai, but not for other languages, as it would apply to 
all text strings.

> 
> Gerriet.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com
> 
> This email sent to david.dun...@apple.com

--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: UILabel is maiming my Character

2015-10-14 Thread Alex Zavatone
NSAttributedText works really nice with these.

I'll send you some material on that.

On Oct 14, 2015, at 7:02 AM, Gerriet M. Denkmann wrote:

> I put into some iOS 9 app (Xcode 7.0)  4 UILabels.
> All have Clip Subviews = off, font size 96 with a coloured background, text 
> plain = “ฟี้กุฎุมพี”.
> 
> The difference is the font:
> 
> System: ok (but is too bold for my taste)
> Thonburi and Thonburi Light: bottom get cut off 
> System Light: bottom gets cut off rather much
> 
> System also uses Thonburi as font substitution.
> 
> With Clip Subviews = on the characters get clipped to the coloured 
> background, which is even worse.
> Note: some characters go well beyond the descender line (as specified by the 
> font) and also above the line height.
> 
> How can I get a UILabel which does not maim my characters?
> (Another question would be: how to get a background which covers all of the 
> characters. But this is not important to me right now)
> 
> These UILabels are ultimately meant to go into UITableViewCells (without 
> coloured background).
> 
> Gerriet.
> 
> 
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
> 
> This email sent to z...@mac.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com