Re: Vertically Centered Colon

2016-12-01 Thread Doug Hill

> On Dec 1, 2016, at 11:20 AM, Alastair Houghton  
> wrote:
> 
> On 1 Dec 2016, at 19:05, Doug Hill  wrote:
>> 
>> Just made another breakthrough. I finally figured out why we have the 
>> vertically centerd colon (I’ll now call it VCC) by default but has 
>> requirements of numbers on either side of the colon.
>> The SF font setting is “Contextual Alternatives” (I’ll now call it CA). When 
>> CA is on, it will use the logic of numbers on either side of a colon to get 
>> VCC. Turning off CA turns off this logic and no VCC. But even if CA is on, 
>> and you have a character stream that isn’t :, you can turn 
>> on VCC explicitly with it’s own selector to get that behavior.
>> 
>> Other than VCC I’m not sure what other contextual alternatives there are. 
>> Fractions didn’t seem to do anything differently.
> 
> I think we’ve headed off topic somewhat, so this is likely my final word on 
> the subject.  Contextual alternates’ usual abbreviation is “calt” (which is 
> its OpenType tag).  It might also, at this point, be worth pointing you at 
> the OpenType specification
> 
>  https://www.microsoft.com/en-us/Typography/OpenTypeSpecification.aspx
> 
> and in particular the registered features page:
> 
>  https://www.microsoft.com/typography/otspec/featurelist.htm
> 
> The pages on advanced layout may also be informative.

Thanks for the info!

At this point, I think we figured out the original VCC bug, and I was able to 
document a number of SF font features and how to easily use them. I hope this 
has some value to the developer community; at the very least Google searches 
will now bring up info about these features.
Going forward, I personally hope I don’t have to do a deep dive into the 
OpenType spec everytime I want to use cool features of San Francisco. ;)

Thanks again everyone.

Doug Hil
___

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: Vertically Centered Colon

2016-12-01 Thread Alastair Houghton
On 1 Dec 2016, at 19:05, Doug Hill  wrote:
> 
> Just made another breakthrough. I finally figured out why we have the 
> vertically centerd colon (I’ll now call it VCC) by default but has 
> requirements of numbers on either side of the colon.
> The SF font setting is “Contextual Alternatives” (I’ll now call it CA). When 
> CA is on, it will use the logic of numbers on either side of a colon to get 
> VCC. Turning off CA turns off this logic and no VCC. But even if CA is on, 
> and you have a character stream that isn’t :, you can turn on 
> VCC explicitly with it’s own selector to get that behavior.
> 
> Other than VCC I’m not sure what other contextual alternatives there are. 
> Fractions didn’t seem to do anything differently.

I think we’ve headed off topic somewhat, so this is likely my final word on the 
subject.  Contextual alternates’ usual abbreviation is “calt” (which is its 
OpenType tag).  It might also, at this point, be worth pointing you at the 
OpenType specification

  https://www.microsoft.com/en-us/Typography/OpenTypeSpecification.aspx

and in particular the registered features page:

  https://www.microsoft.com/typography/otspec/featurelist.htm

The pages on advanced layout may also be informative.

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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: Vertically Centered Colon

2016-12-01 Thread Doug Hill

> On Dec 1, 2016, at 8:17 AM, Doug Hill  wrote:
> 
>> On Dec 1, 2016, at 12:58 AM, Alastair Houghton 
>>  wrote:
>> 
>> Agreed.  At the very least it needs to explicitly document the set of 
>> stylistic alternates for the SF font family so that we know what they all do 
>> (it looks like there might be more than in your document too; I can’t think 
>> of a reason for using one, two, three and then seven without also using 
>> four, five and six).
> 
> Alastair,
> 
> At the time I wrote that document, I only had time to figure out a few of the 
> selectors. I have since found out #6 (“High Legibility”). According to the 
> Mac Font Panel, #4 is “Stylistic Set 4”, whatever that is. #5 appears to do 
> nothing, AFAICT.

Just made another breakthrough. I finally figured out why we have the 
vertically centerd colon (I’ll now call it VCC) by default but has requirements 
of numbers on either side of the colon.
The SF font setting is “Contextual Alternatives” (I’ll now call it CA). When CA 
is on, it will use the logic of numbers on either side of a colon to get VCC. 
Turning off CA turns off this logic and no VCC. But even if CA is on, and you 
have a character stream that isn’t :, you can turn on VCC 
explicitly with it’s own selector to get that behavior.

Other than VCC I’m not sure what other contextual alternatives there are. 
Fractions didn’t seem to do anything differently.

Also, when Apple says VCC is on by default in the SDKs, I think they mean CA is 
on by default.

Anyways, this selector is in my SF Font code here:

https://github.com/djfitz/SFFontFeatures 


Doug Hill
___

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: Vertically Centered Colon

2016-12-01 Thread Doug Hill

> On Dec 1, 2016, at 8:07 AM, Alastair Houghton  
> wrote:
> 
> On 1 Dec 2016, at 15:57, Alex Zavatone  wrote:
>> 
>> If we are able to do it right, then we don't have to worry about waiting for 
>> it or aren't put behind an 8 ball if Apple decides to pull the rug out from 
>> under us if it decides to change the feature (which happens).
>> 
>> With these features in text styling, we have all the metrics that we need 
>> and as long as the font we want to use supports what we want, these features 
>> can be implemented without waiting for someone else to do it for us.
> 
> Up to a point.  Sometimes there is special support in a font for some 
> particular feature, which will provide better results than naïvely moving or 
> scaling a glyph.  A case in point is small caps; you can simulate small caps 
> by using capitals from a smaller point size, but doing so will affect the 
> weight of the strokes.  Dedicated small caps support tends to look a lot 
> better — the stroke weight will match, but also sometimes changes are made to 
> the glyphs to better fit into the available space and/or to better align with 
> other characters in the font.
> 
> Vertically centring a colon is towards the simpler end of things and should 
> be doable “by hand”, though there might still be gotchas with some fonts 
> (e.g. where digits are not the same height as capital letters or where “old 
> style” digits are in use).

Indeed, while knowing how to achieve typographic effects on any font can be 
very desirable, the system font is a very special case. Apple has tried to 
bring these typographic affects to a wider developer audience by including them 
in the font itself, and has actively encouraged developers to use these 
features. While the usage is a bit clunky right now due to primitive 
interfaces, I believe it will get easier with time. Additionally, as mentioned, 
the quality of the typographic effects should be quite good, as mentioned 
above. For example, the setting for “High Legibility” encompasses a lot of 
features (change many glyph forms, change tracking, etc.) that probably would 
be a pain to achive manually. Also, Apple did a lot of research into what makes 
things more legible and will probably improve this in the future.

