Sign in to follow this  
GameMasterXL

Creating custom font types

Recommended Posts

I was wondering this morning if it was possible to creat your own style of font to be used by any program that allows it? like i am wanting to creat my own font style for my game so i don't need to load bitmap images that will take more memory.

Share this post


Link to post
Share on other sites
Just find a program that allow you to create truetype fonts and you're done. It is a tedious task but can be rewarding. Unfortunately, I didn't find any free program to do the job - but you are encouraged to search one and to post a link as a reply if you find one. The otehr possiblity if to find a site with free, non-resticted fonts and to use one of these - the one that matches your idea.

A bitmap font, even a big one, is still a rather small bitmap. Moreover it is loaded only once. If you check my little TTT (see my GDS showcase) you'll see that I use an enormous bitmap fond with only the glyph I needed. Even if it is really big, I don't feel this 512x512x24bit bitmap (768kB!!) will be a heavy memory burner (it could be reduced to 256x256x8bit easily, which would make it a 65kB bitmap if memory were really a problem).

The fact is that it is faster to render from a bitmap font than from a truetype one, because you don't need to create a temporary texture, raster the font to this texture and send it to the GPU. Of course, you miss some nifty TT font features - kerning, support for other charsets, and so on. But it is easy, fast and very convenient.

Regards,

Share this post


Link to post
Share on other sites
Hi thanks for the help. I don't get this why does the GPU render everything to a texture? and not justy like it is static? like word displays text realy fast and easy but why can a game not do the same?

And also there is a font editor called fontlab that is dear though [sad] but microsoft has additional font tools http://www.microsoft.com/typography/tools/tools.aspx
Yes i think i found a font tool, look in windows system32 folder and go to eudcedit.exe or go to start->run and type the name in. You will get a private character editor that can creat custom symbols and characters for font librarys [smile].

[Edited by - GameMasterXL on June 23, 2005 10:43:04 AM]

Share this post


Link to post
Share on other sites
The main advantage of Truetype fonts is that they are scalable. Bitmap fonts look fine at thier native size but if you try to scale them they usually look terrible. Truetype fonts can look great at any size, although at small sizes it can be a bit tricky. The perf aspect is mostly a non-issue since you can render the realization of your choice (size, weight, etc) to a temporary bitmap once and at that point you've basically got a custom bitmap font.

eudcedit isn't really intended for creating fonts that will be distributed. It's for east-asian writing systems that can have arbitrary images as part of thier "character set". The scenario might be that you are Japanese and your family name is some random character that you or some ancestor literally pulled out of the air. You can then use eudcedit to draw the character and later use it in documents. These "end-user defined characters" are specific to your machine however and won't necessarily be visible on a different machine.

Quote:
like word displays text realy fast and easy but why can a game not do the same
Games can do the same. However the base 3D libraries (DX, OpenGL) typically don't have support for it so you need to roll your own font engine. The 3D libraries probably don't want to get involved because it can be a huge undertaking to create drivers for all the varius font formats as well as handling all the complexities add up real fast if you want to be fully general - far-east languages with potentially infinite numbers of glyphs, middle-east languages where glyph shapes are context sensitive, multi-lingual strings, vertical writing systems, right-to-left and bi-directional writing systems, not to mention petty (to outsiders) political issues between countries that supposedly use the same writing systems but actually have differences, etc, etc.

Share this post


Link to post
Share on other sites
True type fonts using windows GDI are very slow (don’t believe me? Write your own textbox class). How word displays text so quickly is… well it doesn’t. Instead it is smart enough to know what parts of the text has changed and only write over that particular section. If you scroll in a word document what you are actually doing is just shifting a saved image of the document in the direction that you are scrolling, and then updating the now “invalidated” area. Thus Word gets good performance via only updating what actually needs to be updated.

Not saying true type fonts cannot be used in games, first off you may write your own true type renderer (Direct3D has this, however I cannot get good performance from it), or you could write the font to a bitmap at run time and use those bitmaps to quickly shoot the characters onto the screen. Or you could always take the windows application approach and only refresh the text when you need to.

Anyway, Hope that helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by GameMasterXL
like word displays text realy fast and easy but why can a game not do the same?


Well... Word uses a lot of memory you know ;)

