Load Custom Font

SGDK only sub forum

Moderator: Stef

Post Reply
cloudstrifer
Very interested
Posts: 118
Joined: Mon Feb 19, 2018 7:31 pm

Load Custom Font

Post by cloudstrifer » Mon Sep 23, 2019 4:03 am

Hi, I need help with custom font.

Thank you!

Code: Select all

	u32 customFont = VDP_loadFont(&custom_font, DMA);		
	VDP_loadFontData(&customFont, custom_font.numTile, DMA);	
.res

Code: Select all

	TILESET custom_font "gfx/font.png" BEST
	PALETTE custom_pal "gfx/font.png"

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Load Custom Font

Post by Stef » Mon Sep 23, 2019 7:59 am

You just need to use one or the other:

.res

Code: Select all

IMAGE custom_font  "gfx/font.png" BEST
.c

Code: Select all

VDP_loadFont(custom_font.tileset, DMA);	
should be enough to get your custom font loaded (i used IMAGE resource but the tileset as you did is also ok).
If you need to set a specific palette then don't forget to load the palette as well (by default text use PAL0 but you can change it)

cloudstrifer
Very interested
Posts: 118
Joined: Mon Feb 19, 2018 7:31 pm

Re: Load Custom Font

Post by cloudstrifer » Tue Sep 24, 2019 3:25 pm

Stef, using IMAGE and DMA my font didn't work correctly, instead of showing 60, it showed 71. :shock:


With the code below it works.

c

Code: Select all

	VDP_loadFont(&custom_font, CPU);
res

Code: Select all

	TILESET custom_font "gfx/font.png" -1
Thank you!
Thank you again for SGDK 1.41! :D

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Load Custom Font

Post by Stef » Tue Sep 24, 2019 4:34 pm

Oh i guess it "optimized" the empty (space) character :lol:
You can disable IMAGE optimisation declaring it that way :

Code: Select all

IMAGE custom_font  "gfx/font.png" BEST NONE
But TILESET may be better in the end to avoid that issue ;)

Post Reply