IonicWind Software

IWBasic => General Questions => Topic started by: paja on August 29, 2009, 03:04:37 AM

Title: Own font ?
Post by: paja on August 29, 2009, 03:04:37 AM
Hi,

How can I use in my program my own font - it means non system font ?
Title: Re: Own font ?
Post by: sapero on August 29, 2009, 04:02:37 AM
Hello paja, call AddFontResourceEx api (LoadFont like function) to attach your font file to current process:
$include "windowssdk.inc"
int fontscount = AddFontResourceEx("c:\\download\\my font.fon", FR_PRIVATE, 0)
...SetFont()...

If the function succeeds, the return value specifies the number of fonts added, or zero if failed.
FR_PRIVATE - Specifies that only the process that called the AddFontResourceEx function can use this font. When you are finished with this font, call RemoveFontResourceEx with the same parameters.
Title: Re: Own font ?
Post by: paja on August 29, 2009, 03:39:05 PM
I wrote

const FR_PRIVATE = 0x10
def fontscount:int
declare "gdi32.dll", AddFontResourceEx(LPCSTR:string, fl:Double, PVOID:int),int
fontscount = AddFontResourceEx("D:\E_basic\EBDev\lcddot.ttf", FR_PRIVATE, 0)

but I get this error from linker: "Unresolved_external: ___inp_AddFontResourceEx"
Title: Re: Own font ?
Post by: ZeroDog on August 29, 2009, 04:16:40 PM
Are you running win2k pro or higher? 
Title: Re: Own font ?
Post by: paja on August 29, 2009, 04:45:59 PM
I have WIN XP PRO
Title: Re: Own font ?
Post by: sapero on August 29, 2009, 05:17:22 PM
AddFontResourceEx is an alias for AddFontResourceExA or AddFontResourceExW (unicode version).
Title: Re: Own font ?
Post by: paja on August 29, 2009, 05:47:35 PM
OK - but how can I uset it ? Please can you write complete code.
Title: Re: Own font ?
Post by: LarryMc on August 29, 2009, 05:50:36 PM
$include "windowssdk.inc"

Larry
Title: Re: Own font ?
Post by: ZeroDog on August 29, 2009, 07:42:19 PM
What you originally posted should work if you change  AddFontResourceEx  to  AddFontResourceExA (for ANSI)  or  AddFontResourceExW (for UNICODE).