Could we call UIFont using Objective-C Runtime Something like: id class_UIFont = objc_getClass("UIFont"); SEL sel_labelFontSize = sel_registerName("labelFontSize"); float size = objc_msgSend_fpret(class_UIFont, sel_labelFontSize);
? Anyway, we are back to the original question: What font to use. Reading Richard's original request we are still not getting the recommend font which is bold. I start to think the answer to get this right in the CSS… Felipe On Oct 30, 2013, at 10:14 AM, Oldrich Maticka <oldrich.mati...@oracle.com> wrote: > Hi, > > CTFontCreateUIFontForLanguage() returns fonts with same sizes for both iOS > and Mac OS X. See table below. > > Unfortunately I made a mistake when I wrote 15.0 for > CTFontCreateUIFontForLanguage(kCTFontPushButtonFontType) font size, > unfortunately it is 13.0. Other sizes reported were correct (I have verified > it yet once). > > > iPad3 (iOS7.0) MacOSX 10.8 > kCTFontUserFontType 12 12 > kCTFontUserFixedPitchFontType 10 10 > kCTFontSystemFontType 13 13 > kCTFontEmphasizedSystemFontType 13 13 > kCTFontSmallSystemFontType 11 11 > kCTFontSmallEmphasizedSystemFontType 11 11 > kCTFontMiniSystemFontType 9 9 > kCTFontMiniEmphasizedSystemFontType 9 9 > kCTFontViewsFontType 12 12 > kCTFontApplicationFontType 13 13 > kCTFontLabelFontType 10 10 > kCTFontMenuTitleFontType 14 14 > kCTFontMenuItemFontType 14 14 > kCTFontMenuItemMarkFontType 14 14 > kCTFontMenuItemCmdKeyFontType 14 14 > kCTFontWindowTitleFontType 13 13 > kCTFontPushButtonFontType 13 13 > kCTFontUtilityWindowTitleFontType 11 11 > kCTFontAlertHeaderFontType 13 13 > kCTFontSystemDetailFontType 9 9 > kCTFontEmphasizedSystemDetailFontType 9 9 > kCTFontToolbarFontType 11 11 > kCTFontSmallToolbarFontType 10 10 > kCTFontMessageFontType 13 13 > kCTFontPaletteFontType 11 11 > kCTFontToolTipFontType 11 11 > kCTFontControlContentFontType 12 12 > > Oldrich > > On 10/30/13 4:38 PM, Felipe Heidrich wrote: >> Hi, >> >> Correct me if I'm wrong, to use UIWhatever or NSWhatever we will need >> Objective-C (or use the ugly objc_msgSend). >> That is more work as we don't have Objective-C in native font code. Besides, >> creating a Button requires, usually, a lot more boilerplate code. We will >> also have to link to UIKit frameworks, etc. >> >> Now, creating a CTFont using >> CTFontCreateUIFontForLanguage(kCTFontPushButtonFontType) would be a very >> easy change. >> >> Oldrich, could you please prepare a table with the fontSize for all values >> on CTFontUIFontType for MacOSX and iOS ? >> >> Thanks >> >> >> On Oct 30, 2013, at 6:38 AM, Stephen F Northover >> <steve.x.northo...@oracle.com> wrote: >> >>> Let's use UIButton as this seems to match the stack overflow discussion. >>> >>> Steve >>> >>> On 2013-10-30 7:51 AM, Oldrich Maticka wrote: >>>> I have tried simple app with several controls. Fonts in Interface Builder - >>>> >>>> UIButton - System 15.0 >>>> UILabel - System 17.0 >>>> UITextField - System 14.0 >>>> UITextView - System 14.0 >>>> >>>> Same fontsize - 15.0 has UIButton's label created at runtime. >>>> >>>> UIFont class methods for getting system font information return: >>>> + labelFontSize 17.0 >>>> + buttonFontSize 18.0 >>>> + smallSystemFontSize 12.0 >>>> + systemFontSize 14.0 >>>> >>>> >>>> In fx Java_com_sun_javafx_font_MacFontFinder_getSystemFontSize returns 13.0 >>>> >>>> We can use different CTFontUIFontType in this method to return something >>>> "better" than 13.0 - >>>> e.g. with kCTFontPushButtonFontType as an argument to >>>> CTFontCreateUIFontForLanguage() it returns 15.0, but we need to decide, >>>> what we want to use as default. Should be our system default the size same >>>> as for UIButton, UILabel or other control? >>>> >>>> >>>> I was using iPad3 (iOS 7.0, Xcode 5.0). >>>> >>>> Olda >>>> >>>> On 10/29/13 7:32 PM, Stephen F Northover wrote: >>>>> I was going to create a dummy control (say a Button) and ask for the >>>>> font. Just an idea. >>>>> >>>>> Steve >>>>> >>>>> On 2013-10-29 2:18 PM, Felipe Heidrich wrote: >>>>>> 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 >