With so many easy to use features available, Apple has done the developer 
community a big favor. My guess is that these features will be supported for 
some time, as they are used by many Apple apps, and Apple has publicly 
encouraged developers to use them as well.

Doug Hill




___

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: Vertically Centered Colon

2016-12-01 Thread Doug Hill

> On Dec 1, 2016, at 12:58 AM, Alastair Houghton  
> wrote:
> 
> On 30 Nov 2016, at 18:33, Doug Hill  > wrote:
>> 
>> Still hoping Apple will make SF font specific features part of the SDK.
> 
> Agreed.  At the very least it needs to explicitly document the set of 
> stylistic alternates for the SF font family so that we know what they all do 
> (it looks like there might be more than in your document too; I can’t think 
> of a reason for using one, two, three and then seven without also using four, 
> five and six).

Alastair,

At the time I wrote that document, I only had time to figure out a few of the 
selectors. I have since found out #6 (“High Legibility”). According to the Mac 
Font Panel, #4 is “Stylistic Set 4”, whatever that is. #5 appears to do 
nothing, AFAICT.

Also, I finally got time to collect the work I’ve done and make a convenience 
class to use these San Francisco font features. See here:

https://github.com/djfitz/SFFontFeatures 


I can’t guarantee that anything will work, or if there are other features I’m 
missing. For now, I have support for 11 features:

• Straight-sided six and nine
• Open Four
• Vertically centered colon
• High Legibility
• One Storey a
• Upper Case Small Capitals
• Lower Case Small Capitals
• Contextual Fractional Forms
• Monospaced/Proportional Numbers
• Superiors/Superscripts
• Inferiors/Subscripts

Feel free to try this out, and let me know if things work for you.

Doug Hill
___

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: Vertically Centered Colon

2016-12-01 Thread Alastair Houghton
On 1 Dec 2016, at 15:57, Alex Zavatone  wrote:
> 
> If we are able to do it right, then we don't have to worry about waiting for 
> it or aren't put behind an 8 ball if Apple decides to pull the rug out from 
> under us if it decides to change the feature (which happens).
> 
> With these features in text styling, we have all the metrics that we need and 
> as long as the font we want to use supports what we want, these features can 
> be implemented without waiting for someone else to do it for us.

Up to a point.  Sometimes there is special support in a font for some 
particular feature, which will provide better results than naïvely moving or 
scaling a glyph.  A case in point is small caps; you can simulate small caps by 
using capitals from a smaller point size, but doing so will affect the weight 
of the strokes.  Dedicated small caps support tends to look a lot better — the 
stroke weight will match, but also sometimes changes are made to the glyphs to 
better fit into the available space and/or to better align with other 
characters in the font.

Vertically centring a colon is towards the simpler end of things and should be 
doable “by hand”, though there might still be gotchas with some fonts (e.g. 
where digits are not the same height as capital letters or where “old style” 
digits are in use).

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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: Vertically Centered Colon

2016-12-01 Thread Alex Zavatone

On Dec 1, 2016, at 2:58 AM, Alastair Houghton wrote:

> On 30 Nov 2016, at 18:33, Doug Hill  wrote:
>> 
>>> On Nov 29, 2016, at 11:06 PM, Alex Zavatone  wrote:
>>> 
>>> On Nov 30, 2016, at 12:10 AM, Doug Hill wrote:
>>> 
 After some trial and error, I figured out how to accomplish the San 
 Francisco font features described below. I updated my document to include 
 the code to turn on each feature.
 
 http://breaqz.com/font/AlternateStylisticForms.pdf 
 
 
 I should make a sample app or blog post but time doesn’t permit at the 
 moment. Hope this all helps!
 
 Doug Hill
>>> 
>>> This doc might help
>>> https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html
>>>  
>>> 
>> 
>> A lot of good stuff there. It appears to be some documentation for what's in 
>> SFNTLayoutTypes.h which is helpful.
>> However, all the alternate stylistic forms are still numbered selectors so 
>> not a lot of new information.
> 
> The problem with the alternate stylistic forms (“salt”) feature is that there 
> are twenty sets and they’re only defined by a number.  Moreover, they’re font 
> specific (or, more accurately, typeface specific, because they’re encoded 
> separately in each OpenType font file).  Hopefully Apple will document the 
> stylistic alternates in question and won’t change them, but until and unless 
> they do, using them is slightly risky.  (I think there’s a good chance they 
> won’t change them, as they probably do the same thing in their own code, but 
> I’d rather see them explicitly documented.)
> 
>> Still hoping Apple will make SF font specific features part of the SDK.
> 
> Agreed.  At the very least it needs to explicitly document the set of 
> stylistic alternates for the SF font family so that we know what they all do 
> (it looks like there might be more than in your document too; I can’t think 
> of a reason for using one, two, three and then seven without also using four, 
> five and six).
> 
> Kind regards,
> 
> Alastair.

As we found out with the graphics we require (gears), there are cases like 
these where we discover something new and simply have to do it ourselves.  

With Attributed Text on iOS, there was no supplied superscripting ability, so I 
created formatting methods to do so that were based on a % of the font size 
above the baseline so that you can always get good results.  

After adding superscript, for numerical display of text, I added auto 
superscripting of symbols like ®, and support for proper display of currency.  
We can get displays like this

http://i.imgur.com/Fu1IQgK.png
http://i.imgur.com/WoTGgNE.png

And this

http://i.imgur.com/n7VPeL3.png
http://i.imgur.com/vaQOb9s.png


If we are able to do it right, then we don't have to worry about waiting for it 
or aren't put behind an 8 ball if Apple decides to pull the rug out from under 
us if it decides to change the feature (which happens).

With these features in text styling, we have all the metrics that we need and 
as long as the font we want to use supports what we want, these features can be 
implemented without waiting for someone else to do it for us.

Alex Zavatone
___

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: Vertically Centered Colon

2016-12-01 Thread Alastair Houghton
On 30 Nov 2016, at 18:33, Doug Hill  wrote:
> 
>> On Nov 29, 2016, at 11:06 PM, Alex Zavatone  wrote:
>> 
>> On Nov 30, 2016, at 12:10 AM, Doug Hill wrote:
>> 
>>> After some trial and error, I figured out how to accomplish the San 
>>> Francisco font features described below. I updated my document to include 
>>> the code to turn on each feature.
>>> 
>>> http://breaqz.com/font/AlternateStylisticForms.pdf 
>>> 
>>> 
>>> I should make a sample app or blog post but time doesn’t permit at the 
>>> moment. Hope this all helps!
>>> 
>>> Doug Hill
>> 
>> This doc might help
>> https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html
>>  
>> 
> 
> A lot of good stuff there. It appears to be some documentation for what's in 
> SFNTLayoutTypes.h which is helpful.
> However, all the alternate stylistic forms are still numbered selectors so 
> not a lot of new information.

