May 08, 2024, 02:01:51 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Own font ?

Started by paja, August 29, 2009, 03:04:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

paja

Hi,

How can I use in my program my own font - it means non system font ?

sapero

August 29, 2009, 04:02:37 AM #1 Last Edit: August 29, 2009, 04:05:16 AM by sapero
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.

paja

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"

ZeroDog

Are you running win2k pro or higher? 

paja


sapero

AddFontResourceEx is an alias for AddFontResourceExA or AddFontResourceExW (unicode version).

paja

OK - but how can I uset it ? Please can you write complete code.

LarryMc

$include "windowssdk.inc"

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

ZeroDog

What you originally posted should work if you change  AddFontResourceEx  to  AddFontResourceExA (for ANSI)  or  AddFontResourceExW (for UNICODE).