This project is read-only.

Would it be possible to use .ttf fonts on cosmos?

Topics: Other, Using Cosmos (Developing your own OS, projects, etc)
Jul 15, 2012 at 1:10 PM

I want to have .ttf, to finish the homebar for my os. it needs text, and for differant resolutions differant sizes. help!

Jul 17, 2012 at 10:18 PM

It is perfectly possible, even without Filesystem support. Just convert the file to a byte array (I don't just mean read it into memory either, I mean store it in a class as a byte array), then when it is in a byte array, you can read it at runtime and interpret it, however, you would have to have advanced graphics support, as most TrueType Fonts require you to be able to draw straight lines (admittedly simple), but also to draw quadratic Bézier curves and there is still a lot more you'd have to account for in a *.ttf file.

I had an idea similar a few weeks ago, I then gave the idea up when I saw the amount of work I would have to do to get it working, when I had more pressing things to work on. Kudos to you if you can get it working.

Here is a few links to help you out:


Jul 21, 2012 at 4:23 AM

While yes, it is possible, it is very difficult, I have spent the last year working on a system to do the rendering and hinting of a true type font. While yes, the base rendering itself is easy, that alone produces horrible results at the sizes you'll be looking at. I am currently mostly done with it, I just have to re-write my renderer to support dropout control, as well as to use the winding rule rather than the parity rule to determine if a point is supposed to be filled in. After I re-write the renderer, I just need to pass the final dropout mode to the renderer so it knows what dropout rules to use,

Jul 23, 2012 at 6:44 PM

I think MOSA has a prototype for a graphical sub system with vector graphics called Pictor.

I do not know if this can load ttf but you can try to port code from that and store a self made vector font in your own format.
I also think that code could be helpful in various other places aswell.

Jul 23, 2012 at 11:05 PM

It can't load ttf, they started to write such a system a few years ago, but the code has since been lost. (and actually forgotten about mostly, took me a bit of digging to find out it ever existed) My Image class could cover some of the functionality that you'd be looking at for a vector format. Filling polygons still needs to be re-written to use the same system I use for my ttf rendering... Although the Image class is more of a raster system than a vector system.... (the ttf system is vector.) The biggest downside to creating your own font, is the designing of it, there are multiple challenges that Hinting was designed in order to overcome, mostly having to do with pixel boundary issues....

Jul 25, 2012 at 1:04 PM

The MOSA version is ported from v2.4 because it has a BSD license.

It uses FreeType for loading fonts.