ios - How to create light system font with special font attributes -
i need create uifont is:
- san francisco
- light weight
- using case insensitive font attribute (to display '/' glyph vertically aligned numbers)
i using code go it:
uifontdescriptor *fontdescriptor = [uifontdescriptor preferredfontdescriptorwithtextstyle:uifonttextstylebody]; nsarray *additionalfontsettings = @[@{uifontfeaturetypeidentifierkey: @(kcasesensitivelayouttype), uifontfeatureselectoridentifierkey: @(kcasesensitivelayoutonselector)}]; fontdescriptor = [fontdescriptor fontdescriptorbyaddingattributes:@{uifontdescriptorfeaturesettingsattribute: additionalfontsettings, uifontdescriptortraitsattribute: @{uifontweighttrait : @(uifontweightlight)}}]; return [uifont fontwithdescriptor:fontdescriptor size:50];
i right font right feature enabled, can't font weight adhered to. need light weight of system font. how achieve this?
turns out matt right hint. had forgotten can derive uifontdescriptor
existing uifont
.
therefore, creating descriptor works:
uifont *lightfont = [uifont systemfontofsize:50 weight:uifontweightlight]; uifontdescriptor *fontdescriptor = lightfont.fontdescriptor;
Comments
Post a Comment