DirectWrite: character spacing in Windows 7

I need to convert some text-to-bitmap rendering procedures into existing C ++ code that uses GDI and GDI + to use DirectWrite (requires CFF support and support for OTF functions).

I am new to DirectWrite. After spending some time on the research needed to migrate existing functionality and run some prototypes, I ran into a problem: My problem is that DirectWrite (out of the box) does not support character spacing (which is a requirement for an existing application), at least , not for Windows 7. I know that it comes with Windows 8, but another requirement for this existing application is to work in Windows 7, unfortunately.

What I have found so far in my research is that the implementation path seems to implement a custom DirectWrite text layout, but I did not find any good recommendations on how to do this, especially regarding the intersymbol nature (documentation / examples on MSDN regarding how to create custom text layouts are a bit vague to my liking).

I believe this must have been done before spending days and / or weeks of research and development on reinventing the wheel, does anyone here know an example of implementing a DirectWrite text layout with a custom character spacing that I could use as a starting point or tutorial?

UPDATE1 : not an answer, but - I found out that the IDWriteTextLayout1 interface (which supports setting spaces for characters) not only comes with Windows 8, but also with the "Update for Windows 7 Platform for SP1" (KB 2670838) in Windows 7. Since I can require so that the launcher application works correctly, this solves my problem, although this does not answer my question.

+4
source share
1 answer

- API , [https://msdn.microsoft.com/en-us/library/windows/desktop/dd941711(v=vs.85).aspx]. , , (IDWriteTextAnalyzer:: GetGlyphs), . SDK- for FlowLayout::ShapeGlyphRuns, .

STDMETHODIMP FlowLayout::ShapeGlyphRuns(IDWriteTextAnalyzer* textAnalyzer)
{
...
    hr = ShapeGlyphRun(textAnalyzer, runIndex, glyphStart);
...
    // Add additional character spacing to each trailing edge of each glyph.
    for (auto& advance : glyphAdvances_)
    {
        advance += 5.0f;
    }
...
}

, API- ApplyCharacterSpacing Windows 8, , , (, , API, IDWriteTextLayout::SetCharacterSpacing).

+2

Source: https://habr.com/ru/post/1584847/


All Articles