The problem with the alternate stylistic forms (“salt”) feature is that there 
are twenty sets and they’re only defined by a number.  Moreover, they’re font 
specific (or, more accurately, typeface specific, because they’re encoded 
separately in each OpenType font file).  Hopefully Apple will document the 
stylistic alternates in question and won’t change them, but until and unless 
they do, using them is slightly risky.  (I think there’s a good chance they 
won’t change them, as they probably do the same thing in their own code, but 
I’d rather see them explicitly documented.)

> Still hoping Apple will make SF font specific features part of the SDK.

Agreed.  At the very least it needs to explicitly document the set of stylistic 
alternates for the SF font family so that we know what they all do (it looks 
like there might be more than in your document too; I can’t think of a reason 
for using one, two, three and then seven without also using four, five and six).

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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: Vertically Centered Colon

2016-11-30 Thread Doug Hill

> On Nov 29, 2016, at 11:06 PM, Alex Zavatone  wrote:
> 
> 
> On Nov 30, 2016, at 12:10 AM, Doug Hill wrote:
> 
>> After some trial and error, I figured out how to accomplish the San 
>> Francisco font features described below. I updated my document to include 
>> the code to turn on each feature.
>> 
>> http://breaqz.com/font/AlternateStylisticForms.pdf 
>> 
>> 
>> I should make a sample app or blog post but time doesn’t permit at the 
>> moment. Hope this all helps!
>> 
>> Doug Hill
> 
> This doc might help
> https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html
>  
> 

A lot of good stuff there. It appears to be some documentation for what's in 
SFNTLayoutTypes.h which is helpful.
However, all the alternate stylistic forms are still numbered selectors so not 
a lot of new information.

Still hoping Apple will make SF font specific features part of the SDK.

Doug
___

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: Vertically Centered Colon

2016-11-29 Thread Alex Zavatone

On Nov 30, 2016, at 12:10 AM, Doug Hill wrote:

> After some trial and error, I figured out how to accomplish the San Francisco 
> font features described below. I updated my document to include the code to 
> turn on each feature.
> 
> http://breaqz.com/font/AlternateStylisticForms.pdf
> 
> I should make a sample app or blog post but time doesn’t permit at the 
> moment. Hope this all helps!
> 
> Doug Hill

This doc might help
https://developer.apple.com/fonts/TrueType-Reference-Manual/RM09/AppendixF.html

> 
> 
>> On Nov 29, 2016, at 9:38 AM, Doug Hill  wrote:
>> 
>> I suppose if I have some time I’ll try them out and see if I can do my own 
>> documentation. For reference, here are a few different forms that I was able 
>> to create with TextEdit:
>> 
>> http://breaqz.com/font/AlternateStylisticForms.pdf
>> 
>> This includes examples of the following:
>> 
>> • Vertically centered colon
>> • Straight-sided six and nine
>> • Open Four
>> • One storev a (e.g. alternate lowercase ‘a’ form)
>> • Small Capitals
>> • Contextual Fractional Forms (fractional form for any fraction)
> 
> 
> ___
> 
> 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

Re: Vertically Centered Colon

2016-11-29 Thread Doug Hill
After some trial and error, I figured out how to accomplish the San Francisco 
font features described below. I updated my document to include the code to 
turn on each feature.

http://breaqz.com/font/AlternateStylisticForms.pdf

 I should make a sample app or blog post but time doesn’t permit at the moment. 
Hope this all helps!

Doug Hill


> On Nov 29, 2016, at 9:38 AM, Doug Hill  wrote:
> 
> I suppose if I have some time I’ll try them out and see if I can do my own 
> documentation. For reference, here are a few different forms that I was able 
> to create with TextEdit:
> 
> http://breaqz.com/font/AlternateStylisticForms.pdf
> 
> This includes examples of the following:
> 
> • Vertically centered colon
> • Straight-sided six and nine
> • Open Four
> • One storev a (e.g. alternate lowercase ‘a’ form)
> • Small Capitals
> • Contextual Fractional Forms (fractional form for any fraction)


___

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: Vertically Centered Colon

2016-11-29 Thread Doug Hill

> On Nov 29, 2016, at 3:58 PM, Rick Mann  wrote:
> 
> 
>> On Nov 29, 2016, at 09:38 , Doug Hill  wrote:
>> 
>> Wow, it's awesome that this works! And now that I know how to set these 
>> attributes for a UILabel, I might try using some other features of SF font, 
>> such as contextual fractional forms for any fraction.
> 
> Oh, wow, contextual fractional forms! This is *perfect* for the app I'm 
> working on currently.
> 
> I'm late to this thread. Does this stuff only work for attributed strings?

I believe you can use [UIFont fontWithDescriptor:size] with a non-attributed 
string but if you want to mix font styles in a single string, then you need 
attributed.

> Do I apply the alternate form attribute to the string "99/100" in order to 
> get the fractional form?

It would appear that you need to apply this style to a character sequence of: a 
multi-digit number followed by a ‘/‘ then another multi-digit number.

Good luck!

Doug
___

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: Vertically Centered Colon

2016-11-29 Thread Gerriet M. Denkmann

> On 30 Nov 2016, at 09:18, Doug Hill  wrote:
> 
> 
>> On Nov 29, 2016, at 3:58 PM, Rick Mann  wrote:
>> 
>> 
>>> On Nov 29, 2016, at 09:38 , Doug Hill  wrote:
>>> 
>>> Wow, it's awesome that this works! And now that I know how to set these 
>>> attributes for a UILabel, I might try using some other features of SF font, 
>>> such as contextual fractional forms for any fraction.
>> 
>> Oh, wow, contextual fractional forms! This is *perfect* for the app I'm 
>> working on currently.
>> 
>> I'm late to this thread. Does this stuff only work for attributed strings?
> 
> I believe you can use [UIFont fontWithDescriptor:size] with a non-attributed 
> string but if you want to mix font styles in a single string, then you need 
> attributed.

I just tried:

someLabel.font = fontVariationWithCenteredColons;
someLabel.text = @“abc:xyz”;

and it works.

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: Vertically Centered Colon

2016-11-29 Thread Rick Mann

> On Nov 29, 2016, at 09:38 , Doug Hill  wrote:
> 
> Wow, it's awesome that this works! And now that I know how to set these 
> attributes for a UILabel, I might try using some other features of SF font, 
> such as contextual fractional forms for any fraction.

