Page 1 of 1

Fonts

Posted: April 11th, 2019, 6:38 pm
by danhans42
Does anyone have an example of how to use different fonts in your PsyQ projects?

I wanted to look at using other fonts but all the examples I can find just use the built in stuff.

Thanks

Re: Fonts

Posted: April 13th, 2019, 1:02 am
by LameGuy64
You're going to have to write your own text drawing functions but it shouldn't be too difficult if you're familiar enough with doing 2D graphics on the PS1. You essentially have to composite together a sheet of characters arranged in tile grid format (ie. 8x8 or 8x16) and you select the characters by adjusting the UV coordinates of the sprite primitive based on the character to be drawn.

Here's a snippet that should hopefully get you started with writing such a routine:

Code: Select all

int i,j;
SPRT_8 *cspr = (SPRT_8*)GsOUT_PACKET_P; // (assuming you're working with libgs)
short sx,sy; // These will be the coords where the characters will be drawn at

i = 0;
while(text[i] != 0) {
   j = text[i]-32;
   if( j>0 ) {
      setSprt8(cspr);
      setXY0(cspr, sx, sy);
      setUV0(cspr, (j%16)<<3, (j>>4)<<3); // This is tuned for 8x8 characters arranged in 16 character rows
      setRGB0(cspr, 128, 128, 128);
      addPrim(myOT[myActiveBuff].ot, cspr);
   }
   sx += 8;
   i++;
}