Has Tomasz's (h3r3tic's) OpenGL font rendering code been ported to D2?

Chad J chadjoan at __spam.is.bad__gmail.com
Sun Mar 11 15:36:33 PDT 2012


On 03/11/2012 05:04 PM, Jacob Carlborg wrote:
> On 2012-03-11 14:18, Chad J wrote:
>> On 03/11/2012 09:09 AM, Jacob Carlborg wrote:
>>> On 2012-03-11 03:23, Chad J wrote:
>>>> I've been looking for a good way to render font in OpenGL with D.
>>>>
>>>> Back in they day I was very impressed with Tomasz's article on the
>>>> subject: http://h3.gd/dmedia/?n=Tutorials.TextRendering1
>>>> I was wonder if anyone has ported it.
>>>
>>> Just use FreeType?
>>>
>>
>> FreeType is quite cool, but it will only render glyphs onto small
>> bitmaps. Getting those glyphs onto the screen becomes more complicated
>> after that: you can't just blit them like in SDL or somesuch. Since
>> textures don't come in "supersmall" size, it is effective to pack the
>> glyphs into a larger texture like the article suggests. Then you have to
>> texture-map correctly to only render the glyphs you want. Somewhere in
>> there is a bunch of other font-setting stuff like kerning, sub-pixel
>> anti-aliasing, line offsets, etc. FreeType doesn't do that stuff for
>> anyone, it just provides the tools necessary to make it possible. It's
>> fairly complicated; I'd rather just write "Font f = new Font("Courier
>> New"); f.draw(100, 100, "Hello world!");".
>
> So you mean putting a texture on a font?
>

No, just getting the font onto the screen at all.

And I want to:
- Be able to size the font smoothly.  (No bitmap fonts!)
- Draw glyphs for higher unicode codepoints.  (No texture[128]!)
- Have kerning/hinting.  (Freetype makes it possible, but does not do it 
for you.)
- Have anti-aliasing and maybe even subpixel accuracy.

Tomasz's code does all of this.

Freetype is very low-level.  Freetype does not make OpenGL calls.  You 
give it a font and a codepoint and it gives you a small grayscale bitmap 
and a slew of metrics for it.  Then it's up to you to figure out where 
to put it and how to get it onto the screen.

If this were trivial, Tomasz (and others who have written on the topic, 
too) would not have written 5-10 pages of text plus a bunch of D files 
full of code.  It's just not that easy.  It's all in the original link.

It's actually really weird that there isn't much library code out there 
to render text in OpenGL.  There are a bunch of tutorials that do it 
wrong and maybe a few library thingies that I can't use for various reasons.


More information about the Digitalmars-d mailing list