Path: chuka.playstation.co.uk!news From: James Russell Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: how made his own font ? Date: Wed, 05 Aug 1998 11:03:07 +0100 Organization: Sony Computer Entertainment Europe Lines: 55 Message-ID: <35C82DDB.3E12E37C@scee.sony.co.uk> References: <35C81A30.4ACB@club-internet.fr> NNTP-Posting-Host: mailgate.scee.sony.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.5b1 [en] (Win95; I) X-Accept-Language: en MAGNIER Francis wrote: > > I don't know how made his own font , > I suppose there is an array , > but how many cells horizontal and vertical ? It depends on how many characters you want. Do you want the entire ASCII alphabet, or just the letters? Do you want both uppercase and lowercase? Do you need punctuation, like '!', '.', etc..? Once you've decided what characters you want, this determines the maximum size of your font. Most people would go into a graphics program like Photoshop, Paint Shop Pro or Dpaint and create a 256x256 image containing all the letters of your font in a grid. This implies that all your letters are the same width/height. The size of the grid depends on how many characters are in your font. If you had 256 characters, then the grid would be 8x8, with each cell in the grid being 8x8 pixels. But if you have just numbers and letters, thats 10 (0-9) + 26 (A-Z) = 36, so you could have a 6x6 grid, with each cell being 42x42! Once you've done that, then you need a function to map a given letter to a UV coordinate in the image. Once you have this, you create a GsSPRITE which is set up (except the UV) to draw a letter from that image. All letters will share the same width, height, tpage, etc, so you only have to change the UV to reference a different letter. Say you have a function void CharToUV(char s, char *u, char *v) which takes a character and a pointer to two return characters. This returns the UV of that character (and I'm assuming the character you pass in is within the font!), then to draw your font, you might do this: SetUpGsSprite(&FontSprite); // Set up the tpage, width, height, etc. This only has to be done once in the program void printString(char *string, int x, int y) { FontSprite.x = x; FontSprite.y = y; while(*string) { // while there are still characters in the string if(*string != ' ') { // Skip spaces CharToUV(*string, &FontSprite.u, &FontSprite.v); // Calculate the proper UV GsSortSprite(&FontSprite, My orderingtable, my priority); } FontSprite.x += FONT_GRID_WIDTH; // The width of a letter string++; } } Cheers, James -- == James_Russell@scee.sony.co.uk +44 (171) 447-1626 == Developer Support Engineer - Sony Computer Entertainment Europe Where there's a will, I want to be in it.