Oh, wow, contextual fractional forms! This is *perfect* for the app I'm working 
on currently.

I'm late to this thread. Does this stuff only work for attributed strings? Do I 
apply the alternate form attribute to the string "99/100" in order to get the 
fractional form?

Thanks!


-- 
Rick Mann
rm...@latencyzero.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

Re: Vertically Centered Colon

2016-11-29 Thread Doug Hill

> On Nov 29, 2016, at 10:04 AM, Quincey Morris 
>  wrote:
> 
> On Nov 29, 2016, at 09:38 , Doug Hill  > wrote:
>> 
>> But seriously, why didn’t Apple document what those stylistic alernative 
>> type attribute constants are? Are they supposed to change? Did they not know 
>> what they correspond to when creating the header? Did they not expect that 
>> developers would use this feature?
> 
> My guess is because there aren’t any definitions, but these are instead 
> optional font-specific features with generic identifications. And, lo and 
> behold, when I went to check on this:
> 
>   
> en.wikipedia.org/wiki/List_of_typographic_features#OpenType_typographic_features
>  
> 
> 
> there they are [well, I presume this is them] under the heading “Ligation and 
> alternate forms features intended for all scripts” as “Stylistic Set 1 – 20”. 
> Indeed, if you look at the example of Stylistic Set 04 here:
> 
>   ilovetypography.com/OpenType/opentype-features.html 
> 
> 
> it even looks like the meaning of the set is somehow defined within the font.
> 
> (Note that there appear to be “stylistic alternates”, and “stylistic sets” 
> which are a specific kind of stylistic alternate, so the whole system seems 
> more complicated than I was able to grasp in 5 minutes of searching.)
> 
> I’m ready to stand corrected, but — unless there’s a separate registry or 
> convention on what the sets mean — this appears to me to indicate that the 
> centered colon may only work for SF and perhaps a set of other Apple-tweaked 
> fonts that are intended to have the same behavior.

Indeed many of these features are likely SF font specific. However, these 
features are known to Apple’s developers. For example, check out the Typography 
settings of a font in the Macintosh Font Panel. It knows which features are 
available for any font and shows their name when switching fonts. So the 
mapping between OpenType setting and SF font feature is known somewhere, but 
not to SDK users.

But thanks for the links, very good info which I don’t understand all of it 
either. You can go down this font rat-hole as far as you want; I don’t think it 
ever ends. :)

Doug
___

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: Vertically Centered Colon

2016-11-29 Thread Quincey Morris
On Nov 29, 2016, at 09:38 , Doug Hill  wrote:
> 
> But seriously, why didn’t Apple document what those stylistic alernative type 
> attribute constants are? Are they supposed to change? Did they not know what 
> they correspond to when creating the header? Did they not expect that 
> developers would use this feature?

My guess is because there aren’t any definitions, but these are instead 
optional font-specific features with generic identifications. And, lo and 
behold, when I went to check on this:


en.wikipedia.org/wiki/List_of_typographic_features#OpenType_typographic_features
 


there they are [well, I presume this is them] under the heading “Ligation and 
alternate forms features intended for all scripts” as “Stylistic Set 1 – 20”. 
Indeed, if you look at the example of Stylistic Set 04 here:

ilovetypography.com/OpenType/opentype-features.html

it even looks like the meaning of the set is somehow defined within the font.

(Note that there appear to be “stylistic alternates”, and “stylistic sets” 
which are a specific kind of stylistic alternate, so the whole system seems 
more complicated than I was able to grasp in 5 minutes of searching.)

I’m ready to stand corrected, but — unless there’s a separate registry or 
convention on what the sets mean — this appears to me to indicate that the 
centered colon may only work for SF and perhaps a set of other Apple-tweaked 
fonts that are intended to have the same behavior.
___

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: Vertically Centered Colon

2016-11-29 Thread Doug Hill

> On Nov 29, 2016, at 1:33 AM, Gerriet M. Denkmann  wrote:
> 
>> On 29 Nov 2016, at 03:33, Doug Hill  wrote:
>> 
>> A little experimentation might find the right one.

> 
> A “little” is kind of misleading. There are about 40 features, with up to 20 
> alternatives each.
> 
> …
> After you kindly mentioned kStylisticAlternativesType I started to try this. 
> The documentation is quite helpful in mentioning that some flag “Turns the 
> nth set of alternates on or off” for n = 1 … 20.
> 
> And luckily kStylisticAltThreeOnSelector does indeed turn centred colons on.

Wow, it's awesome that this works! And now that I know how to set these 
attributes for a UILabel, I might try using some other features of SF font, 
such as contextual fractional forms for any fraction.

But seriously, why didn’t Apple document what those stylistic alernative type 
attribute constants are? Are they supposed to change? Did they not know what 
they correspond to when creating the header? Did they not expect that 
developers would use this feature?
I suppose if I have some time I’ll try them out and see if I can do my own 
documentation. For reference, here are a few different forms that I was able to 
create with TextEdit:

http://breaqz.com/font/AlternateStylisticForms.pdf

This includes examples of the following:

• Vertically centered colon
• Straight-sided six and nine
• Open Four
• One storev a (e.g. alternate lowercase ‘a’ form)
• Small Capitals
• Contextual Fractional Forms (fractional form for any fraction)
• Monospaced Numbers

Doug Hill


___

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: Vertically Centered Colon

2016-11-29 Thread Gerriet M. Denkmann

> On 29 Nov 2016, at 00:40, Quincey Morris 
>  wrote:
> 
> On Nov 28, 2016, at 07:01 , Gerriet M. Denkmann  wrote:
>> 
>> But in my case I have “21:37:44” where ““21:37” is bold and “:44” is thin.
> 
> 
> c.  Given that you work so much with non-Latin scripts, I find it surprising 
> that you would make assumptions about how a time is represented. (Again, of 
> course, you may have decided this is the correct approach for your scenario, 
> but it strikes me as worth commenting on.)

I just checked all 739 locales available in iOS. The time format is pretty 
consistent:
“H.mm.ss"
"H:mm.ss”
“HH.mm.ss"
“H:mm:ss"
“HH:mm:ss” (more than 89% use this)

all should be displayed correctly.
Those locales which use ‘:’ will see a nice vertically centered colon, those 
with ‘.’ a non-centered FULL STOP.

Thanks to alerting me to this issue (my old code assumed two digit hours, which 
would not have worked in about 55 locales).

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: Vertically Centered Colon

2016-11-29 Thread Gerriet M. Denkmann

