I’m developing a plugin control, and I have the various graphics Draw/Fill calls for shapes working correctly, but I can’t get the methods that involve text (string) to work. This includes DrawText, TextWidth, and TextHeight.
Here’s how I map into the Xojo methods:
typedef double (* TextWidthFuncTy)(REALgraphics, REALstring);
TextWidthFuncTy TextWidth = (TextWidthFuncTy)REALLoadObjectMethod(context, "TextWidth(value As String) As Double");
typedef double (* TextHeightFuncTy)(REALgraphics, REALstring, RBInteger);
TextHeightFuncTy TextHeight = (TextHeightFuncTy)REALLoadObjectMethod(context, "TextHeight(value As String, wrapWidth as Integer) As Double");
typedef void (* DrawTextFuncTy)(REALgraphics, REALstring, double, double, double, bool);
DrawTextFuncTy DrawText = (DrawTextFuncTy)REALLoadObjectMethod(context, "DrawText(str As String, x As Double, y As Double, wrapWidth As Double, condense As Boolean)");
Then I call a method like so:
DrawText(context, data->someString, left, base, 0, false);
or
data->myHeight = TextHeight(context, data->someString, 9999));
where context is the passed REALgraphics object, someString is a REALstring and left & base are doubles.
But these always cause Xojo to crash. If I wrap the calls in an if like so:
if (DrawText) {
DrawText(context, data->someString, left, base, 0, false);
}
then it doesn’t crash, but the functions don’t run. Meaning the mapping is not successful.
What am I missing?
BTW, this is in Xojo 2021 R1.1 on a Mac, though I’ll need to compile it for Windows also once it’s working correctly.