/***********************************************************************

FontBucket.h

Purpose: 	Include this header file in any source files that work
			with FontBucket. FontBucket enables you to easily include
			custom fonts in your application, and allow users to
			pick their own fonts from popular font collections.	

Copyright © 2000 Hands High Software
All Rights Reserved

The code in this file may be freely copied, distributed and used without 
compensation to  Hands High Software, Inc. or its permission.


API Version: 1.3

File Version: 1.30

See FontBucket.c for history

************************************************************************/

// The following version number gets incremented whenever an API change happens that
// requires the user to install a new version of FontBucket. If an older version is
// detected, FmInit will return errFontObsoleteFBVersion and FontBucket will act as 
// if it was not installed.

#define kFontBucketVersion         2	


#define PalmFontNameString              9500	
#define VGAFontNameString               9504	
#define BoldStyleString					9550

#define kMaxFontNameSize                64	// 63 + null
#define kMaxFontStyleSize				32  // 31 + null
#define kFontBucketNotInstalled         0

#define kDefaultFontStart				((FontID)fntAppFontCustomBase + ((FontID) 2))
#define kDefaultFontMax					((FontID)255)
#define kNoFontRangeSpecified           ((FontID)0)

#define kNoFmFontID                     ((FmFontID)0)

#define errFontTableOutOfSlots       ((Err)(appErrorClass | 0x01))
#define errFontNotFree               ((Err)(appErrorClass | 0x02))
#define errFontNotFound          	 ((Err)(appErrorClass | 0x03))
#define errFontInvalidRange          ((Err)(appErrorClass | 0x04))
#define errFontBucketNotInitialized	 ((Err)(appErrorClass | 0x05))
#define errFontIndexInvalid          ((Err)(appErrorClass | 0x06))
#define errFontInvalidFmFontID       ((Err)(appErrorClass | 0x07))
#define errFontObsoleteFBVersion	 ((Err)(appErrorClass | 0x08))
#define errFontBadFontData			 ((Err)(appErrorClass | 0x09))

typedef UInt32 FmFontID;

typedef enum {
	FmInitFontLaunchCode = sysAppLaunchCmdCustomBase,
	FmSelectFontLaunchCode,
	FmUseFontLaunchCode,
	FmValidateFontLaunchCode,
	FmFreeFontLaunchCode,
	FmCloseLaunchCode,
	FmNameLaunchCode,
	FmIdLaunchCode,
	FmFontIdLaunchCode,
	FmNumberOfFontsLaunchCode,
	FmInfoLaunchCode,
	FmInfoByIDLaunchCode,
	FMFaceListLaunchCode,
	FMDrawModeLaunchCode
} FmLaunchCodes;

typedef enum {
	fmStd,
	fmHandera,
	fmSony
} FMDeviceType;

typedef struct {
	UInt16	  		card;
	LocalID   		localID;
	FMDeviceType 	device;
} FmType, *FmPtr;


// Information about a particular font
typedef struct {
	FmFontID	fmFontID;
	UInt16		fontIndex;
	char 		fontName[kMaxFontNameSize];
	char		fontStyle[kMaxFontStyleSize];
	UInt8 		fontSize;
} FmFontInfoType;


Err FmInit(FmPtr fmPtr,  FontID	firstFont,  FontID    lastFont, Boolean fromSubLaunch);
Boolean FmSelectFont (FmPtr fmPtr, FmFontID* fmFontId);
Err    FmUseFont(FmPtr fmPtr, FmFontID fmFontId, FontID *fontID);
Err    FmFreeFont(FmPtr fmPtr, FontID fontID);
Err    FmClose (FmPtr fmPtr);
Err    FmValidFont(FmPtr fmPtr, FmFontID fmFontId);
Err    FmFontName (FmPtr fmPtr, FmFontID fmFontId, Char *name);
Err    FmGetFMFontIdFromName (FmPtr fmPtr, const Char *name, FmFontID* fmFontId, const Char* style, UInt16 size);
Err    FmGetFMFontID(FmPtr fmPtr, FontID fontID, FmFontID* fmFontId);
UInt16 FmGetFontCount(FmPtr fmPtr);
Err    FmGetIndexedFontInfo(FmPtr fmPtr, UInt16 index, FmFontInfoType* info);
Err    FmGetFontInfo (FmPtr fmPtr, FmFontID fmFontID, FmFontInfoType* info);
MemHandle	   FmGetFamilyNames (FmPtr fmPtr);
	
	/*
	 * 	
// Return true if FontBucket is installed
// Normally, you shouldn't need to call this, since the API works whether or not
// FontBucket is installed. However, if you need to know for some reason, call this after
// calling FmInit.			
__inline Boolean FmIsInstalled (FmPtr fmPtr) {
	return fmPtr->localID != 0;
}

bc of
collect2: ld terminated with signal 11 [Segmentation fault]
src/BinaryClockGeneric.o(.text+0x516):BinaryClockGeneric.c: multiple definition of `FmIsInstalled'
src/fontbucket/FontBucket.o(.text+0x5f0):FontBucket.c: first defined here

*/
