Skip to content

Commit 6af5eba

Browse files
hansonrhansonr
authored andcommitted
adds Font.getPSName()
1 parent a1a3ed3 commit 6af5eba

File tree

2 files changed

+45
-11
lines changed

2 files changed

+45
-11
lines changed
546 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/awt/Font.java

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ public String getFamily() {
11611161
return (family == null ? family = JSToolkit.getFontFamily(this) : family);
11621162
// return getFamily_NoClientCode();
11631163
}
1164+
11641165
// // NOTE: This method is called by privileged threads.
11651166
// // We implement this functionality in a package-private
11661167
// // method to insure that it cannot be overridden by client
@@ -1196,17 +1197,50 @@ public String getFamily() {
11961197
// return getFont2D().getFamilyName(l);
11971198
// }
11981199
//
1199-
// /**
1200-
// * Returns the postscript name of this <code>Font</code>.
1201-
// * Use <code>getFamily</code> to get the family name of the font.
1202-
// * Use <code>getFontName</code> to get the font face name of the font.
1203-
// * @return a <code>String</code> representing the postscript name of
1204-
// * this <code>Font</code>.
1205-
// * @since 1.2
1206-
// */
1207-
// public String getPSName() {
1208-
// return getFont2D().getPostscriptName();
1209-
// }
1200+
/**
1201+
* Returns the postscript name of this <code>Font</code>. Use
1202+
* <code>getFamily</code> to get the family name of the font. Use
1203+
* <code>getFontName</code> to get the font face name of the font.
1204+
*
1205+
* @return a <code>String</code> representing the postscript name of this
1206+
* <code>Font</code>.
1207+
* @since 1.2
1208+
*/
1209+
public String getPSName() {
1210+
1211+
// Serif Serif.plain Serif.bold Serif.italic
1212+
// SansSerif SansSerif.plain SansSerif.bold SansSerif.italic
1213+
// TimesRoman Serif.plain Serif.bold Serif.italic
1214+
// Helvetica SansSerif.plain SansSerif.bold SansSerif.italic
1215+
// Courier Monospaced.plain Monospaced.bold Monospaced.italic
1216+
// Monospaced Monospaced.plain Monospaced.bold Monospaced.italic
1217+
// Dialog Dialog.plain Dialog.bold Dialog.italic
1218+
// DialogInput DialogInput.plain DialogInput.bold DialogInput.italic
1219+
1220+
switch (name) {
1221+
case "TimesRoman":
1222+
name = SERIF;
1223+
break;
1224+
case "Helvetica":
1225+
name = SANS_SERIF;
1226+
break;
1227+
case "Courier":
1228+
name = MONOSPACED;
1229+
break;
1230+
default:
1231+
case MONOSPACED:
1232+
case SERIF:
1233+
case SANS_SERIF:
1234+
case DIALOG:
1235+
case DIALOG_INPUT:
1236+
break;
1237+
}
1238+
return name + (isPlain()? ".plain"
1239+
: "."
1240+
+ (isBold() ? "bold" : "")
1241+
+ (isItalic() ? "italic" : "")
1242+
);
1243+
}
12101244

12111245
/**
12121246
* Returns the logical name of this <code>Font</code>.

0 commit comments

Comments
 (0)