Which font type is the easiest one to parse & render
Which font type is the easiest one to parse & render
Hi all,
After switching to VESA mode, I got another problem: I need some type of font do display with. I just googled the TrueType, find out it is a super complex font format(for a hobby OS). So, anyone knows some type of font which is easier to parse and render.
Cheers
torshie
After switching to VESA mode, I got another problem: I need some type of font do display with. I just googled the TrueType, find out it is a super complex font format(for a hobby OS). So, anyone knows some type of font which is easier to parse and render.
Cheers
torshie
Re: Which font type is the easiest one to parse & render
Fixed size bitmap font. It's super easy, you can DIY without any help.
"Programmers are tools for converting caffeine into code."
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Which font type is the easiest one to parse & render
The easiest way is a fixed size bitmap font. You turn the "on" pixels into foreground colour and "off" pixels into background color (or transparent), and you can just add a constant amount of pixels for every cell moved horizontally or vertically.
Re: Which font type is the easiest one to parse & render
Two "Fixed size bitmap font" reply at almost the same time!
Well, Combuster's way is good, but I don't like doing "on" and "off" for every pixel. You can simply do it by constructing your own bitmap font and then use memcpy (You should have implemented this function so far) to copy directly from the bitmap to video memory. It is faster and easier.
Well, Combuster's way is good, but I don't like doing "on" and "off" for every pixel. You can simply do it by constructing your own bitmap font and then use memcpy (You should have implemented this function so far) to copy directly from the bitmap to video memory. It is faster and easier.
"Programmers are tools for converting caffeine into code."
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Which font type is the easiest one to parse & render
Or implement FreeType. It's API is actually quite reasonable
Re: Which font type is the easiest one to parse & render
He said it's too complex (to him) at first.Owen wrote:Or implement FreeType. It's API is actually quite reasonable
"Programmers are tools for converting caffeine into code."
Re: Which font type is the easiest one to parse & render
Hi,
Fixed size bitmap fonts are easy to parse and render if you want something that looks like fixed size bitmap fonts.
Once you decide you want something that looks good, fixed size bitmap fonts become complex (e.g. bilinear scaling with anti-aliasing); and it becomes even more complex if you want to do it reasonably quickly. It's also a little expensive in terms of memory usage because you get much better results with much larger font data (8*8 characters scaled up to 60*80 looks like crap, but 128*256 characters scaled down to 60*80 can look good), and you'll probably want to pre-generate font data at different sizes to avoid the overhead of repeatedly rescaling (or at least maintain a cache of already scaled font data). For a rough estimate; about 1 million unicode characters with 128*256 bits per character (or 4 KiB per character) works out to about 4 GiB of data (ignoring things like bold/italic, etc)...
Cheers,
Brendan
Fixed size bitmap fonts are easy to parse and render if you want something that looks like fixed size bitmap fonts.
Once you decide you want something that looks good, fixed size bitmap fonts become complex (e.g. bilinear scaling with anti-aliasing); and it becomes even more complex if you want to do it reasonably quickly. It's also a little expensive in terms of memory usage because you get much better results with much larger font data (8*8 characters scaled up to 60*80 looks like crap, but 128*256 characters scaled down to 60*80 can look good), and you'll probably want to pre-generate font data at different sizes to avoid the overhead of repeatedly rescaling (or at least maintain a cache of already scaled font data). For a rough estimate; about 1 million unicode characters with 128*256 bits per character (or 4 KiB per character) works out to about 4 GiB of data (ignoring things like bold/italic, etc)...
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Which font type is the easiest one to parse & render
Instead of investing time in creating high-resolution bitmap fonts (it is a lot of work), I'd recommend outline fonts. It will look better on every size and you will end up saving time because you don't have to work as much on fonts.
If you want something that you know will always be displayed on the same resolution and will have the same size, this might provide an answer. It's a bitmap font so it's easy to parse.
If you want something that you know will always be displayed on the same resolution and will have the same size, this might provide an answer. It's a bitmap font so it's easy to parse.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: Which font type is the easiest one to parse & render
I do not think anyone has come up yet with the "ultimate font format". I tend to think that stroke fonts using spline fitting for curves (plus antialiasing) is probably superior to all the current methods -- which means that there really IS NO good method currently. It needs much more research, and for the moment you just have to pick something and run with it.
Re: Which font type is the easiest one to parse & render
freaky line font!
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: Which font type is the easiest one to parse & render
He said TrueType was too difficult to implement by hand. FreeType, on the other hand, should be reasonably implementable, as it just depends on an ANSI C library (and you need one of those anyway, so investing in that is useful)quanganht wrote:He said it's too complex (to him) at first.Owen wrote:Or implement FreeType. It's API is actually quite reasonable
Re: Which font type is the easiest one to parse & render
Sorry, I made a really quick skim so I thought you was talking about TrueTypeOwen wrote:He said TrueType was too difficult to implement by hand. FreeType, on the other hand, should be reasonably implementable, as it just depends on an ANSI C library (and you need one of those anyway, so investing in that is useful)
"Programmers are tools for converting caffeine into code."
Re: Which font type is the easiest one to parse & render
Thanks for all the replies.
I need to support Chinese, so DIY my own font file is impractical, I have to support some type of public available font file.
Maybe I should spend some time on porting FreeType. FreeType source code is more than 1M, it got to cost some serious time
I need to support Chinese, so DIY my own font file is impractical, I have to support some type of public available font file.
Maybe I should spend some time on porting FreeType. FreeType source code is more than 1M, it got to cost some serious time
Re: Which font type is the easiest one to parse & render
It may be easier to DIY your own font style. How many characters are in your alphabet? For my project, I simply created my font file based on ms serif (I like it, it looks clean), I wrote a simple html application to help me create it. The format is like this:
0x00 means end of line
0x01 means place dot
0x02 means move right one unit
My font file is pretty big, I also include special characters in my font, so I just load it from CD along with my other resources like images, configuration files, etc.
My font is displayed 10pt by default and can be sized dynamically, and the bold, italics, etc are done with code tricks, so I just need one file with both upper and lower case characters and the rest my code handles.
However, if you can port an already made font then why not, it will save you a lot of time.
0x00 means end of line
0x01 means place dot
0x02 means move right one unit
My font file is pretty big, I also include special characters in my font, so I just load it from CD along with my other resources like images, configuration files, etc.
My font is displayed 10pt by default and can be sized dynamically, and the bold, italics, etc are done with code tricks, so I just need one file with both upper and lower case characters and the rest my code handles.
However, if you can port an already made font then why not, it will save you a lot of time.
Yes, I see that you have proven it, but my question was, 'How did you know that would work?'.
Re: Which font type is the easiest one to parse & render
If only support English characters, DIY your own font is possible and much easier than porting FreeType. But I want to support Chinese(my mother tongue), thousands of characters are commonly used, so it's impractical to DIY a font as large as this.osdnlo wrote:It may be easier to DIY your own font style. How many characters are in your alphabet? For my project, I simply created my font file based on ms serif (I like it, it looks clean), I wrote a simple html application to help me create it. The format is like this:
0x00 means end of line
0x01 means place dot
0x02 means move right one unit
My font file is pretty big, I also include special characters in my font, so I just load it from CD along with my other resources like images, configuration files, etc.
My font is displayed 10pt by default and can be sized dynamically, and the bold, italics, etc are done with code tricks, so I just need one file with both upper and lower case characters and the rest my code handles.
However, if you can port an already made font then why not, it will save you a lot of time.