sharpdx/SharpDX

ColorGlyphRunEnumerator.CurrentRun returns Intpr instead of ColorGlyphRun

Gillibald opened this issue · 6 comments

Current CI builds seem to have some code generation issues. ColorGlyphRunEnumerator.CurrentRun returns Intptr instead of ColorGlyphRun. Atleast the marshaling code is available in the current master branch.

It seems the current CI builds dont map this correctly.

I have the following code:

var result = factory2.TryTranslateColorGlyphRun(
baselineOriginX,
baselineOriginY,
glyphRun,
glyphRunDescription,
measuringMode,
null,
0,
out var colorGlyphRunEnumerator);

if (result == Result.Ok)
{
    while (true)
    {
        colorGlyphRunEnumerator.MoveNext(out var hasRun);

        if (!hasRun)
        {
            break;
        }

        var colorGlyphRun = colorGlyphRunEnumerator.CurrentRun;

        brush = new SolidColorBrush(_renderTarget, colorGlyphRun.RunColor);

        _renderTarget.DrawGlyphRun(
             new RawVector2 { X = colorGlyphRun.BaselineOriginX, Y = colorGlyphRun.BaselineOriginY },
                            glyphRun,
                            brush,
                            measuringMode);
     }
         colorGlyphRunEnumerator.Dispose();
     }
    else
    {
         _renderTarget.DrawGlyphRun(baselineOrigin, glyphRun, brush, measuringMode);
    }
}
xoofx commented

@jkoritzinsky could you have a look?

Looks like SharpDX is generating the property based of the parameter type (which is correctly IntPtr). The GetCurrentRun method that doesn't take any parameters will get you your instance of ColorGlyphRun that you're looking for. I'll put together a PR when I have a chance with the changes to the mapping files to show the old API face correctly.

Hmm okay didn't realize there was a method for that. Will have a try.

@Gillibald this will be fixed (with the expected property name like before) in the next version of SharpDX.

Thanks for this 👍