JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
Font.java
Go to the documentation of this file.
1/**
2 * Copyright 2010-2023 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.graph.font;
29
30import com.jogamp.graph.curve.OutlineShape;
31import com.jogamp.math.geom.AABBox;
32import com.jogamp.math.geom.plane.AffineTransform;
33
34/**
35 * Interface wrapper for font implementation.
36 * <p>
37 * TrueType Font Specification:
38 * <ul>
39 * <li>http://www.freetype.org/freetype2/documentation.html</li>
40 * <li>https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html</li>
41 * <li>http://www.microsoft.com/typography/SpecificationsOverview.mspx</li>
42 * <li>http://www.microsoft.com/typography/otspec/</li>
43 * </ul>
44 * </p>
45 * <p>
46 * TrueType Font Table Introduction:
47 * <ul>
48 * <li>http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08</li>
49 * </ul>
50 * </p>
51 * <p>
52 * Misc.:
53 * <ul>
54 * <li>Treatis on Font <code>Rasterization https://freddie.witherden.org/pages/font-rasterisation/</code></li>
55 * <li>Glyph Hell <code>http://walon.org/pub/ttf/ttf_glyphs.htm</code></li>
56 * </ul>
57 * </p>
58 */
59
60public interface Font {
61
62 /** font name indices for name table */
63 public static final int NAME_COPYRIGHT = 0;
64 public static final int NAME_FAMILY = 1;
65 public static final int NAME_SUBFAMILY = 2;
66 public static final int NAME_UNIQUNAME = 3;
67 public static final int NAME_FULLNAME = 4;
68 public static final int NAME_VERSION = 5;
69 public static final int NAME_MANUFACTURER = 8;
70 public static final int NAME_DESIGNER = 9;
71
72
73 /**
74 * Metrics for font
75 *
76 * Depending on the font's direction, horizontal or vertical,
77 * the following tables shall be used:
78 *
79 * Vertical https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6vhea.html
80 * Horizontal https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6hhea.html
81 */
82 public interface Metrics {
83 /**
84 * Distance from baseline of highest ascender, a positive value.
85 * @return ascent in font-units, sourced from `hhea' table.
86 */
88
89 /**
90 * Distance from baseline of highest ascender, a positive value.
91 * @return ascent in font em-size [0..1], sourced from `hhea' table.
92 */
93 float getAscent();
94
95 /**
96 * Distance from baseline of lowest descender, a negative value.
97 * @return descent in font-units, sourced from `hhea' table.
98 */
100
101 /**
102 * Distance from baseline of lowest descender, a negative value.
103 * @return descend in font em-size [0..1], sourced from `hhea' table.
104 */
105 float getDescent();
106
107 /**
108 * Typographic line gap, a positive value.
109 * @return line-gap in font-units, sourced from `hhea' table.
110 */
112
113 /**
114 * Typographic line gap, a positive value.
115 * @return line-gap in font em-size [0..1], sourced from `hhea' table.
116 */
117 float getLineGap();
118
119 /**
120 * max(lsb + (xMax-xMin)), a positive value.
121 * @return max-extend in font-units, sourced from `hhea' table.
122 */
124
125 /**
126 * max(lsb + (xMax-xMin)), a positive value.
127 * @return max-extend in font em-size [0..1], sourced from `hhea' table.
128 */
130
131 /** Returns the font's units per EM from the 'head' table. One em square covers one glyph. */
133
134 /**
135 * Returns fractional font em-size [0..1], i.e. funits divided by {@link #getUnitsPerEM()}, i.e.
136 * <pre>
137 * return funits / head.unitsPerEM;
138 * </pre>
139 * @param funits smallest font unit, where {@link #getUnitsPerEM()} square covers whole glyph
140 * @return fractional font em-size [0..1]
141 */
142 float getScale(final int funits);
143
144 /**
145 * @param dest AABBox instance set to this metrics boundary in font-units
146 * @return the given and set AABBox 'dest' in font units
147 */
149
150 /**
151 * @param dest AABBox instance set to this metrics boundary in font em-size [0..1]
152 * @return the given and set AABBox 'dest' in font units
153 */
155 }
156
157 /**
158 * Glyph for font
159 *
160 * http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6cmap.html
161 * http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6glyf.html
162 * http://www.microsoft.com/typography/otspec/glyf.htm
163 */
164 public interface Glyph {
165 // reserved special glyph IDs
166 // http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08#ba57949e
167 public static final int ID_UNKNOWN = 0;
168
169 /** Returns the {@link Font} owning this {@link Glyph}. */
171
172 /** Returns this glyph's mapped (unicode) `codepoint` symbol. */
174
175 /** Returns this glyph's ID */
176 int getID();
177
178 /** Returns the glyph's name, source from `post` table */
179 String getName();
180
181 /**
182 * Returns true if the Glyph denotes an undefined {@link #getID()} symbol, determined as follows
183 * <ul>
184 * <li>it's glyph index is {@link #ID_UNKNOWN}, i.e. {@code 0x00}</li>
185 * <li>has the {@link #getName() name} `.notdef`, `NULL`, `null` or `.null`</li>
186 * </ul>
187 * <p>
188 * An undefined glyph has no {@link #getShape()} if glyph index is not {@link #ID_UNKNOWN}.
189 * </p>
190 * <p>
191 * An undefined glyph has a default {@link #getBounds()} and {@link #getAdvanceWidth()}.
192 * </p>
193 * Being an undefined shape excludes {@link #isWhitespace()}.
194 * @see #isWhitespace()
195 * @see #isNonContour()
196 */
197 boolean isUndefined();
198
199 /**
200 * Returns true if the Glyph denotes a whitespace, determined as follows
201 * <ul>
202 * <li>is not {@link #isUndefined()}</li>
203 * <li>has no original underlying shape</li>
204 * <li>has an underlying shape with a zero sized area</li>
205 * </ul>
206 * <p>
207 * A whitespace glyph has no {@link #getShape()}, but a valid {@link #getBounds()} and {@link #getAdvanceWidth()}.
208 * </p>
209 * Being a whitespace glyph excludes {@link #isUndefined()}.
210 * @see #isUndefined()
211 * @see #isNonContour()
212 */
213 boolean isWhitespace();
214
215 /**
216 * Returns true if {@link #isWhitespace()} or {@link #isUndefined()}.
217 * @see #isWhitespace()
218 * @see #isUndefined()
219 */
220 boolean isNonContour();
221
222 /**
223 * Returns the AABBox in font-units, borrowing internal instance.
224 */
226
227 /**
228 * Returns the AABBox in font-units, copying into given dest.
229 * @param dest AABBox instance set to this metrics boundary in font-units
230 * @return the given and set AABBox 'dest' in font-units
231 */
233
234 /**
235 * Returns the AABBox in font em-size [0..1], copying into given dest.
236 * @param dest AABBox instance set to this metrics boundary in font em-size [0..1]
237 * @return the given and set AABBox 'dest' in font em-size [0..1]
238 */
240
241 /**
242 * Returns the AABBox in font em-size [0..1], creating a new copy.
243 */
245
246 /** Returns advance in font units, sourced from `hmtx` table. */
248
249 /** Returns advance in font em-size [0..1], sourced from `hmtx` table. */
251
252 /** Returns leftSideBearings in font units, sourced from `hmtx` table. */
254
255 /** Returns leftSideBearings in font em-size [0..1], sourced from `hmtx` table. */
257
258 /** True if kerning values are horizontal, otherwise vertical */
260
261 /** True if kerning values are perpendicular to text flow, otherwise along with flow */
263
264 /** Returns the number of kerning values stored for this glyph, associated to a right hand glyph. */
266
267 /**
268 * Returns the optional kerning inter-glyph distance within words between this glyph and the given right glyph_id in font-units.
269 *
270 * @param right_glyphid right glyph code id
271 * @return font-units
272 */
273 int getKerningFU(final int right_glyphid);
274
275 /**
276 * Returns the optional kerning inter-glyph distance within words between this glyph and the given right glyph_id in fractional font em-size [0..1].
277 *
278 * @param right_glyphid right glyph code id
279 * @return fractional font em-size distance [0..1]
280 */
281 float getKerning(final int right_glyphid);
282
284
285 @Override
286 int hashCode();
287
288 @Override
289 String toString();
290
291 /** Returns all glyph details as string. */
292 String fullString();
293 }
294
295 /**
296 * General purpose {@link Font.Glyph} visitor.
297 */
298 public static interface GlyphVisitor {
299 /**
300 * Visiting the given {@link Font.Glyph} having an {@link OutlineShape} with it's corresponding {@link AffineTransform}.
301 * @param glyph {@link Font.Glyph} which contains an {@link OutlineShape} via {@link Font.Glyph#getShape()}.
302 * @param t may be used immediately as is, otherwise a copy shall be made if stored.
303 */
304 public void visit(final Glyph glyph, final AffineTransform t);
305 }
306
307 /**
308 * General purpose {@link Font.Glyph} visitor w/o {@link AffineTransform}.
309 */
310 public static interface GlyphVisitor2 {
311 /**
312 * Visiting the given {@link Font.Glyph}
313 * @param glyph {@link Font.Glyph} which may contain an {@link OutlineShape} via {@link Font.Glyph#getShape()}.
314 */
315 public void visit(final Glyph glyph);
316 }
317
318 /**
319 * General purpose (unicode) `codepoint` symbol and {@link Font.Glyph} ID visitor without enforcing {@link Glyph} caching.
320 */
321 public static interface CodepointIDVisitor {
322 /**
323 * Visiting the given (unicode) `codepoint` symbol and {@link Font.Glyph} ID.
324 * @param codepoint (unicode) `codepoint` symbol
325 * @param glyph_id {@link Font.Glyph} ID
326 */
327 public void visit(final char codepoint, final int glyph_id);
328 }
329
330 /**
331 * Returns UTF-16 representation of the specified (unicode) `codepoint` symbol like {@link Character#toChars(int)} or {@link Character#toString()}.
332 * <p>
333 * The returned string can be inserted in any text.
334 * </p>
335 * @param codepoint the (unicode) `codepoint` symbol
336 * @return the Java {@link String} conforming result
337 */
338 public static String getUTF16String(final char codepoint) {
339 return Character.toString(codepoint);
340 // return new String(Character.toChars(codepoint));
341 }
342
343 /**
344 * Returns {@link Font} with best coverage for given text while favoring {@code a}. See {@link #getDefinedCount(CharSequence)}.
345 * <pre>
346 * return a.getDefinedCount(text) >= b.getDefinedCount(text) ? a : b;
347 * </pre>
348 */
349 public static Font getBestCoverage(final Font a, final Font b, final CharSequence s) {
350 if( null != a && null != b ) {
351 return a.getDefinedCount(s) >= b.getDefinedCount(s) ? a : b;
352 } else if( null != a ) {
353 return a;
354 } else {
355 return b;
356 }
357 }
358
359 String getName(final int nameIndex);
360
361 /** Shall return the family and subfamily name, separated a dash.
362 * <p>{@link #getName(StringBuilder, int)} w/ {@link #NAME_FAMILY} and {@link #NAME_SUBFAMILY}</p>
363 * <p>Example: "{@code Ubuntu-Regular}"</p> */
365
366 StringBuilder getAllNames(final StringBuilder string, final String separator);
367
368 /**
369 * Returns the hash code based on {@link #NAME_UNIQUNAME}.
370 * <p>
371 * {@inheritDoc}
372 * </p>
373 */
374 @Override
375 int hashCode();
376
377 /**
378 * Returns true if other instance is of same type and {@link #NAME_UNIQUNAME} is equal.
379 * <p>
380 * {@inheritDoc}
381 * </p>
382 */
383 @Override
384 boolean equals(final Object o);
385
386 /**
387 * Returns advance-width of given glyphID in font-units, sourced from `hmtx` table - same as {@link Glyph#getAdvanceWidthFU()}.
388 * @param glyphID
389 */
390 int getAdvanceWidthFU(final int glyphID);
391
392 /**
393 * Returns advance-width of given glyphID in font em-size [0..1], sourced from `hmtx` table - same as {@link Glyph#getAdvanceWidth()}.
394 * @param glyphID
395 */
396 float getAdvanceWidth(final int glyphID);
397
399
400 /** Returns number of {@link Glyph} IDs available, i.e. retrievable via {@link #getGlyph(int)} [0..count). */
402
403 /** Returns the number of defined {@link Glyph}s (coverage), i.e. not {@link Glyph#isUndefined()}, of given text. */
404 int getDefinedCount(final CharSequence text);
405
406 /** Returns the {@link Glyph} (unicode) `codepoint` symbol mapped to given {@link Glyph} `name`. */
407 char getGlyphCodepoint(final String name);
408
409 /**
410 * Returns UTF-16 representation of the specified {@link Glyph} `name` using {@link #getGlyphCodepoint(String)} and {@link #getUTF16String(char)}.
411 * <p>
412 * The returned string can be inserted in any text.
413 * </p>
414 * @param codepoint the (unicode) `codepoint` symbol
415 * @return the Java {@link String} conforming result
416 */
417 String getUTF16String(final String name);
418
419 /** Returns the {@link Glyph} ID mapped to given UTF16 (unicode) `codepoint` symbol. */
420 int getGlyphID(final char codepoint);
421
422 /** Returns the {@link Glyph} mapped to given `name`. */
423 Glyph getGlyph(final String name);
424
425 /** Returns the {@link Glyph} mapped to given (unicode) `codepoint` symbol. */
426 Glyph getGlyph(final char codepoint);
427
428 /** Returns the {@link Glyph} using given ID. */
429 Glyph getGlyph(final int glyph_id);
430
431 /**
432 * Visit all (unicode) `codepoint` symbol and {@link Glyph} ID tuple of this font.
433 * @param visitor handling each (unicode) `codepoint` symbol and {@link Glyph} ID tuple.
434 */
436
437 /**
438 * Visit all {@link Glyph}s of this font.
439 * <p>
440 * Warning: All {@link Glyph}s will be cached.
441 * </p>
442 * @param visitor handling each {@link Glyph}
443 */
444 void forAllGlyphs(final Font.GlyphVisitor2 visitor);
445
446 /**
447 * Returns line height, baseline-to-baseline in font-units, composed from `hhea' table entries.
448 * <pre>
449 * return ascent - descent + linegap;
450 * </pre>
451 * or
452 * <pre>
453 * // lineGap positive value
454 * // descent negative value
455 * // ascent positive value
456 * return ascent - descent + linegap;
457 * </pre>
458 * @see Metrics#getAscentFU()
459 * @see Metrics#getDescentFU()
460 * @see Metrics#getLineGapFU()
461 */
463
464 /**
465 * Returns line height, baseline-to-baseline in em-size [0..1], composed from `hhea' table entries.
466 * <pre>
467 * return ascent - descent + linegap;
468 * </pre>
469 * or
470 * <pre>
471 * // lineGap positive value
472 * // descent negative value
473 * // ascent positive value
474 * return ascent - descent + linegap;
475 * </pre>
476 * @see Metrics#getAscent()
477 * @see Metrics#getDescent()
478 * @see Metrics#getLineGap()
479 */
481
482 /**
483 * Returns metric-bounds in font-units.
484 * <p>
485 * Metric bounds is based on the `hmtx` table's advance of each glyph and `hhea' composed line height.
486 * </p>
487 * <p>
488 * For accurate layout consider using {@link #getGlyphBoundsFU(CharSequence)}.
489 * </p>
490 * @see #getMetricBounds(CharSequence)
491 * @see #getGlyphBoundsFU(CharSequence)
492 */
493 AABBox getMetricBoundsFU(final CharSequence string);
494
495 /**
496 * Returns metric-bounds in font em-size.
497 * <p>
498 * Metric bounds is based on the `hmtx` table's advance of each glyph and `hhea' composed line height.
499 * </p>
500 * <p>
501 * For accurate layout consider using {@link #getGlyphBounds(CharSequence)}.
502 * </p>
503 * @see #getMetricBoundsFU(CharSequence)
504 * @see #getGlyphBounds(CharSequence)
505 * @see #getGlyphShapeBounds(CharSequence)
506 */
507 AABBox getMetricBounds(final CharSequence string);
508
509 /**
510 * Try using {@link #getGlyphBounds(CharSequence, AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
511 */
512 AABBox getGlyphBounds(final CharSequence string);
513
514 /**
515 * Returns accurate bounding box by taking each glyph's font em-sized bounding box into account.
516 * <p>
517 * Glyph bounds is based on each glyph's bounding box and `hhea' composed line height.
518 * </p>
519 * @param string string text
520 * @param tmp1 temp {@link AffineTransform} to be reused
521 * @param tmp2 temp {@link AffineTransform} to be reused
522 * @return the bounding box of the given string in font em-size [0..1]
523 * @see #getGlyphBoundsFU(CharSequence)
524 * @see #getGlyphShapeBounds(CharSequence)
525 * @see #getMetricBounds(CharSequence)
526 */
527 AABBox getGlyphBounds(final CharSequence string, final AffineTransform tmp1, final AffineTransform tmp2);
528
529 /**
530 * Try using {@link #getGlyphBoundsFU(CharSequence, AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
531 */
532 AABBox getGlyphBoundsFU(final CharSequence string);
533
534 /**
535 * Returns accurate bounding box by taking each glyph's font-units sized bounding box into account.
536 * <p>
537 * Glyph bounds is based on each glyph's bounding box and `hhea' composed line height.
538 * </p>
539 * @param string string text
540 * @param tmp1 temp {@link AffineTransform} to be reused
541 * @param tmp2 temp {@link AffineTransform} to be reused
542 * @return the bounding box of the given string in font-units [0..1]
543 * @see #getGlyphBounds(CharSequence)
544 */
545 AABBox getGlyphBoundsFU(final CharSequence string, final AffineTransform tmp1, final AffineTransform tmp2);
546
547 /**
548 * Returns accurate bounding box by taking each glyph's font em-sized {@link OutlineShape} into account.
549 * <p>
550 * Glyph shape bounds is based on each glyph's {@link OutlineShape} and `hhea' composed line height.
551 * </p>
552 * <p>
553 * This method is only exposed to validate the produced {@link OutlineShape} against {@link #getGlyphBounds(CharSequence)}.
554 * </p>
555 * @param transform optional given transform
556 * @param string string text
557 * @return the bounding box of the given string in font-units [0..1]
558 * @see #getGlyphShapeBounds(CharSequence)
559 * @see #getGlyphBounds(CharSequence)
560 * @see #getMetricBounds(CharSequence)
561 */
562 AABBox getGlyphShapeBounds(final AffineTransform transform, final CharSequence string);
563
564 /**
565 * Returns accurate bounding box by taking each glyph's font em-sized {@link OutlineShape} into account.
566 * <p>
567 * Glyph shape bounds is based on each glyph's {@link OutlineShape} and `hhea' composed line height.
568 * </p>
569 * <p>
570 * This method is only exposed to validate the produced {@link OutlineShape} against {@link #getGlyphBounds(CharSequence)}.
571 * </p>
572 * @param transform optional given transform
573 * @param string string text
574 * @param tmp1 temp {@link AffineTransform} to be reused
575 * @param tmp2 temp {@link AffineTransform} to be reused
576 * @return the bounding box of the given string in font-units [0..1]
577 * @see #getGlyphShapeBounds(CharSequence)
578 * @see #getGlyphBounds(CharSequence)
579 * @see #getMetricBounds(CharSequence)
580 */
581 AABBox getGlyphShapeBounds(final AffineTransform transform, final CharSequence string, final AffineTransform tmp1, final AffineTransform tmp2);
582
583 boolean isPrintableChar(final char c);
584
585 /**
586 * Try using {@link #processString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)}
587 * to reuse {@link AffineTransform} instances.
588 * @see #processString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)
589 */
590 AABBox processString(final Font.GlyphVisitor visitor, final AffineTransform transform,
591 final CharSequence string);
592
593 /**
594 * Visit each {@link Glyph} and perhaps its {@link OutlineShape} of the string with the {@link Font.GlyphVisitor}
595 * while passing the progressed {@link AffineTransform}.
596 * <p>
597 * The processed shapes are in font em-size [0..1], but can be adjusted with the given transform, progressed and passed to the visitor.
598 * </p>
599 * @param visitor handling each {@link Font.Glyph} and perhaps its {@link OutlineShape} in font em-size [0..1] and the given {@link AffineTransform}
600 * @param transform optional given transform for size and position
601 * @param font the target {@link Font}
602 * @param string string text
603 * @param temp1 temporary AffineTransform storage, mandatory
604 * @param temp2 temporary AffineTransform storage, mandatory
605 * @return the bounding box of the given string by taking each glyph's font em-sized [0..1] {@link OutlineShape} into account.
606 * @see #processString(GlyphVisitor, AffineTransform, CharSequence)
607 */
608 AABBox processString(final Font.GlyphVisitor visitor, final AffineTransform transform,
609 final CharSequence string,
610 final AffineTransform temp1, final AffineTransform temp2);
611
612 /**
613 * Visit each {@link Glyph} and perhaps its {@link OutlineShape} of the string with the constrained {@link Font.GlyphVisitor2}.
614 * <p>
615 * The processed shapes are in font em-size [0..1].
616 * </p>
617 * @param visitor handling each {@link Font.Glyph} and perhaps its {@link OutlineShape} in font em-size [0..1]
618 * @param string string text
619 */
620 void processString(final Font.GlyphVisitor2 visitor, final CharSequence string);
621
622 /** Returns {@link #getFullFamilyName()} */
623 @Override
624 public String toString();
625
626 /** Returns all font details as string. */
627 String fullString();
628}
A Generic shape objects which is defined by a list of Outlines.
Axis Aligned Bounding Box.
Definition: AABBox.java:54
General purpose (unicode) codepoint symbol and Font.Glyph ID visitor without enforcing Glyph caching.
Definition: Font.java:321
void visit(final char codepoint, final int glyph_id)
Visiting the given (unicode) codepoint symbol and Font.Glyph ID.
General purpose Font.Glyph visitor w/o AffineTransform.
Definition: Font.java:310
void visit(final Glyph glyph)
Visiting the given Font.Glyph.
General purpose Font.Glyph visitor.
Definition: Font.java:298
void visit(final Glyph glyph, final AffineTransform t)
Visiting the given Font.Glyph having an OutlineShape with it's corresponding AffineTransform.
int getLeftSideBearingsFU()
Returns leftSideBearings in font units, sourced from hmtx table.
boolean isNonContour()
Returns true if isWhitespace() or isUndefined().
int getKerningPairCount()
Returns the number of kerning values stored for this glyph, associated to a right hand glyph.
boolean isUndefined()
Returns true if the Glyph denotes an undefined getID() symbol, determined as follows.
AABBox getBoundsFU()
Returns the AABBox in font-units, borrowing internal instance.
Font getFont()
Returns the Font owning this Glyph.
String fullString()
Returns all glyph details as string.
float getKerning(final int right_glyphid)
Returns the optional kerning inter-glyph distance within words between this glyph and the given right...
float getLeftSideBearings()
Returns leftSideBearings in font em-size [0..1], sourced from hmtx table.
float getAdvanceWidth()
Returns advance in font em-size [0..1], sourced from hmtx table.
AABBox getBounds()
Returns the AABBox in font em-size [0..1], creating a new copy.
char getCodepoint()
Returns this glyph's mapped (unicode) codepoint symbol.
static final int ID_UNKNOWN
Definition: Font.java:167
int getKerningFU(final int right_glyphid)
Returns the optional kerning inter-glyph distance within words between this glyph and the given right...
String getName()
Returns the glyph's name, source from post table.
boolean isKerningHorizontal()
True if kerning values are horizontal, otherwise vertical.
boolean isKerningCrossstream()
True if kerning values are perpendicular to text flow, otherwise along with flow.
boolean isWhitespace()
Returns true if the Glyph denotes a whitespace, determined as follows.
AABBox getBoundsFU(final AABBox dest)
Returns the AABBox in font-units, copying into given dest.
int getID()
Returns this glyph's ID.
int getAdvanceWidthFU()
Returns advance in font units, sourced from hmtx table.
AABBox getBounds(final AABBox dest)
Returns the AABBox in font em-size [0..1], copying into given dest.
float getMaxExtend()
max(lsb + (xMax-xMin)), a positive value.
int getLineGapFU()
Typographic line gap, a positive value.
int getUnitsPerEM()
Returns the font's units per EM from the 'head' table.
float getScale(final int funits)
Returns fractional font em-size [0..1], i.e.
int getMaxExtendFU()
max(lsb + (xMax-xMin)), a positive value.
float getAscent()
Distance from baseline of highest ascender, a positive value.
float getDescent()
Distance from baseline of lowest descender, a negative value.
AABBox getBoundsFU(final AABBox dest)
AABBox getBounds(final AABBox dest)
float getLineGap()
Typographic line gap, a positive value.
int getDescentFU()
Distance from baseline of lowest descender, a negative value.
int getAscentFU()
Distance from baseline of highest ascender, a positive value.
Interface wrapper for font implementation.
Definition: Font.java:60
AABBox getGlyphBounds(final CharSequence string, final AffineTransform tmp1, final AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font em-sized bounding box into account.
int getLineHeightFU()
Returns line height, baseline-to-baseline in font-units, composed from ‘hhea’ table entries.
Glyph getGlyph(final String name)
Returns the Glyph mapped to given name.
AABBox getMetricBounds(final CharSequence string)
Returns metric-bounds in font em-size.
AABBox processString(final Font.GlyphVisitor visitor, final AffineTransform transform, final CharSequence string, final AffineTransform temp1, final AffineTransform temp2)
Visit each Glyph and perhaps its OutlineShape of the string with the Font.GlyphVisitor while passing ...
void processString(final Font.GlyphVisitor2 visitor, final CharSequence string)
Visit each Glyph and perhaps its OutlineShape of the string with the constrained Font....
AABBox getGlyphBoundsFU(final CharSequence string, final AffineTransform tmp1, final AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font-units sized bounding box into account.
float getLineHeight()
Returns line height, baseline-to-baseline in em-size [0..1], composed from ‘hhea’ table entries.
AABBox getMetricBoundsFU(final CharSequence string)
Returns metric-bounds in font-units.
String getName(final int nameIndex)
static final int NAME_COPYRIGHT
font name indices for name table
Definition: Font.java:63
static final int NAME_FULLNAME
Definition: Font.java:67
static final int NAME_FAMILY
Definition: Font.java:64
void forAllCodepoints(final Font.CodepointIDVisitor visitor)
Visit all (unicode) codepoint symbol and Glyph ID tuple of this font.
AABBox getGlyphShapeBounds(final AffineTransform transform, final CharSequence string)
Returns accurate bounding box by taking each glyph's font em-sized OutlineShape into account.
String fullString()
Returns all font details as string.
String getFullFamilyName()
Shall return the family and subfamily name, separated a dash.
AABBox getGlyphShapeBounds(final AffineTransform transform, final CharSequence string, final AffineTransform tmp1, final AffineTransform tmp2)
Returns accurate bounding box by taking each glyph's font em-sized OutlineShape into account.
int getDefinedCount(final CharSequence text)
Returns the number of defined Glyphs (coverage), i.e.
AABBox getGlyphBounds(final CharSequence string)
Try using getGlyphBounds(CharSequence, AffineTransform, AffineTransform) to reuse AffineTransform ins...
static final int NAME_UNIQUNAME
Definition: Font.java:66
AABBox processString(final Font.GlyphVisitor visitor, final AffineTransform transform, final CharSequence string)
Try using processString(GlyphVisitor, AffineTransform, CharSequence, AffineTransform,...
int getGlyphID(final char codepoint)
Returns the Glyph ID mapped to given UTF16 (unicode) codepoint symbol.
static final int NAME_SUBFAMILY
Definition: Font.java:65
String toString()
Returns getFullFamilyName().
int getAdvanceWidthFU(final int glyphID)
Returns advance-width of given glyphID in font-units, sourced from hmtx table - same as Glyph#getAdva...
int getGlyphCount()
Returns number of Glyph IDs available, i.e.
boolean equals(final Object o)
Returns true if other instance is of same type and NAME_UNIQUNAME is equal.
char getGlyphCodepoint(final String name)
Returns the Glyph (unicode) codepoint symbol mapped to given Glyph name.
void forAllGlyphs(final Font.GlyphVisitor2 visitor)
Visit all Glyphs of this font.
AABBox getGlyphBoundsFU(final CharSequence string)
Try using getGlyphBoundsFU(CharSequence, AffineTransform, AffineTransform) to reuse AffineTransform i...
Glyph getGlyph(final int glyph_id)
Returns the Glyph using given ID.
static Font getBestCoverage(final Font a, final Font b, final CharSequence s)
Returns Font with best coverage for given text while favoring a.
Definition: Font.java:349
static final int NAME_VERSION
Definition: Font.java:68
static final int NAME_MANUFACTURER
Definition: Font.java:69
static final int NAME_DESIGNER
Definition: Font.java:70
StringBuilder getAllNames(final StringBuilder string, final String separator)
boolean isPrintableChar(final char c)
String getUTF16String(final String name)
Returns UTF-16 representation of the specified Glyph name using getGlyphCodepoint(String) and getUTF1...
int hashCode()
Returns the hash code based on NAME_UNIQUNAME.
static String getUTF16String(final char codepoint)
Returns UTF-16 representation of the specified (unicode) codepoint symbol like Character#toChars(int)...
Definition: Font.java:338
float getAdvanceWidth(final int glyphID)
Returns advance-width of given glyphID in font em-size [0..1], sourced from hmtx table - same as Glyp...
Glyph getGlyph(final char codepoint)
Returns the Glyph mapped to given (unicode) codepoint symbol.