Font creation/rendering
Posted: Sat May 05, 2018 12:22 pm
Hi,
I have nearly finished a project, and in the meantime have been thinking about the next project, and fonts comes to mind.
My current GUI uses numerous fonts, as shown here, but each of those fonts are fixed sized bitmaps. For example, the character 'A', in its simplest form, might use an 8-bit width and an 10-byte height, a set bit meaning to plot a pixel, a clear bit meaning to bring the background pixel forward.
This makes it really simple. In fact, I created a simple font creation utility that allows me to create these fonts with ease, the 'A' in question, shown. Each white box represents a background pixel (a transparent pixel) while a black box represents a foreground pixel (non-transparent pixel). The utility allows me to move the bits around, but in the end, the character is still just a bitmap of pixels.
The other font, the LucidaC font is again, the exact same thing, though more pixels in the width and height directions.
The problem is, they remain the same size, period. If the font is 19 pixels tall, as in the LucidaC font, the characters are always 19 pixels tall. I have no way of displaying different sizes, unless I use a routine to simply expand the pixel bitmap.
For example, in this image, notice the background image is at a fixed size of 640x480, but in this image I have used a routine to "stretch" the background image to match the screen size.
I thought about doing this technique to the current font bitmap design, but as the font size increased, so would the pixelation appearance.
I have looked around for font ideas, TrueType, OpenType, etc. I looked on this forum, the previous few screen shots of projects like klange's Toaruos, pat's Saturn and nakst's projects, that seem to show font size differences, though I know that Saturn uses FreeType as its font rendering engine.
I grabbed a few simple font files from WinXP, each roughly 50k in size, and tore them apart looking to see what they did. (I thought it would be really nice to grab one of these font files, try to display it, having a WinXP machine do the same, and then compare).
Also, having recently worked with my ACPI and AML stuff, I thought of having an AML type language that would tell the rendering engine how to draw the character, possibly similar to the TrueType font file, but not so detailed. The TTF file has 14 tables, more than half referencing each other just to get information about how to display the font, let along the actual glyphs.
So, my question is for those of you whom have stuck around and read this far (smile), what have you done, thought about doing, think you might do, etc.? I know pat's Saturn uses FreeType, but I don't want to port someone else's code, I want to do this myself.
If I did an AML type language, I could have instructions like, for simplicity sake:
- move to x,y (x and y being units in size)
- turn on pixel drawing
- move to x,y
- draw radius at x,y w/radius = r, from degree (d0) to degree (d1)
- stop pixel drawing
- move to x,y
- etc....
As long as I remembered that x,y and any size related variable needed to be "current font height/width" aware, this would work for simple fonts.
My question is, do I want to take the time to create a TTF rendering package where I can simply download a free font from the web and display it (many advantages), or create a much simpler font rendering package of my own, but have to create each font file myself?
Just asking for your thoughts and ideas.
Thanks,
Ben
- http://www.fysnet.net/osdesign_book_series.htm
I have nearly finished a project, and in the meantime have been thinking about the next project, and fonts comes to mind.
My current GUI uses numerous fonts, as shown here, but each of those fonts are fixed sized bitmaps. For example, the character 'A', in its simplest form, might use an 8-bit width and an 10-byte height, a set bit meaning to plot a pixel, a clear bit meaning to bring the background pixel forward.
This makes it really simple. In fact, I created a simple font creation utility that allows me to create these fonts with ease, the 'A' in question, shown. Each white box represents a background pixel (a transparent pixel) while a black box represents a foreground pixel (non-transparent pixel). The utility allows me to move the bits around, but in the end, the character is still just a bitmap of pixels.
The other font, the LucidaC font is again, the exact same thing, though more pixels in the width and height directions.
The problem is, they remain the same size, period. If the font is 19 pixels tall, as in the LucidaC font, the characters are always 19 pixels tall. I have no way of displaying different sizes, unless I use a routine to simply expand the pixel bitmap.
For example, in this image, notice the background image is at a fixed size of 640x480, but in this image I have used a routine to "stretch" the background image to match the screen size.
I thought about doing this technique to the current font bitmap design, but as the font size increased, so would the pixelation appearance.
I have looked around for font ideas, TrueType, OpenType, etc. I looked on this forum, the previous few screen shots of projects like klange's Toaruos, pat's Saturn and nakst's projects, that seem to show font size differences, though I know that Saturn uses FreeType as its font rendering engine.
I grabbed a few simple font files from WinXP, each roughly 50k in size, and tore them apart looking to see what they did. (I thought it would be really nice to grab one of these font files, try to display it, having a WinXP machine do the same, and then compare).
Also, having recently worked with my ACPI and AML stuff, I thought of having an AML type language that would tell the rendering engine how to draw the character, possibly similar to the TrueType font file, but not so detailed. The TTF file has 14 tables, more than half referencing each other just to get information about how to display the font, let along the actual glyphs.
So, my question is for those of you whom have stuck around and read this far (smile), what have you done, thought about doing, think you might do, etc.? I know pat's Saturn uses FreeType, but I don't want to port someone else's code, I want to do this myself.
If I did an AML type language, I could have instructions like, for simplicity sake:
- move to x,y (x and y being units in size)
- turn on pixel drawing
- move to x,y
- draw radius at x,y w/radius = r, from degree (d0) to degree (d1)
- stop pixel drawing
- move to x,y
- etc....
As long as I remembered that x,y and any size related variable needed to be "current font height/width" aware, this would work for simple fonts.
My question is, do I want to take the time to create a TTF rendering package where I can simply download a free font from the web and display it (many advantages), or create a much simpler font rendering package of my own, but have to create each font file myself?
Just asking for your thoughts and ideas.
Thanks,
Ben
- http://www.fysnet.net/osdesign_book_series.htm