Since all I hear is crickets in this dark and lonely place with Core Text, I thought I would post an answer that I found myself.
Answer: UIKit does not support customizing OpenType functions in its structure (at the time of writing), you need to go to Core Text to do this, and, fortunately, they have an API that provides additional font functions.
I will not go into details about using Core Text to draw text, but the corresponding idea is that you need to get a CTFontDescriptorRef that defines all the font attributes that will be used to draw your text.
Code example:
CTFontDescriptorRef fontDescriptorNoFeatures = CTFontDescriptorCreateWithNameAndSize((__bridge CFStringRef)self.font.fontName, pointSize);
The main thing I do here is to make a copy using CTFontDescriptorCreateCopyWithFeature() , a normal font descriptor with an additional function, called "Table Shapes" in OpenType, but in Core Text you must access this function using the number spacing function ( kNumberSpacingType ) and set the value for the corresponding enumeration defined in <CoreText/SFNTLayoutTypes.h> ,
For a number with an interval, the enumeration values (for some reason they call them selectors!?!):
enum { kMonospacedNumbersSelector = 0, kProportionalNumbersSelector = 1, kThirdWidthNumbersSelector = 2, kQuarterWidthNumbersSelector = 3 };
So, the trick is that there is no direct one-to-one mapping of OpenType functions with CoreText, but it seems that they are all there, you just need to go through the pain to identify the function by looking at the constants defined in <CoreText/SFNTLayoutTypes.h> .
The rest of the pain now you need to draw the text using this font in Core Text, and not at a higher level, but there are many links for this.
Kekoa
source share