Skip to content

Commit 3a59a35

Browse files
hansonrhansonr
authored andcommitted
fixes CSS "monospace" not "monospaced"
1 parent 844bd92 commit 3a59a35

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sources/net.sf.j2s.java.core/src/swingjs/JSToolkit.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff 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
*

0 commit comments

Comments
 (0)