This adds a method to the Java TrueType implementation to map characters
to glyph indices. This is useful for a couple of purposes, for example
to determine the advance width of a character.

2007-05-08  Roman Kennke  <[EMAIL PROTECTED]>

        * gnu/java/awt/font/FontDelegate.java
        (getGlyphIndex): New method. Maps characters to their
        glyph index in the font.
        M gnu/java/awt/font/opentype/OpenTypeFont.java
        (getGlyphIndex): New method. Maps characters to their
        glyph index in the font.

/Roman

-- 
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-0

USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt
Index: gnu/java/awt/font/FontDelegate.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/FontDelegate.java,v
retrieving revision 1.3
diff -u -1 -5 -r1.3 FontDelegate.java
--- gnu/java/awt/font/FontDelegate.java	16 Dec 2006 20:51:02 -0000	1.3
+++ gnu/java/awt/font/FontDelegate.java	8 May 2007 14:39:43 -0000
@@ -103,32 +103,40 @@
   
   /**
    * Returns the PostScript name of this font face, for example
    * <i>&#x201c;Helvetica-Bold&#x201d;</i>.
    *
    * @return the PostScript name, or <code>null</code> if the font
    * does not provide a PostScript name.
    */
   public String getPostScriptName();
 
 
   /**
    * Returns the number of glyphs in this font face.
    */
   public int getNumGlyphs();
-  
-  
+
+  /**
+   * Returns the glyph code for the specified character.
+   *
+   * @param c the character to map
+   *
+   * @return the glyph code
+   */
+  public int getGlyphIndex(int c);
+
   /**
    * Returns the index of the glyph which gets displayed if the font
    * cannot map a Unicode code point to a glyph. Many fonts show this
    * glyph as an empty box.
    */
   public int getMissingGlyphCode();
   
 
   /**
    * Creates a GlyphVector by mapping each character in a
    * CharacterIterator to the corresponding glyph.
    *
    * <p>The mapping takes only the font&#x2019;s <code>cmap</code>
    * tables into consideration. No other operations (such as glyph
    * re-ordering, composition, or ligature substitution) are
Index: gnu/java/awt/font/opentype/OpenTypeFont.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/font/opentype/OpenTypeFont.java,v
retrieving revision 1.6
diff -u -1 -5 -r1.6 OpenTypeFont.java
--- gnu/java/awt/font/opentype/OpenTypeFont.java	16 Dec 2006 20:51:02 -0000	1.6
+++ gnu/java/awt/font/opentype/OpenTypeFont.java	8 May 2007 14:39:43 -0000
@@ -605,31 +605,41 @@
 
     /* If we had surrogates, the allocated array is too large.
      * Because this will occur very rarely, it seems acceptable to
      * re-allocate a shorter array and copy the contents around.
      */
     if (glyph != numGlyphs)
     {
       int[] newGlyphs = new int[glyph];
       System.arraycopy(glyphs, 0, newGlyphs, 0, glyph);
       glyphs = newGlyphs;
     }
 
     return new GNUGlyphVector(this, font, frc, glyphs);
   }
 
-
+  /**
+   * Returns the glyph code for the specified character.
+   *
+   * @param c the character to map
+   *
+   * @return the glyph code
+   */
+  public int getGlyphIndex(int c)
+  {
+    return cmap.getGlyph(c);
+  }
 
   /**
    * Determines the advance width for a glyph.
    *
    * @param glyphIndex the glyph whose advance width is to be
    * determined.
    *
    * @param pointSize the point size of the font.
    *
    * @param transform a transform that is applied in addition to
    * scaling to the specified point size. This is often used for
    * scaling according to the device resolution. Those who lack any
    * aesthetic sense may also use the transform to slant or stretch
    * glyphs.
    *

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to