Display 2 color font
Moderator: Stef
Display 2 color font
Is there a way to have two colors in text? The single color text is fine for dialog, but i would like to display 2 or more for larger text.
Thanks.
Thanks.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Display 2 color font
You just need to define your own font with several color. Default SGDK font only use colors 0 (background/transparent) and 15 (foreground) but you are free to redefine it so you have nice gradient in your letter for instance
-
- Very interested
- Posts: 86
- Joined: Fri Sep 25, 2015 4:16 pm
Re: Display 2 color font
You can use your four palettes to print up to four different colors without having to touch the font in VRAM.
Re: Display 2 color font
Hi.
I try to insert my font image.
I tried the two functions :
I always have the same error : incompatible type for argument 1. I read the first argument of VDP_loadFont and insert in my .res file :
TILESET fontrom "font.png" 0
I try with BITMAP or IMAGE without success
I try to insert my font image.
I tried the two functions :
Code: Select all
u16 VDP_loadFont(const TileSet *font, u8 use_dma)
(myfont = VDP_loadFont(fontrom, 1);)
void VDP_loadFontData(const u32 *font, u16 length, u8 use_dma)
TILESET fontrom "font.png" 0
I try with BITMAP or IMAGE without success
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Display 2 color font
You were close :
And indeed you have to use TILESET resource type here.
Code: Select all
VDP_loadFont(&fontrom, TRUE);
Re: Display 2 color font
Oh my god, i forgot the pointer.
I've adding a planB to see the transparent color with VDP_drawText(). Now, I use his own palette but we can use the palette we want.
I've made an example, maybe that can help someone else.
https://www.dropbox.com/s/awey2em7by2ygr8/font.zip
I've adding a planB to see the transparent color with VDP_drawText(). Now, I use his own palette but we can use the palette we want.
I've made an example, maybe that can help someone else.
https://www.dropbox.com/s/awey2em7by2ygr8/font.zip
Re: Display 2 color font
Last month, I faced the same problem.
in my case, I wanted to use 8 colors fonts !
The 'only' valid way to do it was to load 8 version of the font.
Hopefully, colors needed to be changed every row so....HInt color change !
If anyone would like to know more, here the code snippet for SGDK:
perhaps it could be optimized but it works like this so....
in my case, I wanted to use 8 colors fonts !
The 'only' valid way to do it was to load 8 version of the font.
Hopefully, colors needed to be changed every row so....HInt color change !
If anyone would like to know more, here the code snippet for SGDK:
Code: Select all
void handleHBlank()
{
u8 currentRow = ((GET_VCOUNTER+1) >> 3);
u16 fontColor;
if (currentRow < 8) return;
fontColor = colors[ 1+(currentRow-8)% 8 ];
asm("move.l #0xc0220000, 0xc00004.l");
while((*((volatile u16*)GFX_CTRL_PORT) & 4) == 0);
asm("move.w %0, 0xc00000.l":/*nothing */:"r"(fontColor) );
}
....
//faster than SYS_setHIntCallback(&handleHBlank);
internalHIntCB = &handleHBlank;
VDP_setHInterrupt(TRUE);