src/java.desktop/share/classes/sun/font/StandardGlyphVector.java

Print this page




1107 
1108         // !!! change mapper interface?
1109         if (start != 0) {
1110             char[] temp = new char[count];
1111             System.arraycopy(text, start, temp, 0, count);
1112             text = temp;
1113         }
1114 
1115         initFontData(); // sets up font2D
1116 
1117         // !!! no layout for now, should add checks
1118         // !!! need to support creating a StandardGlyphVector from a TextMeasurer's info...
1119         glyphs = new int[count]; // hmmm
1120         /* Glyphs obtained here are already validated by the font */
1121         userGlyphs = glyphs;
1122         font2D.getMapper().charsToGlyphs(count, text, glyphs);
1123     }
1124 
1125     private void initFontData() {
1126         font2D = FontUtilities.getFont2D(font);



1127         float s = font.getSize2D();
1128         if (font.isTransformed()) {
1129             ftx = font.getTransform();
1130             if (ftx.getTranslateX() != 0 || ftx.getTranslateY() != 0) {
1131                 addFlags(FLAG_HAS_POSITION_ADJUSTMENTS);
1132             }
1133             ftx.setTransform(ftx.getScaleX(), ftx.getShearY(), ftx.getShearX(), ftx.getScaleY(), 0, 0);
1134             ftx.scale(s, s);
1135         } else {
1136             ftx = AffineTransform.getScaleInstance(s, s);
1137         }
1138 
1139         frctx = frc.getTransform();
1140         resetDTX(getNonTranslateTX(frctx));
1141     }
1142 
1143     /**
1144      * Copy glyph position data into a result array starting at the indicated
1145      * offset in the array.  If the passed-in result array is null, a new
1146      * array will be allocated and returned.


1725                     (tx.getType() & ~AffineTransform.TYPE_TRANSLATION) != 0) {
1726                     double shearx = tx.getShearX();
1727                     if (shearx != 0) {
1728                         double scaley = tx.getScaleY();
1729                         ptSize =
1730                             (int)Math.sqrt(shearx * shearx + scaley * scaley);
1731                     } else {
1732                         ptSize = (int)(Math.abs(tx.getScaleY()));
1733                     }
1734                 }
1735             }
1736             int aa = FontStrikeDesc.getAAHintIntVal(aaHint,sgv.font2D, ptSize);
1737             int fm = FontStrikeDesc.getFMHintIntVal
1738                 (sgv.frc.getFractionalMetricsHint());
1739             FontStrikeDesc desc = new FontStrikeDesc(dtx,
1740                                                      tx,
1741                                                      sgv.font.getStyle(),
1742                                                      aa, fm);
1743             // Get the strike via the handle. Shouldn't matter
1744             // if we've invalidated the font but its an extra precaution.
1745             FontStrike strike = sgv.font2D.handle.font2D.getStrike(desc);  // !!! getStrike(desc, false)





1746 
1747             return new GlyphStrike(sgv, strike, dx, dy);
1748         }
1749 
1750         private GlyphStrike(StandardGlyphVector sgv, FontStrike strike, float dx, float dy) {
1751             this.sgv = sgv;
1752             this.strike = strike;
1753             this.dx = dx;
1754             this.dy = dy;
1755         }
1756 
1757         void getADL(ADL result) {
1758             StrikeMetrics sm = strike.getFontMetrics();
1759             Point2D.Float delta = null;
1760             if (sgv.font.isTransformed()) {
1761                 delta = new Point2D.Float();
1762                 delta.x = (float)sgv.font.getTransform().getTranslateX();
1763                 delta.y = (float)sgv.font.getTransform().getTranslateY();
1764             }
1765 




1107 
1108         // !!! change mapper interface?
1109         if (start != 0) {
1110             char[] temp = new char[count];
1111             System.arraycopy(text, start, temp, 0, count);
1112             text = temp;
1113         }
1114 
1115         initFontData(); // sets up font2D
1116 
1117         // !!! no layout for now, should add checks
1118         // !!! need to support creating a StandardGlyphVector from a TextMeasurer's info...
1119         glyphs = new int[count]; // hmmm
1120         /* Glyphs obtained here are already validated by the font */
1121         userGlyphs = glyphs;
1122         font2D.getMapper().charsToGlyphs(count, text, glyphs);
1123     }
1124 
1125     private void initFontData() {
1126         font2D = FontUtilities.getFont2D(font);
1127         if (font2D instanceof FontSubstitution) {
1128            font2D = ((FontSubstitution)font2D).getCompositeFont2D();
1129         }
1130         float s = font.getSize2D();
1131         if (font.isTransformed()) {
1132             ftx = font.getTransform();
1133             if (ftx.getTranslateX() != 0 || ftx.getTranslateY() != 0) {
1134                 addFlags(FLAG_HAS_POSITION_ADJUSTMENTS);
1135             }
1136             ftx.setTransform(ftx.getScaleX(), ftx.getShearY(), ftx.getShearX(), ftx.getScaleY(), 0, 0);
1137             ftx.scale(s, s);
1138         } else {
1139             ftx = AffineTransform.getScaleInstance(s, s);
1140         }
1141 
1142         frctx = frc.getTransform();
1143         resetDTX(getNonTranslateTX(frctx));
1144     }
1145 
1146     /**
1147      * Copy glyph position data into a result array starting at the indicated
1148      * offset in the array.  If the passed-in result array is null, a new
1149      * array will be allocated and returned.


1728                     (tx.getType() & ~AffineTransform.TYPE_TRANSLATION) != 0) {
1729                     double shearx = tx.getShearX();
1730                     if (shearx != 0) {
1731                         double scaley = tx.getScaleY();
1732                         ptSize =
1733                             (int)Math.sqrt(shearx * shearx + scaley * scaley);
1734                     } else {
1735                         ptSize = (int)(Math.abs(tx.getScaleY()));
1736                     }
1737                 }
1738             }
1739             int aa = FontStrikeDesc.getAAHintIntVal(aaHint,sgv.font2D, ptSize);
1740             int fm = FontStrikeDesc.getFMHintIntVal
1741                 (sgv.frc.getFractionalMetricsHint());
1742             FontStrikeDesc desc = new FontStrikeDesc(dtx,
1743                                                      tx,
1744                                                      sgv.font.getStyle(),
1745                                                      aa, fm);
1746             // Get the strike via the handle. Shouldn't matter
1747             // if we've invalidated the font but its an extra precaution.
1748         // do we want the CompFont from CFont here ?
1749         Font2D f2d = sgv.font2D;
1750         if (f2d instanceof FontSubstitution) {
1751            f2d = ((FontSubstitution)f2d).getCompositeFont2D();
1752         }
1753             FontStrike strike = f2d.handle.font2D.getStrike(desc);  // !!! getStrike(desc, false)
1754 
1755             return new GlyphStrike(sgv, strike, dx, dy);
1756         }
1757 
1758         private GlyphStrike(StandardGlyphVector sgv, FontStrike strike, float dx, float dy) {
1759             this.sgv = sgv;
1760             this.strike = strike;
1761             this.dx = dx;
1762             this.dy = dy;
1763         }
1764 
1765         void getADL(ADL result) {
1766             StrikeMetrics sm = strike.getFontMetrics();
1767             Point2D.Float delta = null;
1768             if (sgv.font.isTransformed()) {
1769                 delta = new Point2D.Float();
1770                 delta.x = (float)sgv.font.getTransform().getTranslateX();
1771                 delta.y = (float)sgv.font.getTransform().getTranslateY();
1772             }
1773