Colouring fonts
Michael Grunditz (8594) 259 posts |
Hi! I don’t understand how to change colour for Font_Paint. I can see that there are a number of swis, but all I get is black. Can anyone give me a example? I am running in 256 colours. |
Stuart Swales (8827) 1357 posts |
Fireworkz and PipeDream both use SWI ColourTrans_SetFontColours(0, fg_rgb, bg_rgb, 14) |
Michael Grunditz (8594) 259 posts |
IN what format is rgb specified. I do like the way you write, except for r0 wich I point to my fonthandle. The handle is ok, I am using it in font_paint. |
Chris Mahoney (1684) 2165 posts |
PRM 3-338:
|
Stuart Swales (8827) 1357 posts |
Oh, the poor PRMs do need some TLC! |
Michael Grunditz (8594) 259 posts |
Thats what I have. Still black text. I wonder if it can be font related. I have tried Homerton and Trinity, |
Rick Murray (539) 13840 posts |
Is there any mention in 5a? Is the font handle being correctly passed to each call? Don’t rely upon “current font” unless you’re the only thing running (as a full screen app). |
Michael Grunditz (8594) 259 posts |
Another factor: I paint text to a 8-bit sprite. I am also drawing with OS_Plot and can change gcol for that. |
Stuart Swales (8827) 1357 posts |
Are you doing the ColourTrans_SetFontColours immediately before the Font_Paint, i.e. after setting the sprite as output? |
Rick Murray (539) 13840 posts |
And set up a save area; do not rely upon the default system save area as FontManager can redirect itself when caching fonts… |
Charles Ferguson (8243) 427 posts |
If you are struggling to make something work, produce a minimal example to see how it functions. Then you can use that as a small worked example to play with different parameters, and you won’t be confused by trying to make things work en masse. Apply the same mentality you would for testing, of checking the behaviour in its smallest parts to be sure you understand what’s going on. And if you’re not thinking about testing, those small examples that you made to debug things can become your tests. If you’re still stuck, your minimal example will be small enough to include when you explain what the problem is on public forums. And I’ve produced some examples of how you use some of the RISC OS APIs. https://github.com/gerph/riscos-examples/blob/master/graphics/fonts/FontPaint%2Cfd1 for example. |
Michael Grunditz (8594) 259 posts |
Turned out to be a casting error. In one of the SpriteOp swis I managed to write (int) instead of (unsigned int) when pointing out the sprite area.. GAH! But happy that it works and good that I got the opportunity to learn more about fonts! |