Package org.apache.batik.svggen.font

Examples of org.apache.batik.svggen.font.Glyph


        public GlyphEntry createGlyphEntry(char c, char referenceChar)
        {
            int index = getCharIndex(referenceChar);
            index = cmapFmt.mapCharCode(index);
            Glyph glyph = getGlyph(index);

            Shape s = getShapeFromGlyph(glyph);

            GlyphEntry ge = new GlyphEntry();
            ge.advance = (int)(getAdvance(referenceChar) * emScale * (useTwips ? SwfConstants.TWIPS_PER_PIXEL : 1));
View Full Code Here


            return index;
        }

        private Glyph getGlyph(int index)
        {
            Glyph glyph = null;
            GlyphDescription desc = glyf.getDescription(index);

            if (desc != null)
                glyph = new Glyph(glyf.getDescription(index), hmtx.getLeftSideBearing(index), hmtx.getAdvanceWidth(index));

            return glyph;
        }
View Full Code Here

    //Manually add a SPACE character to the font
//    int charIndex       = this.getCmapFormat(f).mapCharCode(32);
    int charIndex       = this.getCmapFormat(f).mapCharCode('i');
//    int charIndex       = this.getCmapFormat(f).mapCharCode('-');
    int default_advance_x   = f.getHmtxTable().getAdvanceWidth(charIndex);
    Glyph glyph        = f.getGlyph(charIndex);
    int xadvance = 0;
    if (glyph != null){
//      xadvance = Math.round((default_advance_x * (float)(1.0/(float)this.unitsPerEm)) * fontSize);
      xadvance = Math.round(default_advance_x * this.scaleFactor);
    }else{
 
View Full Code Here

    ArrayList<VectorFontCharacter> characters = new ArrayList<VectorFontCharacter>();

    int x = 0;
    for (short i = 0; i < text.length(); i++) {
      int glyphIndex       = cmapFmt.mapCharCode(text.charAt(i));
      Glyph glyph       = f.getGlyph(glyphIndex);
      int default_advance_x   = f.getHmtxTable().getAdvanceWidth(glyphIndex);

      if (glyph != null) {
//        glyph.scale(Math.round(scaleFactor)); //Scaling has changed to int!?
        // Add the Glyph to the Shape with an horizontal offset of x
        VectorFontCharacter fontChar = getGlyphAsShape(f, glyph, glyphIndex, x, fillColor, strokeColor);

        if (fontChar != null){
          //Sets characters horizontal advancement and unicode value
          fontChar.setHorizontalDist(default_advance_x);

//          float tmp = fontChar.getHorizontalDist() * (float)(1.0/(float)this.unitsPerEm);
//          fontChar.setHorizontalDist(Math.round(tmp * fontSize));
         
          fontChar.setHorizontalDist(Math.round(fontChar.getHorizontalDist() * scaleFactor)); //FIXME TRIAL
         
          fontChar.setUnicode(Character.toString(text.charAt(i)));
          fontChar.setName(Character.toString(text.charAt(i)));

          characters.add(fontChar);
        }

        x += glyph.getAdvanceWidth();
      }else{
        logger.error("Couldnt find character: \"" + text.charAt(i) + "\" in " + fontPath);
        x += (int)((float)default_advance_x /* *scaleFactor */);
      }

 
View Full Code Here

    CmapFormat cmapFmt = this.getCmapFormat(f);
   
    int charIndex = cmapFmt.mapCharCode(charCodeMapIndex);
    int default_advance_x   = f.getHmtxTable().getAdvanceWidth(charIndex);
   
    Glyph glyph  = f.getGlyph(charIndex);
    if (glyph != null){
      VectorFontCharacter character = this.getGlyphAsShape(f, glyph, charIndex, 0, new MTColor(0,0,0,255), new MTColor(0,0,0,255));
      if (character != null){
        character.setHorizontalDist(default_advance_x);
        return character;
View Full Code Here

TOP

Related Classes of org.apache.batik.svggen.font.Glyph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.