[futurebasic] Re: [FB] Font height

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2006 : Group Archive : Group : All Groups

From: Steve Crossman <mactech@...>
Date: Wed, 29 Mar 2006 14:32:38 -0500
thanks for the clarification. I wonder if this is the reason some of  
my text height and width calculations are off!!

On Mar 29, 2006, at 2:21 PM, Bernie wrote:

>
> tedd asked:
>
>> What's the function call (or whatever) you use to detect font height?
>
>
> To get info on a specified font (rather than the current graphics  
> port font), you could use fn FetchFontInfo(). Also, I wonder if  
> GetThemeTextDimensions is a suitable alternative?
>
> '----------
> #define FMFontFamily as SInt16
> toolbox fn FMGetFontFamilyFromName( Str255 iName ) = FMFontFamily
> toolbox fn FetchFontInfo( SInt16 fontID, SInt16 fontSize, ¬
> SInt16 fontStyle, FontInfo *info ) = OSStatus
> toolbox fn GetThemeTextDimensions( CFStringRef inString, ¬
> SInt16 inFont, SInt16 inState, Boolean inBool, point *outPoint, ¬
> short *outBaseline ) = OSStatus
>
> dim as FontInfo    info
> dim as point     @ dims
> dim as SInt16    @ baseline
> dim as short       fontHeight
> dim as OSStatus    ignore
>
> window 1
> text fn FMGetFontFamilyFromName( "Lucida Grande" ), 11
>
>
> // FetchFontInfo
> ignore = fn FetchFontInfo( ¬
> fn FMGetFontFamilyFromName( "Lucida Grande" ), 11, 0, @info )
> fontHeight = info.ascent + info.descent + info.leading
> print fontHeight
>
>
> // GetThemeTextDims
> ignore = fn GetThemeTextDimensions( fn CFSTR( " " ), ¬
> _kThemeCurrentPortFont, _kThemeStateUnavailable, _false, ¬
> @dims, @baseline )
> print dims.v%
>
>
> do
> HandleEvents
> until 0
> '----------
>
> BTW, as of OS X 10.4, both GetFontInfo and FetchFontInfo are  
> deprecated.
>
>
> Bernie
>
> --
>