1 |
/* Font.java -- Font object |
/* Font.java -- Font object |
2 |
Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc. |
Copyright (C) 1999, 2002, 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
209 |
* The style should be one of BOLD, ITALIC, or BOLDITALIC. The default |
* The style should be one of BOLD, ITALIC, or BOLDITALIC. The default |
210 |
* style if none is specified is PLAIN. The default size if none |
* style if none is specified is PLAIN. The default size if none |
211 |
* is specified is 12. |
* is specified is 12. |
212 |
|
* |
213 |
|
* @param fontspec a string specifying the required font (<code>null</code> |
214 |
|
* permitted, interpreted as 'Dialog-PLAIN-12'). |
215 |
|
* |
216 |
|
* @return A font. |
217 |
*/ |
*/ |
218 |
public static Font decode (String fontspec) |
public static Font decode (String fontspec) |
219 |
{ |
{ |
220 |
|
if (fontspec == null) |
221 |
|
fontspec = "Dialog-PLAIN-12"; |
222 |
String name = null; |
String name = null; |
223 |
int style = PLAIN; |
int style = PLAIN; |
224 |
int size = 12; |
int size = 12; |
225 |
|
|
226 |
StringTokenizer st = new StringTokenizer(fontspec, "-"); |
StringTokenizer st = new StringTokenizer(fontspec, "- "); |
227 |
while (st.hasMoreTokens()) |
while (st.hasMoreTokens()) |
228 |
{ |
{ |
229 |
String token = st.nextToken(); |
String token = st.nextToken(); |
254 |
{ |
{ |
255 |
tokenval = Integer.parseInt(token); |
tokenval = Integer.parseInt(token); |
256 |
} |
} |
257 |
catch(NumberFormatException e) { ; } |
catch(NumberFormatException e) |
258 |
|
{ |
259 |
|
// Ignored. |
260 |
|
} |
261 |
|
|
262 |
if (tokenval != 0) |
if (tokenval != 0) |
263 |
size = tokenval; |
size = tokenval; |