I'm trying to use the GDI+ method Graphics::MeasureCharacterRanges but am getting errors from Windows that are no help in debugging the problem.
I think my issue is with the last argument to the method, which according to
https://docs.microsoft.com/en-us/windows/win32/api/gdiplusgraphics/nf-gdiplusgraphics-graphics-measurecharacterranges needs to be a "pointer to an array of Region objects".
What does that mean in Dolphin?
A few possibilities I've tried, plus the errors returned:
- an ExternalHandle -> "Invalid access to memory location"
- array of ExternalHandle objects -> "Invalid access to memory location"
- array of GdiplusRegion objects -> "Cannot coerce an Array to lpvoid"
I also tried creating a subclass of ExternalStructure called GpRegion, but that didn't seem correct since Region it isn't a nice simple C struct but rather a full blown C++ monstrosity. Or whatever it is they call classes.
GdiplusGraphics>>measureCharacterRanges: aString font: aFont layoutRect: aRectangle format: aStringFormat
| text regionCount regions status |
text := aString asUtf16String.
regionCount := aStringFormat getMeasurableCharacterRangeCount value.
regions := (1 to: regionCount) collect: [ :index | GdiplusRegion new ].
(status := GdiplusLibrary default
gdipMeasureCharacterRanges: self asParameter
str: text
length: text size
font: aFont asParameter
layoutRect: (RECTF fromRectangle: aRectangle)
stringFormat: aStringFormat asParameter
regionCount: regionCount
regions: regions asParameter) == Ok
ifFalse: [GdiplusError signal: 'GdipMeasureCharacterRanges failed' with: status].
^regions
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)