Curve.CreateTextOutlines method should not work with non existing font

Hello, I just faced a bug because the font provided to the Curve.CreateTextOutlines method was not installed and Rhino silently used another font.

static Curve[] CreateTextOutlines(
string text,
string font,
double textHeight,
int textStyle,
bool closeLoops,
Plane plane,
double smallCapsScale,
double tolerance
)

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.curve/createtextoutlines

I fixed my bug, but please document this behaviour or throw an exception instead of simply using another font.

1 Like

Hi @martinborst1,

Can you provide some sample code or a sample file where font substitution is occurring?

Thanks,

– Dale

Hi @dale,

“Source Code Pro” is a font that I had to install from the internet, it was not preinstalled. The user did not have source code pro installed and rhino/grasshopper simply used another font instead.
You can see the component actually used a different font, especially for the character “t” once “Source code prooooooo” (or another non existing font) is used as input.
demonstrator_font.gh (7.6 KB)


2023-05-11 07_37_38-Untitled - Rhinoceros 7 Commercial

1 Like

Hi @martinborst1,

The script produces this on my system, since I don’t have your font:

Rhino tries really hard to find the the font you specify. If not found, it tries really hard to return a font that is close, property wise, to what you specified.

There is no way to override this behavior.

If you won’t want to create outlines curves if the font does not exist, you’ll need to verify the font’s existence on your own. A Google search should provide sample code on how to check to see if a font is installed.

– Dale

Yes, I already fixed my bug by checking if the font is already installed, as mentioned in my first message.
I want this behaviour to be documented in the documentation of the function - I assumed that it would raise an exception.