[futurebasic] Beginners Corner: Using call getfnum(fontname$, font%)

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2010 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sun, 17 Jan 2010 22:08:01 -0500
Emmett asked:

>How are Fonts supposed to be loaded?

Emmett:

These more modern complementary functions allow a user to parse a 
font family number from its name and vice versa.

Be sure to double-check the spelling of your font name, including case.

Ken


include "Tlbx Fonts.incl"

local fn GetFontNumberFromName( fontName As Str255 ) as FMFontFamily
'~'1
dim as FMFontFamily fontNumber

fontNumber = Fn FMGetFontFamilyFromName( fontName )
If fontNumber = _kInvalidFontFamily Then fontNumber = 0

end fn = fontNumber

local fn GetFontNameFromNumber$( fontNumber as FMFontFamily ) as Str255
'~'1
dim as Str255   fontNameStr
dim as OSStatus stat

stat = fn FMGetFontFamilyName( fontNumber, fontNameStr )

end fn = fontNameStr

window 1

print fn GetFontNumberFromName( "Lucida Grande" )
print fn GetFontNameFromNumber$( 1024 )

Text fn GetFontNumberFromName( "Lucida Grande" ), 52

print
print "Hello Emmett"

do
HandleEvents
until gFBQuit