> On 29 Nov 2016, at 03:33, Doug Hill  wrote:
> 
> A couple of things to note:
> 
[…]
> In any case it's a bad idea to select the exact font since you have to choose 
> SF Display or Text which you don't want to do. It should be dynamically 
> selected at runtime based on the font size. This behavior is supported by 
> using System Font.
> 
> Anyways, I would check the font at runtime to make sure it’s SF.

thinFont =   font-family: “.SFUIDisplay-Ultralight"; font-weight: 
normal; font-style: normal; font-size: 70.00pt

> Otherwise, you need a font that supports the Vertically Centered Colon font 
> feature. You can check this feature by doing the following:
> • Select your desired font on your Mac for the attributed string in the font 
> panel
> • Click the Gear icon in the upper-left corner.
> • Select Typography…
> • Select 'Alternative Stylistic Sets'
> • Select ‘Vertically Centered Colon'

Well, this is kind of difficult: the Font Panel does not show fonts which have 
names which start with ‘.’.
So: no SF fonts in my Font Panel.



> Furthermore, I don’t see a way to set these  'Alternative Stylistic' 
> attributes from UIAttributedText.

Can be done like this:

NSDictionary *featureCenteredColon = @{ UIFontFeatureTypeIdentifierKey: 
@(kStylisticAlternativesType), 

UIFontFeatureSelectorIdentifierKey: @(kStylisticAltThreeOnSelector)
  };
NSArray *featureArray = @[ featureCenteredColon ];
NSDictionary *featureAtribute = @{ UIFontDescriptorFeatureSettingsAttribute: 
featureArray };

UIFontDescriptor *thinDescriptor = thinFont.fontDescriptor;
UIFontDescriptor *newDescr = [ thinDescriptor fontDescriptorByAddingAttributes: 
featureAtribute ];
UIFont *betterThinFont = [ UIFont fontWithDescriptor: newDescr  size: pointSize 
];



> A little experimentation might find the right one.

A “little” is kind of misleading. There are about 40 features, with up to 20 
alternatives each.


> OK, after doing some tests, UILabel indeed behaves like you mentioned with 
> the SF font. If there aren't numbers on either side of the colon, no vertical 
> centering. My guess would see if you can attempt to set the 
> kStylisticAlternativesType attribute, as noted below, but as previously 
> mentioned, will probably not work automatically due to the different fonts 
> for the numerals around the colon.
> 
> At this point, I’d say your working solution is probably as good as you're 
> going to get.

After you kindly mentioned kStylisticAlternativesType I started to try this. 
The documentation is quite helpful in mentioning that some flag “Turns the nth 
set of alternates on or off” for n = 1 … 20.

And luckily kStylisticAltThreeOnSelector does indeed turn centred colons on.

So now I have two working solutions: 
1. getting the special glyph for the centered colon (as suggested by Alistair) 
and:
2. using kStylisticAltThreeOnSelector (as suggested by you).

Thanks a lot. The hint of “kStylisticAlternativesType” was extremely helpful!

Kind regards,

Gerriet.


> 
> 
>> On Nov 28, 2016, at 11:12 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> 
>>> On 28 Nov 2016, at 23:42, Alastair Houghton  
>>> wrote:
>>> 
>>> On 28 Nov 2016, at 16:18, Gerriet M. Denkmann  wrote:
 
 
> On 28 Nov 2016, at 22:13, Eric E. Dolecki  wrote:
> 
> You could probably use an attributed string and add an attribute for the 
> last colon: NSBaselineOffsetAttributeName
 
 Yes; but this would be some rather desperate work-around.
 
 I was rather thinking of UIFontDescriptorFeatureSettingsAttribute with 
 some Feature type from SFNTLayoutTypes.h (in CoreText).
 I tried a few types, but no success so far.
