(Don't worry Jules; this isn't about font hinting!)
I've messed around with Juce's text rendering a lot, because I wasn't really satisfied with it (on Windows). It looks great on OSX, because the default renderer uses OSX's subpixel renderer - however, on Windows it uses a software antialiased approach. The problem is, that the gamma-change you introduced, while generally improving appearance, made it seem like different characters had different weights.
I then decided to create a subpixel renderer for fonts, that overrides the LowLevelSoftwareRenderer's antialiased text renderer, and so far, I'm pretty happy with the results! As is common with subpixel text rendering, the rendering inherits a slight, fussy feel, but will on the other hand vastly improve italics, kerning & spacing (it does subpixel positioning, also) as well as the gamma weight problem (it creates much more consistent intensity).
-- some examples --
edit 12/02, current progress and comparison of most used platforms (the render in this topic is called 'cpl render'):
Open it here for full resolution: http://i.imgur.com/FnFVED1.gif
Here's some text that illustrates the weight problem. Unfortunately, I didn't think of tagging the images with what renderer is used (the smoother one), but I hope it is obvious (otherwise, zoom in a bit to see the subpixel fringing).
This one will be resized in here, I think, so I'll link it instead (shows italics and a lot of different fonts):
There are some weird dots and pixels around in the images because of the compression in the GIFs.
Now, the implementation.. And the reason for this topic. This renderer only requires two minor changes to the repository, I obviously hope you will implement!
The code is basically an extended version of the EdgeTable::EdgeTableIterationCallback, which means it uses the exising font+glyph cache and edgetables! What it does is to intercept LowLevelGraphicsContext::drawGlyph, grabs the current font and scales it horizontally by 3 (to achieve the subpixel resolution).
This was my version of the intercept:
And, here's the actual renderer (should you be interested?):
Here's a link to the latest version: https://dl.dropboxusercontent.com/u/41702019/CPL.SubpixelFonts.zip
What needs to be changed?
using namespace juce::RenderingHelpers; typedef CachedGlyphEdgeTable<SoftwareRendererSavedState> GlyphType; typedef GlyphCache<GlyphType, SoftwareRendererSavedState> GlyphCacheType; GlyphCacheType& cache = GlyphCacheType::getInstance(); // get the glyph from the cache if (juce::ReferenceCountedObjectPtr<GlyphType> glyphRef = cache.findOrCreateGlyph(font, glyphNumber))
cache.findOrCreateGlyph() is private, and thus either needs to befriend LowLevelGraphicsContext or be public.
CachedGlyphEdgeTable::edgeTable is also private. I suggest creating an accessor method:
const juce::EdgeTable & CachedGlyphEdgeTable::getEdgeTable() const;
And that is all! Then it should work. Regarding performance, it is about 20% slower rendering bulks of text - but that really isn't much, considering subpixel rendering usually takes a lot more memory and performance! On the other hand, it doesn't actually create a copy of the glyphs edgetable on the heap, it uses the existing one. This also means it can't use the renderer stack to clip it. This may be a bad decision, I'm not sure (currently, it checks clipping inside the renderer loop).
If you're interested in the code, you can have it! I can create a version which is void of my math library, otherwise, I'm very interested in what you think about both the font rendering, design and / or proposed changes to the library. I know you generally want to use the platform to render text, but I'm getting impatient on Windows. :)