File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
sources/net.sf.j2s.java.core/src/swingjs Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -833,15 +833,21 @@ public static String getCanvasFont(Font font) {
833833 strStyle += "italic " ;
834834 if (font .isBold ())
835835 strStyle += "bold " ;
836- String family = font .getFamily ();
837- if (family .equals ("SansSerif" ) || family .equals ("Dialog" )
838- || family .equals ("DialogInput" ))
839- family = "Arial" ;
836+ String family = getCSSFontFamilyName (font .getFamily ());
840837 // for whatever reason, Java font points are much larger than HTML5 canvas
841838 // points
842839 return strStyle + font .getSize () + "px " + family ;
843840 }
844841
842+ public static String getCSSFontFamilyName (String family ) {
843+ if (family .equals ("SansSerif" ) || family .equals ("Dialog" )
844+ || family .equals ("DialogInput" ))
845+ family = "Arial" ;
846+ else if (family .equals ("Monospaced" ))
847+ family = "monospace" ;
848+ return family ;
849+ }
850+
845851 /**
846852 * Generate a date in a specific format.
847853 *
You can’t perform that action at this time.
0 commit comments