This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 42967 - We need UIFontTextStyle enum (or constants) for UIFont.GetPreferredFontForTextStyle
Summary: We need UIFontTextStyle enum (or constants) for UIFont.GetPreferredFontForTex...
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: XI 9.8 (tvOS / C7)
Hardware: PC Mac OS
: Normal enhancement
Target Milestone: (C9)
Assignee: Sebastien Pouliot
Depends on:
Reported: 2016-08-01 19:49 UTC by Larry O'Brien
Modified: 2016-09-27 18:21 UTC (History)
6 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Larry O'Brien 2016-08-01 19:49:49 UTC
The string constants defined at

let UIFontTextStyleTitle1: String
let UIFontTextStyleTitle2: String
let UIFontTextStyleTitle3: String
let UIFontTextStyleHeadline: String
let UIFontTextStyleSubheadline: String
let UIFontTextStyleBody: String
let UIFontTextStyleFootnote: String
let UIFontTextStyleCaption1: String
let UIFontTextStyleCaption2: String
let UIFontTextStyleCallout: String

Are required for UIFont.GetPreferredFontForTextStyle
Comment 1 Manuel de la Peña 2016-08-02 08:47:04 UTC
Looking at I've noticed we do have the constants yet they are internal. I've contacted the bindings author to confirm the reason and will update the code accordingly.
Comment 2 Miguel de Icaza [MSFT] 2016-08-02 15:42:58 UTC
Use the UIFont properties for those names instead, you do not need to call a method that takes an NSString whose value is not discoverable:

On the UIFont class, use one of these properties:


This information is even documented on the UIFont documentation:

The docs talk about iOS 7 features, some new properties were added in 9.0, which are not listed in the documentation, we should update that.
Comment 3 Larry O'Brien 2016-08-02 15:50:59 UTC
That works if the dev can hard-code the style (UIFont.PreferredHeadline) but does not work if the style is variable (PreferredFontForTextStyle). The source code we show is incorrect:

	headlineLabel.Font = UIFont.PreferredFontForTextStyle(UIFontTextStyle.Headline);
	bodyText.Font = UIFont.PreferredFontForTextStyle(UIFontTextStyle.Body);

But we don't *have* UIFontTextStyle.Headline or .Body (we don't have UIFontTextStyle).
Comment 4 Sebastien Pouliot 2016-08-02 18:33:01 UTC
I think the original issue was misunderstood, the mentioned API requires the NSString constant. However we can expose something better (and enum) in our public API.
Comment 5 Sebastien Pouliot 2016-09-21 00:56:47 UTC

Note You need to log in before you can comment on or make changes to this bug.