The code Richard sent is creating a dummy font and asking for its size.

The problem is that there are about 3 thousand different fonts on the Mac ;-)

Here we are creating a CTFont. For Mac OS X most native apps probably would be 
using a NSFont (cause that is what cocoa controls take). Likewise on iOS I 
think the "common" font is UIFont (cause I think that is what UIKIt controls 
take).

Could anyone fire up Xcode, create a dummy iOS app, create a UIFont and see 
what is the size ?

Felipe


On Oct 29, 2013, at 8:40 AM, Stephen F Northover <steve.x.northo...@oracle.com> 
wrote:

> If the OS is reporting the wrong value for the default a classic trick is to 
> create a dummy control that normally has the font we want and query that.
> 
> Steve
> 
> On 2013-10-29 11:21 AM, Richard Bair wrote:
>> Hi guys,
>> 
>> The default font for iOS is supposed to be System Bold 15 (according to 
>> http://stackoverflow.com/questions/17325152/what-size-font-is-the-title-in-a-default-uibutton
>>  anyway), and it does look more correct to me. Our code is getting to this 
>> native method in MacFontFinder.c
>> 
>> JNIEXPORT jfloat JNICALL 
>> Java_com_sun_javafx_font_MacFontFinder_getSystemFontSize
>>   (JNIEnv *env, jclass obj)
>> {
>>     CTFontRef font = CTFontCreateUIFontForLanguage(
>>                          kCTFontSystemFontType,
>>                          0.0, //get system font with default size
>>                          NULL);
>>     jfloat systemFontDefaultSize = (jfloat) CTFontGetSize (font);
>>     CFRelease(font);
>>     return systemFontDefaultSize;
>> }
>> 
>> 
>> However it appears the return value is 13 instead of 15 (and I don't know 
>> what the actual default font family / weight is that we're returning). It is 
>> possible the answer coming from this native API call is "wrong". Any ideas?
>> 
>> Richard
> 

Reply via email to