cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
miguello
Level VI

What is a correct way to deal with missing fonts?

Let's say I wrote a beautiful script, that uses some fonts - standard fonts you'd find on almost any computer, but not the JMP default fonts.

I distributed this script to my users, and I started getting feedback on errors messages about missing fonts.

It appears that there are computers in the organization that have a very minimal number of fonts installed.

So I wrapped each Font message in Try() statement, like so:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = dt << Bivariate( Y( :height ), X( :weight ) );
rbiv = biv << Report;
Try((rbiv << XPath( "//AxisBox/MouseBox/DropBox/TextEditBox" )) << Set Font( "Agency FF", 13 ), Write("No Font"));

The problem is it still gives me an error pop-up.

2022-08-30 13_50_05-.png

How do I correctly script the following: 

If a Font is installed - set to the GUI elements as directed, otherwise - use the default font.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: What is a correct way to deal with missing fonts?

This will work, and give you an indication if the <<setfont failed

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = dt << Bivariate( Y( :height ), X( :weight ) );
rbiv = biv << Report;
Batch Interactive( 1 );
x = Log Capture( ((rbiv << XPath( "//AxisBox/MouseBox/DropBox/TextEditBox" ))) << Set Font( "Comic Sans MS1", 13 ) );
Batch Interactive( 0 );

if(x!="",Show( x ));

Note there is no try(...) because <<setfont is not throwing an error. I think the dialog is for a warning, not an error, and should probably be removed, just leaving a warning in the log. LogCapture is making the <<setfont complete before the clearing of the Batch Interactive flag. Without LogCapture, the behavior is wrong.

 

Craige

View solution in original post

7 REPLIES 7
Craige_Hales
Super User

Re: What is a correct way to deal with missing fonts?

Away from my computer, but I believe the answer is to use the batch interactive flag to suppress the dialog. I think the flag is still undocumented and you'll have to search within this community to see how it works. You may also find it useful to use the log capture function to grab the text that would be in the dialog in order to diagnose what has happened, or you may be happy with the default font that you get anyway.

 

edit: link to Wendy's note about Batch Interactive 

Craige
miguello
Level VI

Re: What is a correct way to deal with missing fonts?

I was only able to find one post about Python with this piece of code without much explanation:

# Set the matplotlib.pyplot interactive flag to false
_JMPpp.interactive(False)

Any help would be much appreciated.

Craige_Hales
Super User

Re: What is a correct way to deal with missing fonts?

How do I prevent JMP Alerts from popping up?  is a starting point, not the best...

 

There is a function,

batch Interactive(1);

that sets JMP into batch mode which assumes no user is at the keyboard and takes the default button answer. This is a little undesirable in interactive mode because you might not notice a message in the log. You can set it to 0 right after the statement that might trigger a semi-expected but unwanted dialog.

Each call also returns the previous value if you want to use a stack-like mechanism for restoring the value.

Craige
miguello
Level VI

Re: What is a correct way to deal with missing fonts?

Strangely, this doesn't work:

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = dt << Bivariate( Y( :height ), X( :weight ) );
rbiv = biv << Report;
Batch Interactive(1);
Try((rbiv << XPath( "//AxisBox/MouseBox/DropBox/TextEditBox" )) << Set Font( "Agency FF", 13 ), (rbiv << XPath( "//AxisBox/MouseBox/DropBox/TextEditBox" )) << Set Font( "Agency FB", 13 ));
Batch Interactive(0);

while this works:

Batch Interactive(1);
throw("Test");
Batch Interactive(0);

 

Craige_Hales
Super User

Re: What is a correct way to deal with missing fonts?

Very odd. I think the next best answer is to comment out the Batch Interactive(0).

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = dt << Bivariate( Y( :height ), X( :weight ) );
rbiv = biv << Report;
show(Batch Interactive(1));
((rbiv << XPath( "//AxisBox/MouseBox/DropBox/TextEditBox" ))[1]) << Set Font( "Comic Sans MS1", 13 );
//show(Batch Interactive(0));

I can't explain what is happening, but I think it might be because the font isn't tested until needed...but I can't figure out how to do a wait(1) that fixes it.

 

Edit: sent a note to the dev team.

 

Edit2: next idea is better...

Craige
Craige_Hales
Super User

Re: What is a correct way to deal with missing fonts?

This will work, and give you an indication if the <<setfont failed

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

biv = dt << Bivariate( Y( :height ), X( :weight ) );
rbiv = biv << Report;
Batch Interactive( 1 );
x = Log Capture( ((rbiv << XPath( "//AxisBox/MouseBox/DropBox/TextEditBox" ))) << Set Font( "Comic Sans MS1", 13 ) );
Batch Interactive( 0 );

if(x!="",Show( x ));

Note there is no try(...) because <<setfont is not throwing an error. I think the dialog is for a warning, not an error, and should probably be removed, just leaving a warning in the log. LogCapture is making the <<setfont complete before the clearing of the Batch Interactive flag. Without LogCapture, the behavior is wrong.

 

Craige
miguello
Level VI

Re: What is a correct way to deal with missing fonts?

Looks like this works in this example. Let me see how it will look like in a real life script.