https://bugs.winehq.org/show_bug.cgi?id=53552
--- Comment #11 from Nikolay Sivov bunglehead@gmail.com --- Yes, I can see the same failure with exact same numbers now, after installing corefonts.
The issue I believe is in GetTextAtPosition() in our wpf, specifically this line:
--- text = IntPtr.Add(segment.ptr, (int)(position - segment.start)); ---
As far as I can tell this only works correctly if position == segment.start. I will have to multiply offset by 2 to get correct WCHAR pointers.
The change in dwrite made it so one extra call is happening now with non-zero position, that wasn't there before. It might now happen on Windows, so testing there might be not productive. Still, we should fix this offset.
Output from some extra logging, simply reading through all valid positions, where you can see single byte shifts happening:
--- 012c:err:dwrite:analyze_script hr = 0, position 0, text L"test\n", length 5 012c:err:dwrite:analyze_script hr = 0, position 1, text L"\6500\7300\7400\0a00", length 4 012c:err:dwrite:analyze_script hr = 0, position 2, text L"est", length 3 012c:err:dwrite:analyze_script hr = 0, position 3, text L"\7300\7400", length 2 012c:err:dwrite:analyze_script hr = 0, position 4, text L"s", length 1 ---