293 public Rectangle2D createItalicBounds() {
294 float ia = cm.italicAngle;
295
296 Rectangle2D lb = getLogicalBounds();
297 float l = (float)lb.getMinX();
298 float t = -cm.ascent;
299 float r = (float)lb.getMaxX();
300 float b = cm.descent;
301 if (ia != 0) {
302 if (ia > 0) {
303 l -= ia * (b - cm.ssOffset);
304 r -= ia * (t - cm.ssOffset);
305 } else {
306 l -= ia * (t - cm.ssOffset);
307 r -= ia * (b - cm.ssOffset);
308 }
309 }
310 return new Rectangle2D.Float(l, t, r - l, b - t);
311 }
312
313 private final StandardGlyphVector getGV() {
314 if (gv == null) {
315 gv = createGV();
316 }
317
318 return gv;
319 }
320
321 protected StandardGlyphVector createGV() {
322 FontRenderContext frc = source.getFRC();
323 int flags = source.getLayoutFlags();
324 char[] context = source.getChars();
325 int start = source.getStart();
326 int length = source.getLength();
327
328 GlyphLayout gl = GlyphLayout.get(null); // !!! no custom layout engines
329 gv = gl.layout(font, frc, context, start, length, flags, null); // ??? use textsource
330 GlyphLayout.done(gl);
331
332 return gv;
333 }
526 }
527 int v = l2v(offset);
528
529 // If ligatures are always to the left, do this stuff:
530 //if (!(source.getLayoutFlags() & 0x1) == 0) {
531 // v += 1;
532 // if (v == source.getLength()) {
533 // return true;
534 // }
535 //}
536
537 int idx = v * numvals + advx;
538 float[] charinfo = getCharinfo();
539 if (charinfo == null || idx >= charinfo.length) {
540 return false;
541 } else {
542 return charinfo[idx] != 0;
543 }
544 }
545
546 private final float[] getCharinfo() {
547 if (charinfo == null) {
548 charinfo = createCharinfo();
549 }
550 return charinfo;
551 }
552
553 private static final boolean DEBUG = FontUtilities.debugFonts();
554 /*
555 * This takes the glyph info record obtained from the glyph vector and converts it into a similar record
556 * adjusted to represent character data instead. For economy we don't use glyph info records in this processing.
557 *
558 * Here are some constraints:
559 * - there can be more glyphs than characters (glyph insertion, perhaps based on normalization, has taken place)
560 * - there can be fewer glyphs than characters
561 * Some layout engines may insert 0xffff glyphs for characters ligaturized away, but
562 * not all do, and it cannot be relied upon.
563 * - each glyph maps to a single character, when multiple glyphs exist for a character they all map to it, but
564 * no two characters map to the same glyph
565 * - multiple glyphs mapping to the same character need not be in sequence (thai, tamil have split characters)
566 * - glyphs may be arbitrarily reordered (Indic reorders glyphs)
|
293 public Rectangle2D createItalicBounds() {
294 float ia = cm.italicAngle;
295
296 Rectangle2D lb = getLogicalBounds();
297 float l = (float)lb.getMinX();
298 float t = -cm.ascent;
299 float r = (float)lb.getMaxX();
300 float b = cm.descent;
301 if (ia != 0) {
302 if (ia > 0) {
303 l -= ia * (b - cm.ssOffset);
304 r -= ia * (t - cm.ssOffset);
305 } else {
306 l -= ia * (t - cm.ssOffset);
307 r -= ia * (b - cm.ssOffset);
308 }
309 }
310 return new Rectangle2D.Float(l, t, r - l, b - t);
311 }
312
313 private StandardGlyphVector getGV() {
314 if (gv == null) {
315 gv = createGV();
316 }
317
318 return gv;
319 }
320
321 protected StandardGlyphVector createGV() {
322 FontRenderContext frc = source.getFRC();
323 int flags = source.getLayoutFlags();
324 char[] context = source.getChars();
325 int start = source.getStart();
326 int length = source.getLength();
327
328 GlyphLayout gl = GlyphLayout.get(null); // !!! no custom layout engines
329 gv = gl.layout(font, frc, context, start, length, flags, null); // ??? use textsource
330 GlyphLayout.done(gl);
331
332 return gv;
333 }
526 }
527 int v = l2v(offset);
528
529 // If ligatures are always to the left, do this stuff:
530 //if (!(source.getLayoutFlags() & 0x1) == 0) {
531 // v += 1;
532 // if (v == source.getLength()) {
533 // return true;
534 // }
535 //}
536
537 int idx = v * numvals + advx;
538 float[] charinfo = getCharinfo();
539 if (charinfo == null || idx >= charinfo.length) {
540 return false;
541 } else {
542 return charinfo[idx] != 0;
543 }
544 }
545
546 private float[] getCharinfo() {
547 if (charinfo == null) {
548 charinfo = createCharinfo();
549 }
550 return charinfo;
551 }
552
553 private static final boolean DEBUG = FontUtilities.debugFonts();
554 /*
555 * This takes the glyph info record obtained from the glyph vector and converts it into a similar record
556 * adjusted to represent character data instead. For economy we don't use glyph info records in this processing.
557 *
558 * Here are some constraints:
559 * - there can be more glyphs than characters (glyph insertion, perhaps based on normalization, has taken place)
560 * - there can be fewer glyphs than characters
561 * Some layout engines may insert 0xffff glyphs for characters ligaturized away, but
562 * not all do, and it cannot be relied upon.
563 * - each glyph maps to a single character, when multiple glyphs exist for a character they all map to it, but
564 * no two characters map to the same glyph
565 * - multiple glyphs mapping to the same character need not be in sequence (thai, tamil have split characters)
566 * - glyphs may be arbitrarily reordered (Indic reorders glyphs)
|