Moreover, Word do not work as you'll have to work in a game. Word directly writes the characters on screen, while you'll have to create an offsreen buffer, render the font to tis buffer, then use this buffer as a texture and render a quad using this texture. Finally, you'll have to desroy the off-screen buffer and the texture - because you won't reuse them. As you can understand, there are more work to do.

Regards,

Share this post


Link to post
Share on other sites
Quote:
True type fonts using windows GDI are very slow (don’t believe me? Write your own textbox class). How word displays text so quickly is… well it doesn’t
You do realize that Word uses GDI to display text? You can try it yourself - get one of the platform sdk debuggers (cdb or ntsd) set a breakpoint on gdi32!ExtTextOutW and you'll see Word calling it every time you type something. Word may be smarter about repainting than the text control is but that doesn't really say anything about what's below.

If you're targeting Windows there's no need to write your own Truetype renderer - there's one built in to the system. Just use GDI to render the text to a texture and you're done, you can even do anti-aliased text with a small amount of post-processing. If you want Word performance instead of notepad performance you're going to have do some intelligent caching but that's life in the big city.

Share this post


Link to post
Share on other sites
Is what i don't get though is why everything needs to be rendered to a texure? and not just outputed has pixels on the screen without all texture data.

Share this post


Link to post
Share on other sites
Quote:
Original post by Anon Mike
You do realize that Word uses GDI to display text?


I think what CyberFox meant is that while it does use GDI to actually draw text, it doesn't draw the whole screen every time you type a character - just the character you just typed (actually it probably has to draw a complete word or line, to account for combined characters and ligatures). Personally, I don't know if that's how it actually works or not, but I think that's what CyberFox was implying.

Quote:
Original post by GameMasterXL
Is what i don't get though is why everything needs to be rendered to a texure? and not just outputed has pixels on the screen without all texture data.


Well, it is possible to get a direct pointer to the back buffer's memory. However, because of the heavily-piplined nature of 3D hardware, by first rendering the text to a texture, and giving that to the hardware, you don't end up stalling the pipeline.

Share this post


Link to post
Share on other sites
The OP seems to have an issue with the idea of a "second stage" in the drawing process - conceptually, he wants to just set the pixels on the screen, not set them in a texture then use that to set the screen. I could be wrong of course - this is just the impression I get from the question.

Basically, what makes you think that passing a value for each pixel on the screen which you want to set, individually, in order to form a letter, will be more efficient than making an array of such pixel values and then passing that in one big lump? Generally passing one big lump of data will be more efficient.

These 2 dimensional arrays of pixel values which we like to pass around are sometimes referred to as textures. Just for convenience.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dean Harding
**snip**

Yes that is what I meant, sorry for any confusion. Mind you I have never looked at the Word source code, so my explanation is strictly just most likely how they went about displaying text. I did however do quite a bit of work creating an ide style text editor from scratch (without a canned edit view as I wanted more flexibility for coloring syntax and such). Doing this it readily became obvious that re-rendering the screen every time a new character is typed was far from practical as it caused a very unsightly flashing on the screen. Mind you I could have solved this with a double buffer system, however that seamed like an inefficient approach when in reality only a small portion of the screen needed to be updated. So thus is why I theorize Word uses such an approach. Once again, I could very well be wrong; however the main point anyway is that the GDI in its raw form (without using some optimization trick) is a slow beast, and not well suited for the demands of games IMHO.

Share this post


Link to post
Share on other sites
Most of the time a buffer is an array, however not always. A true buffer is just any data structure that works as a temporary place for data to sit as it moves from one place to another. A good example is when working with c style strings (character arrays) often times one will do something similar to the following:
char buffer[256];
sprintf( buffer, "Some formated text %i", some_int );
font.write( buffer, x, y, 0xff00ff00 );


Here the 'char buffer[256]' acts as a temporary storage space for the formated string as it moves to the screen. Most likely this is the type of buffer you are referring to, in which case it is an array. The classic CS example of a buffer that is not an array would be a print queue.

Hope that helped.

(Also hope you notice this, as it is a few days late in coming)

Share this post


Link to post
Share on other sites
Quote:
Original post by GameMasterXL
I was wondering this morning if it was possible to creat your own style of font to be used by any program that allows it? like i am wanting to creat my own font style for my game so i don't need to load bitmap images that will take more memory.


I found FontForge, and open source font editor capable of making TrueType and OpenType fonts (among others). I haven't tried it but it is free and the screen shots look promising.

Hope this helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this