sharpdx / SharpDX

SharpDX GitHub Repository
http://sharpdx.org
MIT License
1.7k stars 639 forks source link

[DWrite] Accessing ColorGlyphRunEnumerator.CurrentRun throws an AccessViolationException. #1012

Closed Jayonas closed 6 years ago

Jayonas commented 6 years ago

It looks like the problem is that no custom code has been written to marshal ColorGlyphRun from native to managed and the auto-generated code probably isn't up to the task because ColorGlyphRun contains a GlyphRun value (not a pointer), and marshaling a GlyphRun requires hand-written code. The code to marshal GlyphRun already exists, so ColorGlyphRun basically just needs a bit of marshaling code which calls that.

(Note that I'm basing this off my usage of SharpDX 3.1.1, which I realize is out of date, but it also doesn't look like much has happened in the DWrite code since then so I think it's likely that this is still an issue.)

jkoritzinsky commented 6 years ago

I've investigated this a bit and it looks like the underlying issue is that the parameter to GetCurrentRun is a double pointer to a structure, which the code-generator does not correctly generate code for. Instead, the code-generator treats it as a pointer-to-structure parameter. I'll send in a PR when I get a chance with a workaround mapping.