Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loading font from memory help needed...
#4
Try these @Dav :

Code: (Select All)

'load from file into fontdata$
OPEN "c:\windows\fonts\courbd.ttf" FOR BINARY AS 1
fontdata$ = INPUT$(LOF(1), 1)
CLOSE

'load courbd from fontdata$ string memory
myfont& = _LOADFONT(fontdata$, 32, "memory, monospace")
_FONT myfont&
PRINT "Hello World"

SLEEP

SCREEN _NEWIMAGE(640, 480, 32)
myfont& = _LOADFONT(fontdata$, 32, "memory")
_FONT myfont&
PRINT "Hello World"

What was the glitch?  If you look at the top code, you'll notice that you're in a SCREEN 0 text screen.  SCREEN 0 *requires* that all fonts used for it has to be MONOSPACE specified when loaded.  Without the "monospace" you can't load the font in memory and use it in SCREEN 0.

If you look at the second segment of the above, you'll notice that I'm not using "monospace", and yet it's working.  This is because 32-bits screens support variable-width fonts and they don't have to have that flag enabled when loading them.

The issue you're seeing seems to be just a simple case of trying to use a variable-width font in a monospace-required screen.  Wink
Reply


Messages In This Thread
Loading font from memory help needed... - by Dav - 09-16-2023, 12:10 AM
RE: Loading font from memory help needed... - by SMcNeill - 09-16-2023, 01:09 AM



Users browsing this thread: 1 Guest(s)