Addition to Kerning Requested win32_DirectWriteTypeLayout


#1

Kerning now is supported for OS X using its native format (thanks for adding that), can you now add the same for windows. Below is what is needed:
In JUCE_COMRESULT DrawGlyphRun;

float extraKerning = glyphRunLayout->font.getExtraKerningFactor();
if (extraKerning != 0.0f) {
extraKerning *= glyphRunLayout->font.getHeight();
}

        for (UINT32 i = 0; i < glyphRun->glyphCount; ++i)
        {
            const float advance = glyphRun->glyphAdvances[i];
            if ((glyphRun->bidiLevel & 1) != 0)
                x -= advance + extraKerning ;  // RTL text
            glyphRunLayout->glyphs.add (TextLayout::Glyph (glyphRun->glyphIndices[i],
                                                           Point<float> (x, baselineOriginY - lineOrigin.y),
                                                           advance));
            if ((glyphRun->bidiLevel & 1) == 0)
                x += advance + extraKerning;  // LTR text
        }

Also, in juce_TextLayout.cpp in recalculateSize():
if (lines.size() > 0 && text.getReadingDirection() != AttributedString::rightToLeft) needs to be changed to just:
if (lines.size() > 0 )

Thanks,
Darren


#2

Thanks, seems like a good request, I’ll have a look soon!