69 |
public class Font implements Serializable |
public class Font implements Serializable |
70 |
{ |
{ |
71 |
|
|
72 |
/* |
/** |
73 |
* Static Variables |
* Constant indicating a "plain" font. |
74 |
*/ |
*/ |
75 |
|
public static final int PLAIN = 0; |
76 |
/** |
|
77 |
* Constant indicating a "plain" font. |
/** |
78 |
*/ |
* Constant indicating a "bold" font. |
79 |
public static final int PLAIN = 0; |
*/ |
80 |
|
public static final int BOLD = 1; |
81 |
/** |
|
82 |
* Constant indicating a "bold" font. |
/** |
83 |
*/ |
* Constant indicating an "italic" font. |
84 |
public static final int BOLD = 1; |
*/ |
85 |
|
public static final int ITALIC = 2; |
86 |
/** |
|
87 |
* Constant indicating an "italic" font. |
/** |
88 |
*/ |
* Constant indicating the baseline mode characteristic of Roman. |
89 |
public static final int ITALIC = 2; |
*/ |
90 |
|
public static final int ROMAN_BASELINE = 0; |
91 |
/** |
|
92 |
* Constant indicating the baseline mode characteristic of Roman. |
/** |
93 |
*/ |
* Constant indicating the baseline mode characteristic of Chinese. |
94 |
public static final int ROMAN_BASELINE = 0; |
*/ |
95 |
|
public static final int CENTER_BASELINE = 1; |
96 |
/** |
|
97 |
* Constant indicating the baseline mode characteristic of Chinese. |
/** |
98 |
*/ |
* Constant indicating the baseline mode characteristic of Devanigri. |
99 |
public static final int CENTER_BASELINE = 1; |
*/ |
100 |
|
public static final int HANGING_BASELINE = 2; |
|
/** |
|
|
* Constant indicating the baseline mode characteristic of Devanigri. |
|
|
*/ |
|
|
public static final int HANGING_BASELINE = 2; |
|
101 |
|
|
102 |
|
|
103 |
/** |
/** |
186 |
*/ |
*/ |
187 |
protected int style; |
protected int style; |
188 |
|
|
189 |
// Serialization constant |
//Serialization constant |
190 |
private static final long serialVersionUID = -4206021311591459213L; |
private static final long serialVersionUID = -4206021311591459213L; |
191 |
|
|
192 |
|
|
193 |
// The ClasspathToolkit-provided peer which implements this font |
// The ClasspathToolkit-provided peer which implements this font |
194 |
private ClasspathFontPeer peer; |
private ClasspathFontPeer peer; |
195 |
|
|
|
/*************************************************************************/ |
|
196 |
|
|
197 |
/* |
/** |
198 |
* Static Methods |
* Creates a <code>Font</code> object from the specified string, which |
199 |
*/ |
* is in one of the following formats: |
200 |
|
* <p> |
201 |
/** |
* <ul> |
202 |
* Creates a <code>Font</code> object from the specified string, which |
* <li>fontname-style-pointsize |
203 |
* is in one of the following formats: |
* <li>fontname-style |
204 |
* <p> |
* <li>fontname-pointsize |
205 |
* <ul> |
* <li>fontname |
206 |
* <li>fontname-style-pointsize |
* </ul> |
207 |
* <li>fontname-style |
* <p> |
208 |
* <li>fontname-pointsize |
* The style should be one of BOLD, ITALIC, or BOLDITALIC. The default |
209 |
* <li>fontname |
* style if none is specified is PLAIN. The default size if none |
210 |
* </ul> |
* is specified is 12. |
211 |
* <p> |
* |
212 |
* The style should be one of BOLD, ITALIC, or BOLDITALIC. The default |
* @param fontspec a string specifying the required font (<code>null</code> |
213 |
* style if none is specified is PLAIN. The default size if none |
* permitted, interpreted as 'Dialog-PLAIN-12'). |
214 |
* is specified is 12. |
* |
215 |
* |
* @return A font. |
216 |
* @param fontspec a string specifying the required font (<code>null</code> |
*/ |
217 |
* permitted, interpreted as 'Dialog-PLAIN-12'). |
public static Font decode(String fontspec) |
218 |
* |
{ |
219 |
* @return A font. |
if (fontspec == null) |
220 |
*/ |
fontspec = "Dialog-PLAIN-12"; |
221 |
public static Font decode (String fontspec) |
String name = null; |
222 |
{ |
int style = PLAIN; |
223 |
if (fontspec == null) |
int size = 12; |
224 |
fontspec = "Dialog-PLAIN-12"; |
|
225 |
String name = null; |
StringTokenizer st = new StringTokenizer(fontspec, "- "); |
226 |
int style = PLAIN; |
while (st.hasMoreTokens()) |
227 |
int size = 12; |
{ |
228 |
|
String token = st.nextToken(); |
229 |
StringTokenizer st = new StringTokenizer(fontspec, "- "); |
if (name == null) |
230 |
while (st.hasMoreTokens()) |
{ |
231 |
{ |
name = token; |
232 |
String token = st.nextToken(); |
continue; |
233 |
if (name == null) |
} |
234 |
{ |
|
235 |
name = token; |
if (token.toUpperCase().equals("BOLD")) |
236 |
continue; |
{ |
237 |
} |
style = BOLD; |
238 |
|
continue; |
239 |
if (token.toUpperCase().equals("BOLD")) |
} |
240 |
{ |
if (token.toUpperCase().equals("ITALIC")) |
241 |
style = BOLD; |
{ |
242 |
continue; |
style = ITALIC; |
243 |
} |
continue; |
244 |
if (token.toUpperCase().equals("ITALIC")) |
} |
245 |
{ |
if (token.toUpperCase().equals("BOLDITALIC")) |
246 |
style = ITALIC; |
{ |
|
continue; |
|
|
} |
|
|
if (token.toUpperCase().equals("BOLDITALIC")) |
|
|
{ |
|
247 |
style = BOLD | ITALIC; |
style = BOLD | ITALIC; |
248 |
continue; |
continue; |
249 |
} |
} |
250 |
|
|
251 |
int tokenval = 0; |
int tokenval = 0; |
252 |
try |
try |
253 |
{ |
{ |
254 |
tokenval = Integer.parseInt(token); |
tokenval = Integer.parseInt(token); |
255 |
} |
} |
256 |
catch(NumberFormatException e) |
catch (NumberFormatException e) |
257 |
{ |
{ |
258 |
// Ignored. |
// Ignored. |
259 |
} |
} |
260 |
|
|
261 |
if (tokenval != 0) |
if (tokenval != 0) |
262 |
size = tokenval; |
size = tokenval; |
263 |
} |
} |
264 |
|
|
265 |
HashMap attrs = new HashMap(); |
HashMap attrs = new HashMap(); |
266 |
ClasspathFontPeer.copyStyleToAttrs (style, attrs); |
ClasspathFontPeer.copyStyleToAttrs(style, attrs); |
267 |
ClasspathFontPeer.copySizeToAttrs (size, attrs); |
ClasspathFontPeer.copySizeToAttrs(size, attrs); |
268 |
|
|
269 |
return getFontFromToolkit (name, attrs); |
return getFontFromToolkit(name, attrs); |
270 |
} |
} |
271 |
|
|
272 |
/* These methods delegate to the toolkit. */ |
/* These methods delegate to the toolkit. */ |
273 |
|
|
274 |
protected static ClasspathToolkit tk () |
protected static ClasspathToolkit tk() |
275 |
{ |
{ |
276 |
return (ClasspathToolkit)(Toolkit.getDefaultToolkit ()); |
return (ClasspathToolkit) Toolkit.getDefaultToolkit(); |
277 |
} |
} |
278 |
|
|
279 |
/* Every factory method in Font should eventually call this. */ |
/* Every factory method in Font should eventually call this. */ |
280 |
protected static Font getFontFromToolkit (String name, Map attribs) |
protected static Font getFontFromToolkit(String name, Map attribs) |
281 |
{ |
{ |
282 |
return tk ().getFont (name, attribs); |
return tk().getFont(name, attribs); |
283 |
} |
} |
284 |
|
|
285 |
/* Every Font constructor should eventually call this. */ |
/* Every Font constructor should eventually call this. */ |
286 |
protected static ClasspathFontPeer getPeerFromToolkit (String name, Map attrs) |
protected static ClasspathFontPeer getPeerFromToolkit(String name, Map attrs) |
287 |
{ |
{ |
288 |
return tk ().getClasspathFontPeer (name, attrs); |
return tk().getClasspathFontPeer(name, attrs); |
289 |
} |
} |
290 |
|
|
291 |
|
|
292 |
/*************************************************************************/ |
/** |
293 |
|
* Returns a <code>Font</code> object from the passed property name. |
294 |
/** |
* |
295 |
* Returns a <code>Font</code> object from the passed property name. |
* @param propname The name of the system property. |
296 |
* |
* @param defval Value to use if the property is not found. |
297 |
* @param propname The name of the system property. |
* |
298 |
* @param defval Value to use if the property is not found. |
* @return The requested font, or <code>default</code> if the property |
299 |
* |
* not exist or is malformed. |
300 |
* @return The requested font, or <code>default</code> if the property |
*/ |
301 |
* not exist or is malformed. |
public static Font getFont(String propname, Font defval) |
302 |
*/ |
{ |
303 |
public static Font getFont (String propname, Font defval) |
String propval = System.getProperty(propname); |
304 |
{ |
if (propval != null) |
305 |
String propval = System.getProperty(propname); |
return decode(propval); |
|
if (propval != null) |
|
|
return decode (propval); |
|
306 |
return defval; |
return defval; |
307 |
} |
} |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Returns a <code>Font</code> object from the passed property name. |
|
|
* |
|
|
* @param propname The name of the system property. |
|
|
* |
|
|
* @return The requested font, or <code>null</code> if the property |
|
|
* not exist or is malformed. |
|
|
*/ |
|
|
public static Font getFont (String propname) |
|
|
{ |
|
|
return getFont (propname, (Font)null); |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
308 |
|
|
309 |
/* |
/** |
310 |
* Constructors |
* Returns a <code>Font</code> object from the passed property name. |
311 |
*/ |
* |
312 |
|
* @param propname The name of the system property. |
313 |
/** |
* |
314 |
* Initializes a new instance of <code>Font</code> with the specified |
* @return The requested font, or <code>null</code> if the property |
315 |
* attributes. |
* not exist or is malformed. |
316 |
* |
*/ |
317 |
* @param name The name of the font. |
public static Font getFont(String propname) |
318 |
* @param style The font style. |
{ |
319 |
* @param size The font point size. |
return getFont(propname, (Font) null); |
320 |
*/ |
} |
321 |
|
|
322 |
public Font (String name, int style, int size) |
/** |
323 |
|
* Initializes a new instance of <code>Font</code> with the specified |
324 |
|
* attributes. |
325 |
|
* |
326 |
|
* @param name The name of the font. |
327 |
|
* @param style The font style. |
328 |
|
* @param size The font point size. |
329 |
|
*/ |
330 |
|
public Font(String name, int style, int size) |
331 |
{ |
{ |
332 |
HashMap attrs = new HashMap(); |
HashMap attrs = new HashMap(); |
333 |
ClasspathFontPeer.copyStyleToAttrs (style, attrs); |
ClasspathFontPeer.copyStyleToAttrs(style, attrs); |
334 |
ClasspathFontPeer.copySizeToAttrs (size, attrs); |
ClasspathFontPeer.copySizeToAttrs(size, attrs); |
335 |
this.peer = getPeerFromToolkit (name, attrs); |
this.peer = getPeerFromToolkit(name, attrs); |
336 |
this.size = size; |
this.size = size; |
337 |
this.pointSize = (float)size; |
this.pointSize = (float) size; |
338 |
} |
} |
339 |
|
|
340 |
public Font (Map attrs) |
public Font(Map attrs) |
341 |
{ |
{ |
342 |
this(null, attrs); |
this(null, attrs); |
343 |
} |
} |
344 |
|
|
345 |
/* This extra constructor is here to permit ClasspathToolkit and to |
/* This extra constructor is here to permit ClasspathToolkit and to |
346 |
build a font with a "logical name" as well as attrs. |
build a font with a "logical name" as well as attrs. |
347 |
ClasspathToolkit.getFont(String,Map) uses reflection to call this |
ClasspathToolkit.getFont(String,Map) uses reflection to call this |
348 |
package-private constructor. */ |
package-private constructor. */ |
349 |
Font (String name, Map attrs) |
Font(String name, Map attrs) |
350 |
{ |
{ |
351 |
// If attrs is null, setting it to an empty HashMap will give this |
// If attrs is null, setting it to an empty HashMap will give this |
352 |
// Font default attributes. |
// Font default attributes. |
353 |
if (attrs == null) |
if (attrs == null) |
354 |
attrs = new HashMap(); |
attrs = new HashMap(); |
355 |
peer = getPeerFromToolkit (name, attrs); |
peer = getPeerFromToolkit(name, attrs); |
356 |
size = (int)peer.getSize( this ); |
size = (int) peer.getSize(this); |
357 |
pointSize = peer.getSize( this ); |
pointSize = peer.getSize(this); |
358 |
} |
} |
359 |
|
|
360 |
/*************************************************************************/ |
/** |
|
|
|
|
/* |
|
|
* Instance Methods |
|
|
*/ |
|
|
|
|
|
/** |
|
361 |
* Returns the logical name of the font. A logical name is the name the |
* Returns the logical name of the font. A logical name is the name the |
362 |
* font was constructed with. It may be the name of a logical font (one |
* font was constructed with. It may be the name of a logical font (one |
363 |
* of 6 required names in all java environments) or it may be a face |
* of 6 required names in all java environments) or it may be a face |
364 |
* name. |
* name. |
365 |
* |
* |
366 |
* @return The logical name of the font. |
* @return The logical name of the font. |
367 |
* |
* |
368 |
* @see #getFamily() |
* @see #getFamily() |
369 |
* @see #getFontName() |
* @see #getFontName() |
370 |
*/ |
*/ |
371 |
public String getName () |
public String getName () |
372 |
{ |
{ |
373 |
return peer.getName (this); |
return peer.getName(this); |
374 |
} |
} |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Returns the size of the font, in typographics points (1/72 of an inch), |
|
|
* rounded to an integer. |
|
|
* |
|
|
* @return The font size |
|
|
*/ |
|
|
public int getSize () |
|
|
{ |
|
|
return size; |
|
|
} |
|
|
|
|
|
/** |
|
|
* Returns the size of the font, in typographics points (1/72 of an inch). |
|
|
* |
|
|
* @return The font size |
|
|
*/ |
|
|
public float getSize2D () |
|
|
{ |
|
|
return pointSize; |
|
|
} |
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Tests whether or not this is a plain font. This will be true if |
|
|
* and only if neither the bold nor the italics style is set. |
|
|
* |
|
|
* @return <code>true</code> if this is a plain font, <code>false</code> |
|
|
* otherwise. |
|
|
*/ |
|
|
public boolean isPlain () |
|
|
{ |
|
|
return peer.isPlain (this); |
|
|
} |
|
375 |
|
|
376 |
/*************************************************************************/ |
/** |
377 |
|
* Returns the size of the font, in typographics points (1/72 of an inch), |
378 |
|
* rounded to an integer. |
379 |
|
* |
380 |
|
* @return The font size |
381 |
|
*/ |
382 |
|
public int getSize() |
383 |
|
{ |
384 |
|
return size; |
385 |
|
} |
386 |
|
|
387 |
/** |
/** |
388 |
* Tests whether or not this font is bold. |
* Returns the size of the font, in typographics points (1/72 of an inch). |
389 |
* |
* |
390 |
* @return <code>true</code> if this font is bold, <code>false</code> |
* @return The font size |
391 |
* otherwise. |
*/ |
392 |
*/ |
public float getSize2D() |
393 |
public boolean isBold () |
{ |
394 |
{ |
return pointSize; |
395 |
return peer.isBold (this); |
} |
|
} |
|
396 |
|
|
397 |
/*************************************************************************/ |
/** |
398 |
|
* Tests whether or not this is a plain font. This will be true if |
399 |
|
* and only if neither the bold nor the italics style is set. |
400 |
|
* |
401 |
|
* @return <code>true</code> if this is a plain font, <code>false</code> |
402 |
|
* otherwise. |
403 |
|
*/ |
404 |
|
public boolean isPlain() |
405 |
|
{ |
406 |
|
return peer.isPlain(this); |
407 |
|
} |
408 |
|
|
409 |
/** |
/** |
410 |
* Tests whether or not this font is italic. |
* Tests whether or not this font is bold. |
411 |
* |
* |
412 |
* @return <code>true</code> if this font is italic, <code>false</code> |
* @return <code>true</code> if this font is bold, <code>false</code> |
413 |
* otherwise. |
* otherwise. |
414 |
*/ |
*/ |
415 |
public boolean isItalic () |
public boolean isBold() |
416 |
{ |
{ |
417 |
return peer.isItalic (this); |
return peer.isBold(this); |
418 |
} |
} |
419 |
|
|
420 |
/*************************************************************************/ |
/** |
421 |
|
* Tests whether or not this font is italic. |
422 |
|
* |
423 |
|
* @return <code>true</code> if this font is italic, <code>false</code> |
424 |
|
* otherwise. |
425 |
|
*/ |
426 |
|
public boolean isItalic() |
427 |
|
{ |
428 |
|
return peer.isItalic(this); |
429 |
|
} |
430 |
|
|
431 |
/** |
/** |
432 |
* Returns the family name of this font. A family name describes a design |
* Returns the family name of this font. A family name describes a design |
433 |
* or "brand name" (such as Helvetica or Palatino). It is less specific |
* or "brand name" (such as Helvetica or Palatino). It is less specific |
434 |
* than a font face name (such as Helvetica Bold). |
* than a font face name (such as Helvetica Bold). |
435 |
* |
* |
436 |
* @return A string containing the font family name. |
* @return A string containing the font family name. |
437 |
* |
* |
438 |
* @since 1.2 |
* @since 1.2 |
439 |
* |
* |
440 |
* @see #getName() |
* @see #getName() |
441 |
* @see #getFontName() |
* @see #getFontName() |
442 |
* @see GraphicsEnvironment#getAvailableFontFamilyNames() |
* @see GraphicsEnvironment#getAvailableFontFamilyNames() |
443 |
*/ |
*/ |
444 |
public String getFamily () |
public String getFamily() |
445 |
{ |
{ |
446 |
return peer.getFamily (this); |
return peer.getFamily(this); |
447 |
} |
} |
448 |
|
|
449 |
/** |
/** |
450 |
* Returns integer code representing the sum of style flags of this font, a |
* Returns integer code representing the sum of style flags of this font, a |
451 |
* combination of either {@link #PLAIN}, {@link #BOLD}, or {@link #ITALIC}. |
* combination of either {@link #PLAIN}, {@link #BOLD}, or {@link #ITALIC}. |
452 |
* |
* |
453 |
* @return code representing the style of this font. |
* @return code representing the style of this font. |
454 |
* |
* |
455 |
* @see #isPlain() |
* @see #isPlain() |
456 |
* @see #isBold() |
* @see #isBold() |
457 |
* @see #isItalic() |
* @see #isItalic() |
458 |
*/ |
*/ |
459 |
public int getStyle () |
public int getStyle() |
460 |
{ |
{ |
461 |
return peer.getStyle (this); |
return peer.getStyle(this); |
462 |
} |
} |
463 |
|
|
464 |
/** |
/** |
465 |
* Checks if specified character maps to a glyph in this font. |
* Checks if specified character maps to a glyph in this font. |
466 |
* |
* |
467 |
* @param c The character to check. |
* @param c The character to check. |
468 |
* |
* |
469 |
* @return Whether the character has a corresponding glyph in this font. |
* @return Whether the character has a corresponding glyph in this font. |
470 |
* |
* |
471 |
* @since 1.2 |
* @since 1.2 |
472 |
*/ |
*/ |
473 |
public boolean canDisplay (char c) |
public boolean canDisplay(char c) |
474 |
{ |
{ |
475 |
return peer.canDisplay (this, c); |
return peer.canDisplay(this, c); |
476 |
} |
} |
477 |
|
|
478 |
/** |
/** |
479 |
* Checks how much of a given string can be mapped to glyphs in |
* Checks how much of a given string can be mapped to glyphs in |
480 |
* this font. |
* this font. |
481 |
* |
* |
482 |
* @param s The string to check. |
* @param s The string to check. |
483 |
* |
* |
484 |
* @return The index of the first character in <code>s</code> which cannot |
* @return The index of the first character in <code>s</code> which cannot |
485 |
* be converted to a glyph by this font, or <code>-1</code> if all |
* be converted to a glyph by this font, or <code>-1</code> if all |
486 |
* characters can be mapped to glyphs. |
* characters can be mapped to glyphs. |
487 |
* |
* |
488 |
* @since 1.2 |
* @since 1.2 |
489 |
*/ |
*/ |
490 |
public int canDisplayUpTo (String s) |
public int canDisplayUpTo(String s) |
491 |
{ |
{ |
492 |
return peer.canDisplayUpTo (this, new StringCharacterIterator (s), |
return peer.canDisplayUpTo(this, new StringCharacterIterator(s), |
493 |
0, s.length () - 1); |
0, s.length() - 1); |
494 |
} |
} |
495 |
|
|
496 |
/** |
/** |
497 |
* Checks how much of a given sequence of text can be mapped to glyphs in |
* Checks how much of a given sequence of text can be mapped to glyphs in |
498 |
* this font. |
* this font. |
499 |
* |
* |
500 |
* @param text Array containing the text to check. |
* @param text Array containing the text to check. |
501 |
* @param start Position of first character to check in <code>text</code>. |
* @param start Position of first character to check in <code>text</code>. |
502 |
* @param limit Position of last character to check in <code>text</code>. |
* @param limit Position of last character to check in <code>text</code>. |
503 |
* |
* |
504 |
* @return The index of the first character in the indicated range which |
* @return The index of the first character in the indicated range which |
505 |
* cannot be converted to a glyph by this font, or <code>-1</code> if all |
* cannot be converted to a glyph by this font, or <code>-1</code> if all |
506 |
* characters can be mapped to glyphs. |
* characters can be mapped to glyphs. |
507 |
* |
* |
508 |
* @since 1.2 |
* @since 1.2 |
509 |
* |
* |
510 |
* @throws IndexOutOfBoundsException if the range [start, limit] is |
* @throws IndexOutOfBoundsException if the range [start, limit] is |
511 |
* invalid in <code>text</code>. |
* invalid in <code>text</code>. |
512 |
*/ |
*/ |
513 |
public int canDisplayUpTo (char[] text, int start, int limit) |
public int canDisplayUpTo (char[] text, int start, int limit) |
514 |
{ |
{ |
515 |
return peer.canDisplayUpTo |
return peer.canDisplayUpTo(this, |
516 |
(this, new StringCharacterIterator (new String (text)), start, limit); |
new StringCharacterIterator(new String (text)), |
517 |
} |
start, limit); |
518 |
|
} |
|
/** |
|
|
* Checks how much of a given sequence of text can be mapped to glyphs in |
|
|
* this font. |
|
|
* |
|
|
* @param i Iterator over the text to check. |
|
|
* @param start Position of first character to check in <code>i</code>. |
|
|
* @param limit Position of last character to check in <code>i</code>. |
|
|
* |
|
|
* @return The index of the first character in the indicated range which |
|
|
* cannot be converted to a glyph by this font, or <code>-1</code> if all |
|
|
* characters can be mapped to glyphs. |
|
|
* |
|
|
* @since 1.2 |
|
|
* |
|
|
* @throws IndexOutOfBoundsException if the range [start, limit] is |
|
|
* invalid in <code>i</code>. |
|
|
*/ |
|
|
public int canDisplayUpTo (CharacterIterator i, int start, int limit) |
|
|
{ |
|
|
return peer.canDisplayUpTo (this, i, start, limit); |
|
|
} |
|
519 |
|
|
520 |
/** |
/** |
521 |
* Creates a new font with point size 1 and {@link #PLAIN} style, |
* Checks how much of a given sequence of text can be mapped to glyphs in |
522 |
* reading font data from the provided input stream. The resulting font |
* this font. |
523 |
* can have further fonts derived from it using its |
* |
524 |
* <code>deriveFont</code> method. |
* @param i Iterator over the text to check. |
525 |
* |
* @param start Position of first character to check in <code>i</code>. |
526 |
* @param fontFormat Integer code indicating the format the font data is |
* @param limit Position of last character to check in <code>i</code>. |
527 |
* in.Currently this can only be {@link #TRUETYPE_FONT}. |
* |
528 |
* @param is {@link InputStream} from which font data will be read. This |
* @return The index of the first character in the indicated range which |
529 |
* stream is not closed after font data is extracted. |
* cannot be converted to a glyph by this font, or <code>-1</code> if all |
530 |
* |
* characters can be mapped to glyphs. |
531 |
* @return A new {@link Font} of the format indicated. |
* |
532 |
* |
* @since 1.2 |
533 |
* @throws IllegalArgumentException if <code>fontType</code> is not |
* |
534 |
* recognized. |
* @throws IndexOutOfBoundsException if the range [start, limit] is |
535 |
* @throws FontFormatException if data in InputStream is not of format |
* invalid in <code>i</code>. |
536 |
* indicated. |
*/ |
537 |
* @throws IOException if insufficient data is present on InputStream. |
public int canDisplayUpTo(CharacterIterator i, int start, int limit) |
538 |
* |
{ |
539 |
* @since 1.3 |
return peer.canDisplayUpTo(this, i, start, limit); |
540 |
*/ |
} |
|
public static Font createFont (int fontFormat, InputStream is) |
|
|
throws FontFormatException, IOException |
|
|
{ |
|
|
return tk().createFont (fontFormat, is); |
|
|
} |
|
541 |
|
|
542 |
/** |
/** |
543 |
* Maps characters to glyphs in a one-to-one relationship, returning a new |
* Creates a new font with point size 1 and {@link #PLAIN} style, |
544 |
* {@link GlyphVector} with a mapped glyph for each input character. This |
* reading font data from the provided input stream. The resulting font |
545 |
* sort of mapping is often sufficient for some scripts such as Roman, but |
* can have further fonts derived from it using its |
546 |
* is inappropriate for scripts with special shaping or contextual layout |
* <code>deriveFont</code> method. |
547 |
* requirements such as Arabic, Indic, Hebrew or Thai. |
* |
548 |
* |
* @param fontFormat Integer code indicating the format the font data is |
549 |
* @param ctx The rendering context used for precise glyph placement. |
* in.Currently this can only be {@link #TRUETYPE_FONT}. |
550 |
* @param str The string to convert to Glyphs. |
* @param is {@link InputStream} from which font data will be read. This |
551 |
* |
* stream is not closed after font data is extracted. |
552 |
* @return A new {@link GlyphVector} containing glyphs mapped from str, |
* |
553 |
* through the font's cmap table. |
* @return A new {@link Font} of the format indicated. |
554 |
* |
* |
555 |
* @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) |
* @throws IllegalArgumentException if <code>fontType</code> is not |
556 |
*/ |
* recognized. |
557 |
public GlyphVector createGlyphVector (FontRenderContext ctx, String str) |
* @throws FontFormatException if data in InputStream is not of format |
558 |
{ |
* indicated. |
559 |
return peer.createGlyphVector (this, ctx, new StringCharacterIterator (str)); |
* @throws IOException if insufficient data is present on InputStream. |
560 |
} |
* |
561 |
|
* @since 1.3 |
562 |
|
*/ |
563 |
|
public static Font createFont (int fontFormat, InputStream is) |
564 |
|
throws FontFormatException, IOException |
565 |
|
{ |
566 |
|
return tk().createFont(fontFormat, is); |
567 |
|
} |
568 |
|
|
569 |
/** |
/** |
570 |
* Maps characters to glyphs in a one-to-one relationship, returning a new |
* Maps characters to glyphs in a one-to-one relationship, returning a new |
571 |
* {@link GlyphVector} with a mapped glyph for each input character. This |
* {@link GlyphVector} with a mapped glyph for each input character. This |
572 |
* sort of mapping is often sufficient for some scripts such as Roman, but |
* sort of mapping is often sufficient for some scripts such as Roman, but |
573 |
* is inappropriate for scripts with special shaping or contextual layout |
* is inappropriate for scripts with special shaping or contextual layout |
574 |
* requirements such as Arabic, Indic, Hebrew or Thai. |
* requirements such as Arabic, Indic, Hebrew or Thai. |
575 |
* |
* |
576 |
* @param ctx The rendering context used for precise glyph placement. |
* @param ctx The rendering context used for precise glyph placement. |
577 |
* @param i Iterator over the text to convert to glyphs. |
* @param str The string to convert to Glyphs. |
578 |
* |
* |
579 |
* @return A new {@link GlyphVector} containing glyphs mapped from str, |
* @return A new {@link GlyphVector} containing glyphs mapped from str, |
580 |
* through the font's cmap table. |
* through the font's cmap table. |
581 |
* |
* |
582 |
* @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) |
* @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) |
583 |
*/ |
*/ |
584 |
public GlyphVector createGlyphVector (FontRenderContext ctx, CharacterIterator i) |
public GlyphVector createGlyphVector(FontRenderContext ctx, String str) |
585 |
{ |
{ |
586 |
return peer.createGlyphVector (this, ctx, i); |
return peer.createGlyphVector(this, ctx, new StringCharacterIterator(str)); |
587 |
} |
} |
588 |
|
|
589 |
/** |
/** |
590 |
* Maps characters to glyphs in a one-to-one relationship, returning a new |
* Maps characters to glyphs in a one-to-one relationship, returning a new |
591 |
* {@link GlyphVector} with a mapped glyph for each input character. This |
* {@link GlyphVector} with a mapped glyph for each input character. This |
592 |
* sort of mapping is often sufficient for some scripts such as Roman, but |
* sort of mapping is often sufficient for some scripts such as Roman, but |
593 |
* is inappropriate for scripts with special shaping or contextual layout |
* is inappropriate for scripts with special shaping or contextual layout |
594 |
* requirements such as Arabic, Indic, Hebrew or Thai. |
* requirements such as Arabic, Indic, Hebrew or Thai. |
595 |
* |
* |
596 |
* @param ctx The rendering context used for precise glyph placement. |
* @param ctx The rendering context used for precise glyph placement. |
597 |
* @param chars Array of characters to convert to glyphs. |
* @param i Iterator over the text to convert to glyphs. |
598 |
* |
* |
599 |
* @return A new {@link GlyphVector} containing glyphs mapped from str, |
* @return A new {@link GlyphVector} containing glyphs mapped from str, |
600 |
* through the font's cmap table. |
* through the font's cmap table. |
601 |
* |
* |
602 |
* @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) |
* @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) |
603 |
*/ |
*/ |
604 |
public GlyphVector createGlyphVector (FontRenderContext ctx, char[] chars) |
public GlyphVector createGlyphVector(FontRenderContext ctx, |
605 |
{ |
CharacterIterator i) |
606 |
return peer.createGlyphVector |
{ |
607 |
(this, ctx, new StringCharacterIterator (new String (chars))); |
return peer.createGlyphVector(this, ctx, i); |
608 |
} |
} |
609 |
|
|
610 |
/** |
/** |
611 |
* Extracts a sequence of glyphs from a font, returning a new {@link |
* Maps characters to glyphs in a one-to-one relationship, returning a new |
612 |
* GlyphVector} with a mapped glyph for each input glyph code. |
* {@link GlyphVector} with a mapped glyph for each input character. This |
613 |
* |
* sort of mapping is often sufficient for some scripts such as Roman, but |
614 |
* @param ctx The rendering context used for precise glyph placement. |
* is inappropriate for scripts with special shaping or contextual layout |
615 |
* @param glyphCodes Array of characters to convert to glyphs. |
* requirements such as Arabic, Indic, Hebrew or Thai. |
616 |
* |
* |
617 |
* @return A new {@link GlyphVector} containing glyphs mapped from str, |
* @param ctx The rendering context used for precise glyph placement. |
618 |
* through the font's cmap table. |
* @param chars Array of characters to convert to glyphs. |
619 |
* |
* |
620 |
* @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) |
* @return A new {@link GlyphVector} containing glyphs mapped from str, |
621 |
* |
* through the font's cmap table. |
622 |
* @specnote This method is documented to perform character-to-glyph |
* |
623 |
* conversions, in the Sun documentation, but its second parameter name is |
* @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) |
624 |
* "glyphCodes" and it is not clear to me why it would exist if its |
*/ |
625 |
* purpose was to transport character codes inside integers. I assume it |
public GlyphVector createGlyphVector(FontRenderContext ctx, char[] chars) |
626 |
* is mis-documented in the Sun documentation. |
{ |
627 |
*/ |
return peer.createGlyphVector(this, ctx, |
628 |
|
new StringCharacterIterator(new String(chars))); |
629 |
|
} |
630 |
|
|
631 |
public GlyphVector createGlyphVector (FontRenderContext ctx, int[] glyphCodes) |
/** |
632 |
{ |
* Extracts a sequence of glyphs from a font, returning a new {@link |
633 |
return peer.createGlyphVector (this, ctx, glyphCodes); |
* GlyphVector} with a mapped glyph for each input glyph code. |
634 |
} |
* |
635 |
|
* @param ctx The rendering context used for precise glyph placement. |
636 |
|
* @param glyphCodes Array of characters to convert to glyphs. |
637 |
|
* |
638 |
|
* @return A new {@link GlyphVector} containing glyphs mapped from str, |
639 |
|
* through the font's cmap table. |
640 |
|
* |
641 |
|
* @see #layoutGlyphVector(FontRenderContext, char[], int, int, int) |
642 |
|
* |
643 |
|
* @specnote This method is documented to perform character-to-glyph |
644 |
|
* conversions, in the Sun documentation, but its second parameter name is |
645 |
|
* "glyphCodes" and it is not clear to me why it would exist if its |
646 |
|
* purpose was to transport character codes inside integers. I assume it |
647 |
|
* is mis-documented in the Sun documentation. |
648 |
|
*/ |
649 |
|
public GlyphVector createGlyphVector(FontRenderContext ctx, int[] glyphCodes) |
650 |
|
{ |
651 |
|
return peer.createGlyphVector(this, ctx, glyphCodes); |
652 |
|
} |
653 |
|
|
654 |
/** |
/** |
655 |
* Produces a new {@link Font} based on the current font, adjusted to a |
* Produces a new {@link Font} based on the current font, adjusted to a |
656 |
* new size and style. |
* new size and style. |
657 |
* |
* |
658 |
* @param style The style of the newly created font. |
* @param style The style of the newly created font. |
659 |
* @param size The size of the newly created font. |
* @param size The size of the newly created font. |
660 |
* |
* |
661 |
* @return A clone of the current font, with the specified size and style. |
* @return A clone of the current font, with the specified size and style. |
662 |
* |
* |
663 |
* @since 1.2 |
* @since 1.2 |
664 |
*/ |
*/ |
665 |
public Font deriveFont (int style, float size) |
public Font deriveFont(int style, float size) |
666 |
{ |
{ |
667 |
return peer.deriveFont (this, style, size); |
return peer.deriveFont(this, style, size); |
668 |
} |
} |
669 |
|
|
670 |
/** |
/** |
671 |
* Produces a new {@link Font} based on the current font, adjusted to a |
* Produces a new {@link Font} based on the current font, adjusted to a |
672 |
* new size. |
* new size. |
673 |
* |
* |
674 |
* @param size The size of the newly created font. |
* @param size The size of the newly created font. |
675 |
* |
* |
676 |
* @return A clone of the current font, with the specified size. |
* @return A clone of the current font, with the specified size. |
677 |
* |
* |
678 |
* @since 1.2 |
* @since 1.2 |
679 |
*/ |
*/ |
680 |
public Font deriveFont (float size) |
public Font deriveFont(float size) |
681 |
{ |
{ |
682 |
return peer.deriveFont (this, size); |
return peer.deriveFont(this, size); |
683 |
} |
} |
684 |
|
|
685 |
/** |
/** |
686 |
* Produces a new {@link Font} based on the current font, adjusted to a |
* Produces a new {@link Font} based on the current font, adjusted to a |
687 |
* new style. |
* new style. |
688 |
* |
* |
689 |
* @param style The style of the newly created font. |
* @param style The style of the newly created font. |
690 |
* |
* |
691 |
* @return A clone of the current font, with the specified style. |
* @return A clone of the current font, with the specified style. |
692 |
* |
* |
693 |
* @since 1.2 |
* @since 1.2 |
694 |
*/ |
*/ |
695 |
public Font deriveFont (int style) |
public Font deriveFont(int style) |
696 |
{ |
{ |
697 |
return peer.deriveFont (this, style); |
return peer.deriveFont(this, style); |
698 |
} |
} |
699 |
|
|
700 |
/** |
/** |
701 |
* Produces a new {@link Font} based on the current font, adjusted to a |
* Produces a new {@link Font} based on the current font, adjusted to a |
702 |
* new style and subjected to a new affine transformation. |
* new style and subjected to a new affine transformation. |
703 |
* |
* |
704 |
* @param style The style of the newly created font. |
* @param style The style of the newly created font. |
705 |
* @param a The transformation to apply. |
* @param a The transformation to apply. |
706 |
* |
* |
707 |
* @return A clone of the current font, with the specified style and |
* @return A clone of the current font, with the specified style and |
708 |
* transform. |
* transform. |
709 |
* |
* |
710 |
* @throws IllegalArgumentException If transformation is |
* @throws IllegalArgumentException If transformation is |
711 |
* <code>null</code>. |
* <code>null</code>. |
712 |
* |
* |
713 |
* @since 1.2 |
* @since 1.2 |
714 |
*/ |
*/ |
715 |
public Font deriveFont (int style, AffineTransform a) |
public Font deriveFont(int style, AffineTransform a) |
716 |
{ |
{ |
717 |
if (a == null) |
if (a == null) |
718 |
throw new IllegalArgumentException ("Affine transformation is null"); |
throw new IllegalArgumentException("Affine transformation is null"); |
719 |
|
|
720 |
return peer.deriveFont (this, style, a); |
return peer.deriveFont(this, style, a); |
721 |
} |
} |
722 |
|
|
723 |
/** |
/** |
724 |
* Produces a new {@link Font} based on the current font, subjected |
* Produces a new {@link Font} based on the current font, subjected |
725 |
* to a new affine transformation. |
* to a new affine transformation. |
726 |
* |
* |
727 |
* @param a The transformation to apply. |
* @param a The transformation to apply. |
728 |
* |
* |
729 |
* @return A clone of the current font, with the specified transform. |
* @return A clone of the current font, with the specified transform. |
730 |
* |
* |
731 |
* @throws IllegalArgumentException If transformation is |
* @throws IllegalArgumentException If transformation is |
732 |
* <code>null</code>. |
* <code>null</code>. |
733 |
* |
* |
734 |
* @since 1.2 |
* @since 1.2 |
735 |
*/ |
*/ |
736 |
public Font deriveFont (AffineTransform a) |
public Font deriveFont(AffineTransform a) |
737 |
{ |
{ |
738 |
if (a == null) |
if (a == null) |
739 |
throw new IllegalArgumentException ("Affine transformation is null"); |
throw new IllegalArgumentException("Affine transformation is null"); |
740 |
|
|
741 |
return peer.deriveFont (this, a); |
return peer.deriveFont(this, a); |
742 |
} |
} |
743 |
|
|
744 |
/** |
/** |
745 |
* Produces a new {@link Font} based on the current font, adjusted to a |
* Produces a new {@link Font} based on the current font, adjusted to a |
746 |
* new set of attributes. |
* new set of attributes. |
747 |
* |
* |
748 |
* @param attributes Attributes of the newly created font. |
* @param attributes Attributes of the newly created font. |
749 |
* |
* |
750 |
* @return A clone of the current font, with the specified attributes. |
* @return A clone of the current font, with the specified attributes. |
751 |
* |
* |
752 |
* @since 1.2 |
* @since 1.2 |
753 |
*/ |
*/ |
754 |
public Font deriveFont (Map attributes) |
public Font deriveFont(Map attributes) |
755 |
{ |
{ |
756 |
return peer.deriveFont (this, attributes); |
return peer.deriveFont(this, attributes); |
757 |
} |
} |
758 |
|
|
759 |
/** |
/** |
760 |
* Returns a map of chracter attributes which this font currently has set. |
* Returns a map of chracter attributes which this font currently has set. |
761 |
* |
* |
762 |
* @return A map of chracter attributes which this font currently has set. |
* @return A map of chracter attributes which this font currently has set. |
763 |
* |
* |
764 |
* @see #getAvailableAttributes() |
* @see #getAvailableAttributes() |
765 |
* @see java.text.AttributedCharacterIterator.Attribute |
* @see java.text.AttributedCharacterIterator.Attribute |
766 |
* @see java.awt.font.TextAttribute |
* @see java.awt.font.TextAttribute |
767 |
*/ |
*/ |
768 |
public Map getAttributes () |
public Map getAttributes() |
769 |
{ |
{ |
770 |
return peer.getAttributes (this); |
return peer.getAttributes(this); |
771 |
} |
} |
772 |
|
|
773 |
/** |
/** |
774 |
* Returns an array of chracter attribute keys which this font understands. |
* Returns an array of chracter attribute keys which this font understands. |
775 |
* |
* |
776 |
* @return An array of chracter attribute keys which this font understands. |
* @return An array of chracter attribute keys which this font understands. |
777 |
* |
* |
778 |
* @see #getAttributes() |
* @see #getAttributes() |
779 |
* @see java.text.AttributedCharacterIterator.Attribute |
* @see java.text.AttributedCharacterIterator.Attribute |
780 |
* @see java.awt.font.TextAttribute |
* @see java.awt.font.TextAttribute |
781 |
*/ |
*/ |
782 |
public AttributedCharacterIterator.Attribute[] getAvailableAttributes() |
public AttributedCharacterIterator.Attribute[] getAvailableAttributes() |
783 |
{ |
{ |
784 |
return peer.getAvailableAttributes (this); |
return peer.getAvailableAttributes(this); |
785 |
} |
} |
786 |
|
|
787 |
/** |
/** |
788 |
* Returns a baseline code (one of {@link #ROMAN_BASELINE}, {@link |
* Returns a baseline code (one of {@link #ROMAN_BASELINE}, {@link |
789 |
* #CENTER_BASELINE} or {@link #HANGING_BASELINE}) indicating which baseline |
* #CENTER_BASELINE} or {@link #HANGING_BASELINE}) indicating which baseline |
790 |
* this font will measure baseline offsets for, when presenting glyph |
* this font will measure baseline offsets for, when presenting glyph |
791 |
* metrics for a given character. |
* metrics for a given character. |
792 |
* |
* |
793 |
* Baseline offsets describe the position of a glyph relative to an |
* Baseline offsets describe the position of a glyph relative to an |
794 |
* invisible line drawn under, through the center of, or over a line of |
* invisible line drawn under, through the center of, or over a line of |
795 |
* rendered text, respectively. Different scripts use different baseline |
* rendered text, respectively. Different scripts use different baseline |
796 |
* modes, so clients should not assume all baseline offsets in a glyph |
* modes, so clients should not assume all baseline offsets in a glyph |
797 |
* vector are from a common baseline. |
* vector are from a common baseline. |
798 |
* |
* |
799 |
* @param c The character code to select a baseline mode for. |
* @param c The character code to select a baseline mode for. |
800 |
* |
* |
801 |
* @return The baseline mode which would be used in a glyph associated |
* @return The baseline mode which would be used in a glyph associated |
802 |
* with the provided character. |
* with the provided character. |
803 |
* |
* |
804 |
* @since 1.2 |
* @since 1.2 |
805 |
* |
* |
806 |
* @see LineMetrics#getBaselineOffsets() |
* @see LineMetrics#getBaselineOffsets() |
807 |
*/ |
*/ |
808 |
public byte getBaselineFor (char c) |
public byte getBaselineFor(char c) |
809 |
{ |
{ |
810 |
return peer.getBaselineFor (this, c); |
return peer.getBaselineFor(this, c); |
811 |
} |
} |
812 |
|
|
813 |
/** |
/** |
814 |
* Returns the family name of this font. A family name describes a |
* Returns the family name of this font. A family name describes a |
815 |
* typographic style (such as Helvetica or Palatino). It is more specific |
* typographic style (such as Helvetica or Palatino). It is more specific |
816 |
* than a logical font name (such as Sans Serif) but less specific than a |
* than a logical font name (such as Sans Serif) but less specific than a |
817 |
* font face name (such as Helvetica Bold). |
* font face name (such as Helvetica Bold). |
818 |
* |
* |
819 |
* @param lc The locale in which to describe the name of the font family. |
* @param lc The locale in which to describe the name of the font family. |
820 |
* |
* |
821 |
* @return A string containing the font family name, localized for the |
* @return A string containing the font family name, localized for the |
822 |
* provided locale. |
* provided locale. |
823 |
* |
* |
824 |
* @since 1.2 |
* @since 1.2 |
825 |
* |
* |
826 |
* @see #getName() |
* @see #getName() |
827 |
* @see #getFontName() |
* @see #getFontName() |
828 |
* @see GraphicsEnvironment#getAvailableFontFamilyNames() |
* @see GraphicsEnvironment#getAvailableFontFamilyNames() |
829 |
* @see Locale |
* @see Locale |
830 |
*/ |
*/ |
831 |
public String getFamily (Locale lc) |
public String getFamily(Locale lc) |
832 |
{ |
{ |
833 |
return peer.getFamily (this, lc); |
return peer.getFamily(this, lc); |
834 |
} |
} |
835 |
|
|
836 |
/** |
/** |
837 |
* Returns a font appropriate for the given attribute set. |
* Returns a font appropriate for the given attribute set. |
838 |
* |
* |
839 |
* @param attributes The attributes required for the new font. |
* @param attributes The attributes required for the new font. |
840 |
* |
* |
841 |
* @return A new Font with the given attributes. |
* @return A new Font with the given attributes. |
842 |
* |
* |
843 |
* @since 1.2 |
* @since 1.2 |
844 |
* |
* |
845 |
* @see java.awt.font.TextAttribute |
* @see java.awt.font.TextAttribute |
846 |
*/ |
*/ |
847 |
public static Font getFont (Map attributes) |
public static Font getFont(Map attributes) |
848 |
{ |
{ |
849 |
return getFontFromToolkit (null, attributes); |
return getFontFromToolkit(null, attributes); |
850 |
} |
} |
851 |
|
|
852 |
/** |
/** |
853 |
* Returns the font face name of the font. A font face name describes a |
* Returns the font face name of the font. A font face name describes a |
854 |
* specific variant of a font family (such as Helvetica Bold). It is more |
* specific variant of a font family (such as Helvetica Bold). It is more |
855 |
* specific than both a font family name (such as Helvetica) and a logical |
* specific than both a font family name (such as Helvetica) and a logical |
856 |
* font name (such as Sans Serif). |
* font name (such as Sans Serif). |
857 |
* |
* |
858 |
* @return The font face name of the font. |
* @return The font face name of the font. |
859 |
* |
* |
860 |
* @since 1.2 |
* @since 1.2 |
861 |
* |
* |
862 |
* @see #getName() |
* @see #getName() |
863 |
* @see #getFamily() |
* @see #getFamily() |
864 |
*/ |
*/ |
865 |
public String getFontName () |
public String getFontName() |
866 |
{ |
{ |
867 |
return peer.getFontName (this); |
return peer.getFontName(this); |
868 |
} |
} |
869 |
|
|
870 |
/** |
/** |
871 |
* Returns the font face name of the font. A font face name describes a |
* Returns the font face name of the font. A font face name describes a |
872 |
* specific variant of a font family (such as Helvetica Bold). It is more |
* specific variant of a font family (such as Helvetica Bold). It is more |
873 |
* specific than both a font family name (such as Helvetica). |
* specific than both a font family name (such as Helvetica). |
874 |
* |
* |
875 |
* @param lc The locale in which to describe the name of the font face. |
* @param lc The locale in which to describe the name of the font face. |
876 |
* |
* |
877 |
* @return A string containing the font face name, localized for the |
* @return A string containing the font face name, localized for the |
878 |
* provided locale. |
* provided locale. |
879 |
* |
* |
880 |
* @since 1.2 |
* @since 1.2 |
881 |
* |
* |
882 |
* @see #getName() |
* @see #getName() |
883 |
* @see #getFamily() |
* @see #getFamily() |
884 |
*/ |
*/ |
885 |
public String getFontName (Locale lc) |
public String getFontName(Locale lc) |
886 |
{ |
{ |
887 |
return peer.getFontName (this, lc); |
return peer.getFontName(this, lc); |
888 |
} |
} |
889 |
|
|
890 |
/** |
/** |
891 |
* Returns the italic angle of this font, a measurement of its slant when |
* Returns the italic angle of this font, a measurement of its slant when |
892 |
* style is {@link #ITALIC}. The precise meaning is the inverse slope of a |
* style is {@link #ITALIC}. The precise meaning is the inverse slope of a |
893 |
* caret line which "best measures" the font's italic posture. |
* caret line which "best measures" the font's italic posture. |
894 |
* |
* |
895 |
* @return The italic angle. |
* @return The italic angle. |
896 |
* |
* |
897 |
* @see java.awt.font.TextAttribute#POSTURE |
* @see java.awt.font.TextAttribute#POSTURE |
898 |
*/ |
*/ |
899 |
public float getItalicAngle () |
public float getItalicAngle() |
900 |
{ |
{ |
901 |
return peer.getItalicAngle (this); |
return peer.getItalicAngle(this); |
902 |
} |
} |
903 |
|
|
904 |
/** |
/** |
905 |
* Returns a {@link LineMetrics} object constructed with the specified |
* Returns a {@link LineMetrics} object constructed with the specified |
906 |
* text and {@link FontRenderContext}. |
* text and {@link FontRenderContext}. |
907 |
* |
* |
908 |
* @param text The string to calculate metrics from. |
* @param text The string to calculate metrics from. |
909 |
* @param begin Index of first character in <code>text</code> to measure. |
* @param begin Index of first character in <code>text</code> to measure. |
910 |
* @param limit Index of last character in <code>text</code> to measure. |
* @param limit Index of last character in <code>text</code> to measure. |
911 |
* @param rc Context for calculating precise glyph placement and hints. |
* @param rc Context for calculating precise glyph placement and hints. |
912 |
* |
* |
913 |
* @return A new {@link LineMetrics} object. |
* @return A new {@link LineMetrics} object. |
914 |
* |
* |
915 |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
916 |
* invalid in <code>text</code>. |
* invalid in <code>text</code>. |
917 |
*/ |
*/ |
918 |
public LineMetrics getLineMetrics(String text, int begin, |
public LineMetrics getLineMetrics(String text, int begin, |
919 |
int limit, FontRenderContext rc) |
int limit, FontRenderContext rc) |
920 |
{ |
{ |
921 |
return peer.getLineMetrics (this, new StringCharacterIterator (text), |
return peer.getLineMetrics(this, new StringCharacterIterator(text), |
922 |
begin, limit, rc); |
begin, limit, rc); |
923 |
} |
} |
924 |
|
|
925 |
/** |
/** |
926 |
* Returns a {@link LineMetrics} object constructed with the specified |
* Returns a {@link LineMetrics} object constructed with the specified |
927 |
* text and {@link FontRenderContext}. |
* text and {@link FontRenderContext}. |
928 |
* |
* |
929 |
* @param chars The string to calculate metrics from. |
* @param chars The string to calculate metrics from. |
930 |
* @param begin Index of first character in <code>text</code> to measure. |
* @param begin Index of first character in <code>text</code> to measure. |
931 |
* @param limit Index of last character in <code>text</code> to measure. |
* @param limit Index of last character in <code>text</code> to measure. |
932 |
* @param rc Context for calculating precise glyph placement and hints. |
* @param rc Context for calculating precise glyph placement and hints. |
933 |
* |
* |
934 |
* @return A new {@link LineMetrics} object. |
* @return A new {@link LineMetrics} object. |
935 |
* |
* |
936 |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
937 |
* invalid in <code>chars</code>. |
* invalid in <code>chars</code>. |
938 |
*/ |
*/ |
939 |
public LineMetrics getLineMetrics(char[] chars, int begin, |
public LineMetrics getLineMetrics(char[] chars, int begin, |
940 |
int limit, FontRenderContext rc) |
int limit, FontRenderContext rc) |
941 |
{ |
{ |
942 |
return peer.getLineMetrics (this, new StringCharacterIterator (new String(chars)), |
return peer.getLineMetrics(this, |
943 |
begin, limit, rc); |
new StringCharacterIterator(new String(chars)), |
944 |
} |
begin, limit, rc); |
945 |
|
} |
946 |
|
|
947 |
/** |
/** |
948 |
* Returns a {@link LineMetrics} object constructed with the specified |
* Returns a {@link LineMetrics} object constructed with the specified |
949 |
* text and {@link FontRenderContext}. |
* text and {@link FontRenderContext}. |
950 |
* |
* |
951 |
* @param ci The string to calculate metrics from. |
* @param ci The string to calculate metrics from. |
952 |
* @param begin Index of first character in <code>text</code> to measure. |
* @param begin Index of first character in <code>text</code> to measure. |
953 |
* @param limit Index of last character in <code>text</code> to measure. |
* @param limit Index of last character in <code>text</code> to measure. |
954 |
* @param rc Context for calculating precise glyph placement and hints. |
* @param rc Context for calculating precise glyph placement and hints. |
955 |
* |
* |
956 |
* @return A new {@link LineMetrics} object. |
* @return A new {@link LineMetrics} object. |
957 |
* |
* |
958 |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
959 |
* invalid in <code>ci</code>. |
* invalid in <code>ci</code>. |
960 |
*/ |
*/ |
961 |
public LineMetrics getLineMetrics (CharacterIterator ci, int begin, |
public LineMetrics getLineMetrics(CharacterIterator ci, int begin, |
962 |
int limit, FontRenderContext rc) |
int limit, FontRenderContext rc) |
963 |
{ |
{ |
964 |
return peer.getLineMetrics (this, ci, begin, limit, rc); |
return peer.getLineMetrics(this, ci, begin, limit, rc); |
965 |
} |
} |
966 |
|
|
967 |
/** |
/** |
968 |
* Returns the maximal bounding box of all the bounding boxes in this |
* Returns the maximal bounding box of all the bounding boxes in this |
969 |
* font, when the font's bounding boxes are evaluated in a given {@link |
* font, when the font's bounding boxes are evaluated in a given {@link |
970 |
* FontRenderContext} |
* FontRenderContext} |
971 |
* |
* |
972 |
* @param rc Context in which to evaluate bounding boxes. |
* @param rc Context in which to evaluate bounding boxes. |
973 |
* |
* |
974 |
* @return The maximal bounding box. |
* @return The maximal bounding box. |
975 |
*/ |
*/ |
976 |
public Rectangle2D getMaxCharBounds (FontRenderContext rc) |
public Rectangle2D getMaxCharBounds(FontRenderContext rc) |
977 |
{ |
{ |
978 |
return peer.getMaxCharBounds (this, rc); |
return peer.getMaxCharBounds(this, rc); |
979 |
} |
} |
980 |
|
|
981 |
/** |
/** |
982 |
* Returns the glyph code this font uses to represent missing glyphs. This |
* Returns the glyph code this font uses to represent missing glyphs. This |
983 |
* code will be present in glyph vectors when the font was unable to |
* code will be present in glyph vectors when the font was unable to |
984 |
* locate a glyph to represent a particular character code. |
* locate a glyph to represent a particular character code. |
985 |
* |
* |
986 |
* @return The missing glyph code. |
* @return The missing glyph code. |
987 |
* |
* |
988 |
* @since 1.2 |
* @since 1.2 |
989 |
*/ |
*/ |
990 |
public int getMissingGlyphCode () |
public int getMissingGlyphCode() |
991 |
{ |
{ |
992 |
return peer.getMissingGlyphCode (this); |
return peer.getMissingGlyphCode(this); |
993 |
} |
} |
994 |
|
|
995 |
/** |
/** |
996 |
* Returns the overall number of glyphs in this font. This number is one |
* Returns the overall number of glyphs in this font. This number is one |
997 |
* more than the greatest glyph code used in any glyph vectors this font |
* more than the greatest glyph code used in any glyph vectors this font |
998 |
* produces. In other words, glyph codes are taken from the range |
* produces. In other words, glyph codes are taken from the range |
999 |
* <code>[ 0, getNumGlyphs() - 1 ]</code>. |
* <code>[ 0, getNumGlyphs() - 1 ]</code>. |
1000 |
* |
* |
1001 |
* @return The number of glyphs in this font. |
* @return The number of glyphs in this font. |
1002 |
* |
* |
1003 |
* @since 1.2 |
* @since 1.2 |
1004 |
*/ |
*/ |
1005 |
public int getNumGlyphs () |
public int getNumGlyphs() |
1006 |
{ |
{ |
1007 |
return peer.getMissingGlyphCode (this); |
return peer.getMissingGlyphCode(this); |
1008 |
} |
} |
1009 |
|
|
1010 |
/** |
/** |
1011 |
* Returns the PostScript Name of this font. |
* Returns the PostScript Name of this font. |
1012 |
* |
* |
1013 |
* @return The PostScript Name of this font. |
* @return The PostScript Name of this font. |
1014 |
* |
* |
1015 |
* @since 1.2 |
* @since 1.2 |
1016 |
* |
* |
1017 |
* @see #getName() |
* @see #getName() |
1018 |
* @see #getFamily() |
* @see #getFamily() |
1019 |
* @see #getFontName() |
* @see #getFontName() |
1020 |
*/ |
*/ |
1021 |
public String getPSName () |
public String getPSName() |
1022 |
{ |
{ |
1023 |
return peer.getPostScriptName (this); |
return peer.getPostScriptName(this); |
1024 |
} |
} |
1025 |
|
|
1026 |
/** |
/** |
1027 |
* Returns the logical bounds of the specified string when rendered with this |
* Returns the logical bounds of the specified string when rendered with this |
1028 |
* font in the specified {@link FontRenderContext}. This box will include the |
* font in the specified {@link FontRenderContext}. This box will include the |
1029 |
* glyph origin, ascent, advance, height, and leading, but may not include all |
* glyph origin, ascent, advance, height, and leading, but may not include all |
1030 |
* diacritics or accents. To get the complete visual bounding box of all the |
* diacritics or accents. To get the complete visual bounding box of all the |
1031 |
* glyphs in a run of text, use the {@link TextLayout#getBounds} method of |
* glyphs in a run of text, use the {@link TextLayout#getBounds} method of |
1032 |
* {@link TextLayout}. |
* {@link TextLayout}. |
1033 |
* |
* |
1034 |
* @param str The string to measure. |
* @param str The string to measure. |
1035 |
* @param frc The context in which to make the precise glyph measurements. |
* @param frc The context in which to make the precise glyph measurements. |
1036 |
* |
* |
1037 |
* @return A bounding box covering the logical bounds of the specified text. |
* @return A bounding box covering the logical bounds of the specified text. |
1038 |
* |
* |
1039 |
* @see #createGlyphVector(FontRenderContext, String) |
* @see #createGlyphVector(FontRenderContext, String) |
1040 |
*/ |
*/ |
1041 |
public Rectangle2D getStringBounds (String str, FontRenderContext frc) |
public Rectangle2D getStringBounds(String str, FontRenderContext frc) |
1042 |
{ |
{ |
1043 |
return getStringBounds (str, 0, str.length () - 1, frc); |
return getStringBounds(str, 0, str.length() - 1, frc); |
1044 |
} |
} |
1045 |
|
|
1046 |
/** |
/** |
1047 |
* Returns the logical bounds of the specified string when rendered with this |
* Returns the logical bounds of the specified string when rendered with this |
1048 |
* font in the specified {@link FontRenderContext}. This box will include the |
* font in the specified {@link FontRenderContext}. This box will include the |
1049 |
* glyph origin, ascent, advance, height, and leading, but may not include all |
* glyph origin, ascent, advance, height, and leading, but may not include all |
1050 |
* diacritics or accents. To get the complete visual bounding box of all the |
* diacritics or accents. To get the complete visual bounding box of all the |
1051 |
* glyphs in a run of text, use the {@link TextLayout#getBounds} method of |
* glyphs in a run of text, use the {@link TextLayout#getBounds} method of |
1052 |
* {@link TextLayout}. |
* {@link TextLayout}. |
1053 |
* |
* |
1054 |
* @param str The string to measure. |
* @param str The string to measure. |
1055 |
* @param begin Index of the first character in <code>str</code> to measure. |
* @param begin Index of the first character in <code>str</code> to measure. |
1056 |
* @param limit Index of the last character in <code>str</code> to measure. |
* @param limit Index of the last character in <code>str</code> to measure. |
1057 |
* @param frc The context in which to make the precise glyph measurements. |
* @param frc The context in which to make the precise glyph measurements. |
1058 |
* |
* |
1059 |
* @return A bounding box covering the logical bounds of the specified text. |
* @return A bounding box covering the logical bounds of the specified text. |
1060 |
* |
* |
1061 |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
1062 |
* invalid in <code>str</code>. |
* invalid in <code>str</code>. |
1063 |
* |
* |
1064 |
* @since 1.2 |
* @since 1.2 |
1065 |
* |
* |
1066 |
* @see #createGlyphVector(FontRenderContext, String) |
* @see #createGlyphVector(FontRenderContext, String) |
1067 |
*/ |
*/ |
1068 |
public Rectangle2D getStringBounds (String str, int begin, |
public Rectangle2D getStringBounds(String str, int begin, |
1069 |
int limit, FontRenderContext frc) |
int limit, FontRenderContext frc) |
1070 |
{ |
{ |
1071 |
return peer.getStringBounds (this, new StringCharacterIterator(str), begin, limit, frc); |
return peer.getStringBounds(this, new StringCharacterIterator(str), begin, |
1072 |
} |
limit, frc); |
1073 |
|
} |
1074 |
|
|
1075 |
/** |
/** |
1076 |
* Returns the logical bounds of the specified string when rendered with this |
* Returns the logical bounds of the specified string when rendered with this |
1077 |
* font in the specified {@link FontRenderContext}. This box will include the |
* font in the specified {@link FontRenderContext}. This box will include the |
1078 |
* glyph origin, ascent, advance, height, and leading, but may not include all |
* glyph origin, ascent, advance, height, and leading, but may not include all |
1079 |
* diacritics or accents. To get the complete visual bounding box of all the |
* diacritics or accents. To get the complete visual bounding box of all the |
1080 |
* glyphs in a run of text, use the {@link TextLayout#getBounds} method of |
* glyphs in a run of text, use the {@link TextLayout#getBounds} method of |
1081 |
* {@link TextLayout}. |
* {@link TextLayout}. |
1082 |
* |
* |
1083 |
* @param ci The text to measure. |
* @param ci The text to measure. |
1084 |
* @param begin Index of the first character in <code>ci</code> to measure. |
* @param begin Index of the first character in <code>ci</code> to measure. |
1085 |
* @param limit Index of the last character in <code>ci</code> to measure. |
* @param limit Index of the last character in <code>ci</code> to measure. |
1086 |
* @param frc The context in which to make the precise glyph measurements. |
* @param frc The context in which to make the precise glyph measurements. |
1087 |
* |
* |
1088 |
* @return A bounding box covering the logical bounds of the specified text. |
* @return A bounding box covering the logical bounds of the specified text. |
1089 |
* |
* |
1090 |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
1091 |
* invalid in <code>ci</code>. |
* invalid in <code>ci</code>. |
1092 |
* |
* |
1093 |
* @since 1.2 |
* @since 1.2 |
1094 |
* |
* |
1095 |
* @see #createGlyphVector(FontRenderContext, CharacterIterator) |
* @see #createGlyphVector(FontRenderContext, CharacterIterator) |
1096 |
*/ |
*/ |
1097 |
public Rectangle2D getStringBounds (CharacterIterator ci, int begin, |
public Rectangle2D getStringBounds(CharacterIterator ci, int begin, |
1098 |
int limit, FontRenderContext frc) |
int limit, FontRenderContext frc) |
1099 |
{ |
{ |
1100 |
return peer.getStringBounds (this, ci, begin, limit, frc); |
return peer.getStringBounds(this, ci, begin, limit, frc); |
1101 |
} |
} |
1102 |
|
|
1103 |
/** |
/** |
1104 |
* Returns the logical bounds of the specified string when rendered with this |
* Returns the logical bounds of the specified string when rendered with this |
1105 |
* font in the specified {@link FontRenderContext}. This box will include the |
* font in the specified {@link FontRenderContext}. This box will include the |
1106 |
* glyph origin, ascent, advance, height, and leading, but may not include all |
* glyph origin, ascent, advance, height, and leading, but may not include all |
1107 |
* diacritics or accents. To get the complete visual bounding box of all the |
* diacritics or accents. To get the complete visual bounding box of all the |
1108 |
* glyphs in a run of text, use the {@link TextLayout#getBounds} method of |
* glyphs in a run of text, use the {@link TextLayout#getBounds} method of |
1109 |
* {@link TextLayout}. |
* {@link TextLayout}. |
1110 |
* |
* |
1111 |
* @param chars The text to measure. |
* @param chars The text to measure. |
1112 |
* @param begin Index of the first character in <code>ci</code> to measure. |
* @param begin Index of the first character in <code>ci</code> to measure. |
1113 |
* @param limit Index of the last character in <code>ci</code> to measure. |
* @param limit Index of the last character in <code>ci</code> to measure. |
1114 |
* @param frc The context in which to make the precise glyph measurements. |
* @param frc The context in which to make the precise glyph measurements. |
1115 |
* |
* |
1116 |
* @return A bounding box covering the logical bounds of the specified text. |
* @return A bounding box covering the logical bounds of the specified text. |
1117 |
* |
* |
1118 |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
1119 |
* invalid in <code>chars</code>. |
* invalid in <code>chars</code>. |
1120 |
* |
* |
1121 |
* @since 1.2 |
* @since 1.2 |
1122 |
* |
* |
1123 |
* @see #createGlyphVector(FontRenderContext, char[]) |
* @see #createGlyphVector(FontRenderContext, char[]) |
1124 |
*/ |
*/ |
1125 |
public Rectangle2D getStringBounds (char[] chars, int begin, |
public Rectangle2D getStringBounds(char[] chars, int begin, |
1126 |
int limit, FontRenderContext frc) |
int limit, FontRenderContext frc) |
1127 |
{ |
{ |
1128 |
return peer.getStringBounds (this, new StringCharacterIterator (new String (chars)), |
return peer.getStringBounds(this, |
1129 |
begin, limit, frc); |
new StringCharacterIterator(new String(chars)), |
1130 |
} |
begin, limit, frc); |
1131 |
|
} |
1132 |
|
|
1133 |
/** |
/** |
1134 |
* Returns a copy of the affine transformation this font is currently |
* Returns a copy of the affine transformation this font is currently |
1135 |
* subject to, if any. |
* subject to, if any. |
1136 |
* |
* |
1137 |
* @return The current transformation. |
* @return The current transformation. |
1138 |
*/ |
*/ |
1139 |
public AffineTransform getTransform () |
public AffineTransform getTransform() |
1140 |
{ |
{ |
1141 |
return peer.getTransform (this); |
return peer.getTransform(this); |
1142 |
} |
} |
1143 |
|
|
1144 |
/** |
/** |
1145 |
* Indicates whether this font's line metrics are uniform. A font may be |
* Indicates whether this font's line metrics are uniform. A font may be |
1146 |
* composed of several "subfonts", each covering a different code range, |
* composed of several "subfonts", each covering a different code range, |
1147 |
* and each with their own line metrics. A font with no subfonts, or |
* and each with their own line metrics. A font with no subfonts, or |
1148 |
* subfonts with identical line metrics, is said to have "uniform" line |
* subfonts with identical line metrics, is said to have "uniform" line |
1149 |
* metrics. |
* metrics. |
1150 |
* |
* |
1151 |
* @return Whether this font has uniform line metrics. |
* @return Whether this font has uniform line metrics. |
1152 |
* |
* |
1153 |
* @see LineMetrics |
* @see LineMetrics |
1154 |
* @see #getLineMetrics(String, FontRenderContext) |
* @see #getLineMetrics(String, FontRenderContext) |
1155 |
*/ |
*/ |
1156 |
public boolean hasUniformLineMetrics () |
public boolean hasUniformLineMetrics() |
1157 |
{ |
{ |
1158 |
return peer.hasUniformLineMetrics (this); |
return peer.hasUniformLineMetrics(this); |
1159 |
} |
} |
1160 |
|
|
1161 |
/** |
/** |
1162 |
* Indicates whether this font is subject to a non-identity affine |
* Indicates whether this font is subject to a non-identity affine |
1163 |
* transformation. |
* transformation. |
1164 |
* |
* |
1165 |
* @return <code>true</code> iff the font has a non-identity affine |
* @return <code>true</code> iff the font has a non-identity affine |
1166 |
* transformation applied to it. |
* transformation applied to it. |
1167 |
*/ |
*/ |
1168 |
public boolean isTransformed () |
public boolean isTransformed() |
1169 |
{ |
{ |
1170 |
return peer.isTransformed (this); |
return peer.isTransformed(this); |
1171 |
} |
} |
1172 |
|
|
1173 |
/** |
/** |
1174 |
* Produces a glyph vector representing a full layout fo the specified |
* Produces a glyph vector representing a full layout fo the specified |
1175 |
* text in this font. Full layouts may include complex shaping and |
* text in this font. Full layouts may include complex shaping and |
1176 |
* reordering operations, for scripts such as Arabic or Hindi. |
* reordering operations, for scripts such as Arabic or Hindi. |
1177 |
* |
* |
1178 |
* Bidirectional (bidi) layout is not performed in this method; text |
* Bidirectional (bidi) layout is not performed in this method; text |
1179 |
* should have its bidi direction specified with one of the flags {@link |
* should have its bidi direction specified with one of the flags {@link |
1180 |
* #LAYOUT_LEFT_TO_RIGHT} or {@link #LAYOUT_RIGHT_TO_LEFT}. |
* #LAYOUT_LEFT_TO_RIGHT} or {@link #LAYOUT_RIGHT_TO_LEFT}. |
1181 |
* |
* |
1182 |
* Some types of layout (notably Arabic glyph shaping) may examine context |
* Some types of layout (notably Arabic glyph shaping) may examine context |
1183 |
* characters beyond the bounds of the indicated range, in order to select |
* characters beyond the bounds of the indicated range, in order to select |
1184 |
* an appropriate shape. The flags {@link #LAYOUT_NO_START_CONTEXT} and |
* an appropriate shape. The flags {@link #LAYOUT_NO_START_CONTEXT} and |
1185 |
* {@link #LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra |
* {@link #LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra |
1186 |
* context areas from being examined, for instance if they contain invalid |
* context areas from being examined, for instance if they contain invalid |
1187 |
* characters. |
* characters. |
1188 |
* |
* |
1189 |
* @param frc Context in which to perform the layout. |
* @param frc Context in which to perform the layout. |
1190 |
* @param chars Text to perform layout on. |
* @param chars Text to perform layout on. |
1191 |
* @param start Index of first character to perform layout on. |
* @param start Index of first character to perform layout on. |
1192 |
* @param limit Index of last character to perform layout on. |
* @param limit Index of last character to perform layout on. |
1193 |
* @param flags Combination of flags controlling layout. |
* @param flags Combination of flags controlling layout. |
1194 |
* |
* |
1195 |
* @return A new {@link GlyphVector} representing the specified text. |
* @return A new {@link GlyphVector} representing the specified text. |
1196 |
* |
* |
1197 |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
* @throws IndexOutOfBoundsException if the range [begin, limit] is |
1198 |
* invalid in <code>chars</code>. |
* invalid in <code>chars</code>. |
1199 |
*/ |
*/ |
1200 |
public GlyphVector layoutGlyphVector (FontRenderContext frc, |
public GlyphVector layoutGlyphVector(FontRenderContext frc, |
1201 |
char[] chars, int start, |
char[] chars, int start, |
1202 |
int limit, int flags) |
int limit, int flags) |
1203 |
{ |
{ |
1204 |
return peer.layoutGlyphVector (this, frc, chars, start, limit, flags); |
return peer.layoutGlyphVector(this, frc, chars, start, limit, flags); |
1205 |
} |
} |
1206 |
|
|
1207 |
|
|
1208 |
/** |
/** |
1209 |
* Returns a native peer object for this font. |
* Returns a native peer object for this font. |
1210 |
* |
* |
1211 |
* @return A native peer object for this font. |
* @return A native peer object for this font. |
1212 |
* |
* |
1213 |
* @deprecated |
* @deprecated |
1214 |
*/ |
*/ |
1215 |
public FontPeer getPeer () |
public FontPeer getPeer() |
1216 |
{ |
{ |
1217 |
return peer; |
return peer; |
1218 |
} |
} |
1219 |
|
|
1220 |
|
|
1221 |
/** |
/** |
1222 |
* Returns a hash value for this font. |
* Returns a hash value for this font. |
1223 |
* |
* |
1224 |
* @return A hash for this font. |
* @return A hash for this font. |
1225 |
*/ |
*/ |
1226 |
public int hashCode() |
public int hashCode() |
1227 |
{ |
{ |
1228 |
return this.toString().hashCode(); |
return this.toString().hashCode(); |
1229 |
} |
} |
1230 |
|
|
1231 |
|
|
1232 |
/** |
/** |
1233 |
* Tests whether or not the specified object is equal to this font. This |
* Tests whether or not the specified object is equal to this font. This |
1234 |
* will be true if and only if: |
* will be true if and only if: |
1235 |
* <P> |
* <P> |
1236 |
* <ul> |
* <ul> |
1237 |
* <li>The object is not <code>null</code>. |
* <li>The object is not <code>null</code>. |
1238 |
* <li>The object is an instance of <code>Font</code>. |
* <li>The object is an instance of <code>Font</code>. |
1239 |
* <li>The object has the same names, style, size, and transform as this object. |
* <li>The object has the same names, style, size, and transform as this object. |
1240 |
* </ul> |
* </ul> |
1241 |
* |
* |
1242 |
* @return <code>true</code> if the specified object is equal to this |
* @return <code>true</code> if the specified object is equal to this |
1243 |
* object, <code>false</code> otherwise. |
* object, <code>false</code> otherwise. |
1244 |
*/ |
*/ |
1245 |
public boolean |
public boolean equals(Object obj) |
1246 |
equals(Object obj) |
{ |
1247 |
{ |
if (obj == null) |
1248 |
if (obj == null) |
return false; |
|
return(false); |
|
1249 |
|
|
1250 |
if (!(obj instanceof Font)) |
if (! (obj instanceof Font)) |
1251 |
return(false); |
return false; |
1252 |
|
|
1253 |
Font f = (Font)obj; |
Font f = (Font) obj; |
1254 |
|
|
1255 |
return (f.getName ().equals (this.getName ()) && |
return (f.getName().equals(this.getName()) |
1256 |
f.getFamily ().equals (this.getFamily ()) && |
&& f.getFamily().equals(this.getFamily()) |
1257 |
f.getFontName ().equals (this.getFontName ()) && |
&& f.getFontName().equals(this.getFontName()) |
1258 |
f.getTransform ().equals (this.getTransform ()) && |
&& f.getTransform().equals(this.getTransform ()) |
1259 |
f.getSize() == this.getSize() && |
&& f.getSize() == this.getSize() |
1260 |
f.getStyle() == this.getStyle()); |
&& f.getStyle() == this.getStyle()); |
1261 |
} |
} |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
/** |
|
|
* Returns a string representation of this font. |
|
|
* |
|
|
* @return A string representation of this font. |
|
|
*/ |
|
|
public String |
|
|
toString() |
|
|
{ |
|
|
String styleString = ""; |
|
1262 |
|
|
1263 |
switch (getStyle ()) |
/** |
1264 |
{ |
* Returns a string representation of this font. |
1265 |
case 0: |
* |
1266 |
styleString = "plain"; |
* @return A string representation of this font. |
1267 |
break; |
*/ |
1268 |
case 1: |
public String toString() |
1269 |
styleString = "bold"; |
{ |
1270 |
break; |
String styleString = ""; |
|
case 2: |
|
|
styleString = "italic"; |
|
|
break; |
|
|
default: |
|
|
styleString = "unknown"; |
|
|
} |
|
1271 |
|
|
1272 |
return getClass ().getName () |
switch (getStyle()) |
1273 |
+ "[family=" + getFamily () |
{ |
1274 |
+ ",name=" + getFontName () |
case 0: |
1275 |
+ ",style=" + styleString |
styleString = "plain"; |
1276 |
+ ",size=" + getSize () + "]"; |
break; |
1277 |
} |
case 1: |
1278 |
|
styleString = "bold"; |
1279 |
|
break; |
1280 |
|
case 2: |
1281 |
|
styleString = "italic"; |
1282 |
|
break; |
1283 |
|
default: |
1284 |
|
styleString = "unknown"; |
1285 |
|
} |
1286 |
|
|
1287 |
|
return getClass().getName() |
1288 |
|
+ "[family=" + getFamily () |
1289 |
|
+ ",name=" + getFontName () |
1290 |
|
+ ",style=" + styleString |
1291 |
|
+ ",size=" + getSize () + "]"; |
1292 |
|
} |
1293 |
|
|
1294 |
|
|
1295 |
/** |
/** |
1312 |
*/ |
*/ |
1313 |
public LineMetrics getLineMetrics(String str, FontRenderContext frc) |
public LineMetrics getLineMetrics(String str, FontRenderContext frc) |
1314 |
{ |
{ |
1315 |
return getLineMetrics (str, 0, str.length () - 1, frc); |
return getLineMetrics(str, 0, str.length() - 1, frc); |
1316 |
} |
} |
1317 |
|
|
1318 |
} // class Font |
} |
|
|
|