>>> 
>>> The problem you’ve got is that unless the font has a feature that 
>>> specifically allows you to change *any* colon (as opposed to a colon 
>>> between two numerals), you aren’t going to be able to do it by turning on 
>>> an OpenType feature.  Even if you can, there doesn’t appear to be a 
>>> standard feature code for this, so you’d be reliant on Apple not changing 
>>> it in the future.
>> 
>> The WWDC 2015 talk seemed to suggest that there is a standard feature for 
>> this.
>> But there are about 40 feature types in SFNTLayoutTypes.h - no idea what to 
>> use.
>> 
>> 
>>> What you *could* do instead is get Core Text (or Cocoa Text) to lay out a 
>>> string e.g. “12:00”, then grab the glyph for the centred colon directly 
>>> from that string and use it explicitly, e.g. by attaching a 
>>> kCTGlyphInfoAttributeName attribute to your string with the value set to an 
>>> appropriately constructed CTGlyphInfoRef.
>> 
>> done once:
>> 
>> CGRect frame = { {0,0},{99,99}}; 
>> UITextView *dummyTextView = [ [UITextView alloc] 

Re: Vertically Centered Colon

2016-11-28 Thread Doug Hill
OK, after doing some tests, UILabel indeed behaves like you mentioned with the 
SF font. If there aren't numbers on either side of the colon, no vertical 
centering. My guess would see if you can attempt to set the 
kStylisticAlternativesType attribute, as noted below, but as previously 
mentioned, will probably not work automatically due to the different fonts for 
the numerals around the colon.

At this point, I'd say your working solution is probably as good as you're 
going to get.

Doug Hill


> On Nov 28, 2016, at 12:33 PM, Doug Hill  wrote:
> 
> A couple of things to note:
> 
> 1. In the SF font, colons are vertically centered by default.
> You can test this by creating a plain UILabel with System Font in IB and type 
> a time e.g. 10:20, and notice the colon is vertically centered. So if you use 
> SF font, you don't have to do anything to get the centered colon feature.
> 
> 2. The font for UILabel with an attributed string 'text' property appears NOT 
> to be SF font (e.g. System Font) by default.
> Again, to test this create a UILabel in IB and change Text to an attributed 
> string, notice that the font changes to Helvetica Neue. I also notice that SF 
> font doesn't show up in the list of fonts in IB for this label. FWIW, I'm 
> still using Xcode 7.x so someone should try Xcode 8 to verify if this is 
> still the case.
> For the heck of it I installed SF font on my Mac so I can select it in the 
> attributed text font list, but notice a bunch of bugs. For example, the font 
> size I set in IB for the attributed text is ignored. At runtime it's probably 
> 12 or 14 pt. Also, in IB, if you edit the text by double-clicking in the 
> label, you'll see an input field for large text but nothing shown. Oh well, 
> another trip to RADAR.
> In any case it's a bad idea to select the exact font since you have to choose 
> SF Display or Text which you don't want to do. It should be dynamically 
> selected at runtime based on the font size. This behavior is supported by 
> using System Font.
> 
> Anyways, I would check the font at runtime to make sure it's SF. Otherwise, 
> you need a font that supports the Vertically Centered Colon font feature. You 
> can check this feature by doing the following:
> • Select your desired font on your Mac for the attributed string in the font 
> panel
> • Click the Gear icon in the upper-left corner.
> • Select Typography…
> • Select 'Alternative Stylistic Sets'
> • Select 'Vertically Centered Colon'
> 
> Which Helvetica Neue DOES NOT support.
> 
> Furthermore, I don't see a way to set these  'Alternative Stylistic' 
> attributes from UIAttributedText. I do see some settings in 
> CoreText/SFNTLayoutTypes.h under kStylisticAlternativesType. But the settings 
> are just numbered so I don't know which it might be. A little experimentation 
> might find the right one.
> 
> But in summary, if you are using SF font, you don't need to set the 
> Vertically Centered Colon attribute as it should be on by default.
> 
> Doug Hill
> 
> 
> 
>> On Nov 28, 2016, at 11:12 AM, Gerriet M. Denkmann  
>> wrote:
>> 
>> 
>>> On 28 Nov 2016, at 23:42, Alastair Houghton  
>>> wrote:
>>> 
>>> On 28 Nov 2016, at 16:18, Gerriet M. Denkmann  wrote:
 
 
> On 28 Nov 2016, at 22:13, Eric E. Dolecki  wrote:
> 
> You could probably use an attributed string and add an attribute for the 
> last colon: NSBaselineOffsetAttributeName
 
 Yes; but this would be some rather desperate work-around.
 
 I was rather thinking of UIFontDescriptorFeatureSettingsAttribute with 
 some Feature type from SFNTLayoutTypes.h (in CoreText).
 I tried a few types, but no success so far.
>>> 
>>> The problem you’ve got is that unless the font has a feature that 
>>> specifically allows you to change *any* colon (as opposed to a colon 
>>> between two numerals), you aren’t going to be able to do it by turning on 
>>> an OpenType feature.  Even if you can, there doesn’t appear to be a 
>>> standard feature code for this, so you’d be reliant on Apple not changing 
>>> it in the future.
>> 
>> The WWDC 2015 talk seemed to suggest that there is a standard feature for 
>> this.
>> But there are about 40 feature types in SFNTLayoutTypes.h - no idea what to 
>> use.
>> 
>> 
>>> What you *could* do instead is get Core Text (or Cocoa Text) to lay out a 
>>> string e.g. “12:00”, then grab the glyph for the centred colon directly 
>>> from that string and use it explicitly, e.g. by attaching a 
>>> kCTGlyphInfoAttributeName attribute to your string with the value set to an 
>>> appropriately constructed CTGlyphInfoRef.
>> 
>> done once:
>> 
>> CGRect frame = { {0,0},{99,99}}; 
>> UITextView *dummyTextView = [ [UITextView alloc] initWithFrame: frame 
>> textContainer: nil ];
>> dummyTextView.text = @“23:21”;
>> dummyTextView.font = thinFont;
>> NSLayoutManager *layoutManager = 

Re: Vertically Centered Colon

2016-11-28 Thread Doug Hill
A couple of things to note:

1. In the SF font, colons are vertically centered by default.
You can test this by creating a plain UILabel with System Font in IB and type a 
time e.g. 10:20, and notice the colon is vertically centered. So if you use SF 
font, you don't have to do anything to get the centered colon feature.

2. The font for UILabel with an attributed string 'text' property appears NOT 
to be SF font (e.g. System Font) by default.
Again, to test this create a UILabel in IB and change Text to an attributed 
string, notice that the font changes to Helvetica Neue. I also notice that SF 
font doesn't show up in the list of fonts in IB for this label. FWIW, I'm still 
using Xcode 7.x so someone should try Xcode 8 to verify if this is still the 
case.
For the heck of it I installed SF font on my Mac so I can select it in the 
attributed text font list, but notice a bunch of bugs. For example, the font 
size I set in IB for the attributed text is ignored. At runtime it's probably 
12 or 14 pt. Also, in IB, if you edit the text by double-clicking in the label, 
you'll see an input field for large text but nothing shown. Oh well, another 
trip to RADAR.
In any case it's a bad idea to select the exact font since you have to choose 
SF Display or Text which you don't want to do. It should be dynamically 
selected at runtime based on the font size. This behavior is supported by using 
System Font.

Anyways, I would check the font at runtime to make sure it's SF. Otherwise, you 
need a font that supports the Vertically Centered Colon font feature. You can 
check this feature by doing the following:
• Select your desired font on your Mac for the attributed string in the font 
panel
• Click the Gear icon in the upper-left corner.
• Select Typography…
• Select 'Alternative Stylistic Sets'
• Select 'Vertically Centered Colon'

Which Helvetica Neue DOES NOT support.

Furthermore, I don't see a way to set these  'Alternative Stylistic' attributes 
from UIAttributedText. I do see some settings in CoreText/SFNTLayoutTypes.h 
under kStylisticAlternativesType. But the settings are just numbered so I don't 
know which it might be. A little experimentation might find the right one.

But in summary, if you are using SF font, you don't need to set the Vertically 
Centered Colon attribute as it should be on by default.

Doug Hill



> On Nov 28, 2016, at 11:12 AM, Gerriet M. Denkmann  wrote:
> 
> 
>> On 28 Nov 2016, at 23:42, Alastair Houghton  
>> wrote:
>> 
>> On 28 Nov 2016, at 16:18, Gerriet M. Denkmann  wrote:
>>> 
>>> 
 On 28 Nov 2016, at 22:13, Eric E. Dolecki  wrote:
 
 You could probably use an attributed string and add an attribute for the 
 last colon: NSBaselineOffsetAttributeName
>>> 
>>> Yes; but this would be some rather desperate work-around.
>>> 
>>> I was rather thinking of UIFontDescriptorFeatureSettingsAttribute with some 
>>> Feature type from SFNTLayoutTypes.h (in CoreText).
>>> I tried a few types, but no success so far.
>> 
>> The problem you’ve got is that unless the font has a feature that 
>> specifically allows you to change *any* colon (as opposed to a colon between 
>> two numerals), you aren’t going to be able to do it by turning on an 
>> OpenType feature.  Even if you can, there doesn’t appear to be a standard 
>> feature code for this, so you’d be reliant on Apple not changing it in the 
>> future.
> 
> The WWDC 2015 talk seemed to suggest that there is a standard feature for 
> this.
> But there are about 40 feature types in SFNTLayoutTypes.h - no idea what to 
> use.
> 
> 
>> What you *could* do instead is get Core Text (or Cocoa Text) to lay out a 
>> string e.g. “12:00”, then grab the glyph for the centred colon directly from 
>> that string and use it explicitly, e.g. by attaching a 
>> kCTGlyphInfoAttributeName attribute to your string with the value set to an 
>> appropriately constructed CTGlyphInfoRef.
> 
> done once:
> 
> CGRect frame = { {0,0},{99,99}};  
> UITextView *dummyTextView = [ [UITextView alloc] initWithFrame: frame 
> textContainer: nil ];
> dummyTextView.text = @“23:21”;
> dummyTextView.font = thinFont;
> NSLayoutManager *layoutManager = dummyTextView.layoutManager;
> [ layoutManager ensureGlyphsForCharacterRange: range ];
> [ layoutManager ensureLayoutForCharacterRange: range ];
> NSUInteger glyphIndex = [ layoutManager glyphIndexForCharacterAtIndex: 2 ];
> centeredColonGlyph = [ layoutManager CGGlyphAtIndex: glyphIndex ];;
> 
> 
> and then:
> 
> CFMutableAttributedStringRef aStr = (__bridge 
> CFMutableAttributedStringRef)attributedString;
> CTFontRef fontRiff = (__bridge CTFontRef)thinFont;
> CTGlyphInfoRef glyInfRef = CTGlyphInfoCreateWithGlyph( centeredColonGlyph, 
> fontRiff, (CFStringRef)@":" );
> CFRange range = { (CFIndex)colonIndex, 1 };
> CFAttributedStringSetAttribute( aStr, range, kCTGlyphInfoAttributeName, 
> glyInfRef );
> 

Re: Vertically Centered Colon

2016-11-28 Thread Gerriet M. Denkmann

> On 28 Nov 2016, at 23:42, Alastair Houghton  
> wrote:
> 
> On 28 Nov 2016, at 16:18, Gerriet M. Denkmann  wrote:
>> 
>> 
>>> On 28 Nov 2016, at 22:13, Eric E. Dolecki  wrote:
>>> 
>>> You could probably use an attributed string and add an attribute for the 
>>> last colon: NSBaselineOffsetAttributeName
>> 
>> Yes; but this would be some rather desperate work-around.
>> 
>> I was rather thinking of UIFontDescriptorFeatureSettingsAttribute with some 
>> Feature type from SFNTLayoutTypes.h (in CoreText).
>> I tried a few types, but no success so far.
> 
> The problem you’ve got is that unless the font has a feature that 
> specifically allows you to change *any* colon (as opposed to a colon between 
> two numerals), you aren’t going to be able to do it by turning on an OpenType 
> feature.  Even if you can, there doesn’t appear to be a standard feature code 
> for this, so you’d be reliant on Apple not changing it in the future.

The WWDC 2015 talk seemed to suggest that there is a standard feature for this.
But there are about 40 feature types in SFNTLayoutTypes.h - no idea what to use.


> What you *could* do instead is get Core Text (or Cocoa Text) to lay out a 
> string e.g. “12:00”, then grab the glyph for the centred colon directly from 
> that string and use it explicitly, e.g. by attaching a 
> kCTGlyphInfoAttributeName attribute to your string with the value set to an 
> appropriately constructed CTGlyphInfoRef.

done once:

CGRect frame = { {0,0},{99,99}};
UITextView *dummyTextView = [ [UITextView alloc] initWithFrame: frame 
textContainer: nil ];
dummyTextView.text = @“23:21”;
dummyTextView.font = thinFont;
NSLayoutManager *layoutManager = dummyTextView.layoutManager;
[ layoutManager ensureGlyphsForCharacterRange: range ];
[ layoutManager ensureLayoutForCharacterRange: range ];
NSUInteger glyphIndex = [ layoutManager glyphIndexForCharacterAtIndex: 2 ];
centeredColonGlyph = [ layoutManager CGGlyphAtIndex: glyphIndex ];;


and then:

CFMutableAttributedStringRef aStr = (__bridge 
CFMutableAttributedStringRef)attributedString;
CTFontRef fontRiff = (__bridge CTFontRef)thinFont;
CTGlyphInfoRef glyInfRef = CTGlyphInfoCreateWithGlyph( centeredColonGlyph, 
fontRiff, (CFStringRef)@":" );
CFRange range = { (CFIndex)colonIndex, 1 };
CFAttributedStringSetAttribute( aStr, range, kCTGlyphInfoAttributeName, 
glyInfRef );
CFRelease(glyInfRef);

This seems to be working. Nut sure whether there is a more elegant way.

Thanks a lot for your help!


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: Vertically Centered Colon

2016-11-28 Thread Gerriet M. Denkmann

> On 29 Nov 2016, at 00:40, Quincey Morris 
>  wrote:
> 
> On Nov 28, 2016, at 07:01 , Gerriet M. Denkmann  wrote:
>> 
>> But in my case I have “21:37:44” where ““21:37” is bold and “:44” is thin.
> 
> a. Are you using an attributed string whose text is “21:37:44”, or two 
> unattributed strings?

One attributed string, where the first 5 chars have NSFontAttributeName = 
boldFont and the last 3 have
NSFontAttributeName = thinFont.

> b. You have a — I don’t know exactly what to call it — “logical” or 
> “consistency” problem inherent in this situation, because it’s not obvious 
> which font the second “:” should be in. I’m not suggesting you’re incapable 
> of making a decision, but that your actual problem is a consequence of this 
> underlying ambiguity. What would you do if the “:” glyphs were radically 
> different in the two fonts?

UIFont *boldFont = [ UIFont systemFontOfSize: pointSize  weight: 
UIFontWeightLight ];
UIFont *thinFont = [ UIFont systemFontOfSize: pointSize  weight: 
UIFontWeightUltraLight ];

I just assume that the glyphs, coming form the same family, are somewhat 
consistent.

> c. Where does the colon character come from in the first place? Specifically, 
> you’re using a formatted time string, which could be expected to come from 
> (say) a DateFormatter. How do you know there are going to be any colons at 
> all, let alone two of them?

They indeed come from an NSDateFormatter:
timeFormatter = [ [ NSDateFormatter alloc ] init];
timeFormatter.dateFormat = @"HH:mm:ss";  

> Given that you work so much with non-Latin scripts, I find it surprising that 
> you would make assumptions about how a time is represented. (Again, of 
> course, you may have decided this is the correct approach for your scenario, 
> but it strikes me as worth commenting on.)
> 
> What I’m suggesting is that perhaps you should treat this as something like a 
> code smell, and re-evaluate whether changing fonts in the middle of the time 
> string is a good idea.

The effect I am after is: hours and minutes should be emphasized, the seconds 
should not.
Maybe I could use the same font with different colours: black versus light gray 
or something like this.

But right now I am still trying to implement Alistairs suggestion.


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: Vertically Centered Colon

2016-11-28 Thread Alex Zavatone
I have old iOS attributed strong code that explicitly handles superscripting 
specific characters in an NS attributed string from the baseline by a % of the 
character height or by a fixed pixel amount.

Let me know if you want it.

Sent from my iPhone

> On Nov 28, 2016, at 10:42 AM, Alastair Houghton 
>  wrote:
> 
>> On 28 Nov 2016, at 16:18, Gerriet M. Denkmann  wrote:
>> 
>> 
>>> On 28 Nov 2016, at 22:13, Eric E. Dolecki  wrote:
>>> 
>>> You could probably use an attributed string and add an attribute for the 
>>> last colon: NSBaselineOffsetAttributeName
>> 
>> Yes; but this would be some rather desperate work-around.
>> 
>> I was rather thinking of UIFontDescriptorFeatureSettingsAttribute with some 
>> Feature type from SFNTLayoutTypes.h (in CoreText).
>> I tried a few types, but no success so far.
> 
> The problem you’ve got is that unless the font has a feature that 
> specifically allows you to change *any* colon (as opposed to a colon between 
> two numerals), you aren’t going to be able to do it by turning on an OpenType 
> feature.  Even if you can, there doesn’t appear to be a standard feature code 
> for this, so you’d be reliant on Apple not changing it in the future.
> 
> What you *could* do instead is get Core Text (or Cocoa Text) to lay out a 
> string e.g. "12:00”, then grab the glyph for the centred colon directly from 
> that string and use it explicitly, e.g. by attaching a 
> kCTGlyphInfoAttributeName attribute to your string with the value set to an 
> appropriately constructed CTGlyphInfoRef.
> 
> Kind regards,
> 
> Alastair.
> 
> --
> http://alastairs-place.net
> 
> 
> ___
> 
> 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

Re: Vertically Centered Colon

2016-11-28 Thread Quincey Morris
On Nov 28, 2016, at 07:01 , Gerriet M. Denkmann  wrote:
> 
> But in my case I have “21:37:44” where ““21:37” is bold and “:44” is thin.

a. Are you using an attributed string whose text is “21:37:44”, or two 
unattributed strings?

b. You have a — I don’t know exactly what to call it — “logical” or 
“consistency” problem inherent in this situation, because it’s not obvious 
which font the second “:” should be in. I’m not suggesting you’re incapable of 
making a decision, but that your actual problem is a consequence of this 
underlying ambiguity. What would you do if the “:” glyphs were radically 
different in the two fonts?

c. Where does the colon character come from in the first place? Specifically, 
you’re using a formatted time string, which could be expected to come from 
(say) a DateFormatter. How do you know there are going to be any colons at all, 
let alone two of them? Given that you work so much with non-Latin scripts, I 
find it surprising that you would make assumptions about how a time is 
represented. (Again, of course, you may have decided this is the correct 
approach for your scenario, but it strikes me as worth commenting on.)

What I’m suggesting is that perhaps you should treat this as something like a 
code smell, and re-evaluate whether changing fonts in the middle of the time 
string is a good idea.

FWIW.

___

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: Vertically Centered Colon

2016-11-28 Thread Alastair Houghton
On 28 Nov 2016, at 16:18, Gerriet M. Denkmann  wrote:
> 
> 
>> On 28 Nov 2016, at 22:13, Eric E. Dolecki  wrote:
>> 
>> You could probably use an attributed string and add an attribute for the 
>> last colon: NSBaselineOffsetAttributeName
> 
> Yes; but this would be some rather desperate work-around.
> 
> I was rather thinking of UIFontDescriptorFeatureSettingsAttribute with some 
> Feature type from SFNTLayoutTypes.h (in CoreText).
> I tried a few types, but no success so far.

The problem you’ve got is that unless the font has a feature that specifically 
allows you to change *any* colon (as opposed to a colon between two numerals), 
you aren’t going to be able to do it by turning on an OpenType feature.  Even 
if you can, there doesn’t appear to be a standard feature code for this, so 
you’d be reliant on Apple not changing it in the future.

What you *could* do instead is get Core Text (or Cocoa Text) to lay out a 
string e.g. "12:00”, then grab the glyph for the centred colon directly from 
that string and use it explicitly, e.g. by attaching a 
kCTGlyphInfoAttributeName attribute to your string with the value set to an 
appropriately constructed CTGlyphInfoRef.

Kind regards,

Alastair.

--
http://alastairs-place.net


___

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: Vertically Centered Colon

2016-11-28 Thread Gerriet M. Denkmann

> On 28 Nov 2016, at 22:13, Eric E. Dolecki  wrote:
> 
> You could probably use an attributed string and add an attribute for the last 
> colon: NSBaselineOffsetAttributeName

Yes; but this would be some rather desperate work-around.

I was rather thinking of UIFontDescriptorFeatureSettingsAttribute with some 
Feature type from SFNTLayoutTypes.h (in CoreText).
I tried a few types, but no success so far. 

> 
> On Mon, Nov 28, 2016 at 10:02 AM Gerriet M. Denkmann  
> wrote:
> iOS 10.1.1
> 
> WWDC 2015,Session 804: Introducing the New System Fonts tells (at about 
> 23:23) about Vertically Centered Colons.
> But I do not understand, how to turn this on.
> 
> It works automatically (in SF) with colons surrounded by digits.
> 
> But in my case I have “21:37:44” where ““21:37” is bold and “:44” is thin. 
> And the ‘:’ in front of “44” is not surrounded by digits. So I want to turn 
> this feature on explicitly.
> 
> How to do this?
> 
> 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: Vertically Centered Colon

2016-11-28 Thread Eric E. Dolecki
You could probably use an attributed string and add an attribute for the
last colon: NSBaselineOffsetAttributeName

On Mon, Nov 28, 2016 at 10:02 AM Gerriet M. Denkmann 
wrote:

> iOS 10.1.1
>
> WWDC 2015,Session 804: Introducing the New System Fonts tells (at about
> 23:23) about Vertically Centered Colons.
> But I do not understand, how to turn this on.
>
> It works automatically (in SF) with colons surrounded by digits.
>
> But in my case I have “21:37:44” where ““21:37” is bold and “:44” is thin.
> And the ‘:’ in front of “44” is not surrounded by digits. So I want to turn
> this feature on explicitly.
>
> How to do this?
>
> 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/edolecki%40gmail.com
>
> This email sent to edole...@gmail.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