harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r584088 - in /harmony/enhanced/classlib/trunk/modules/awt/src/main/java: common/java/awt/Font.java common/org/apache/harmony/awt/gl/font/FontPeerImpl.java windows/org/apache/harmony/awt/gl/font/WindowsFont.java
Date Fri, 12 Oct 2007 07:31:09 GMT
Author: ayza
Date: Fri Oct 12 00:31:08 2007
New Revision: 584088

URL: http://svn.apache.org/viewvc?rev=584088&view=rev
Log:
Adding getUnicodeByIndex() implementation from HARMONY-4556 ([classlib][awt] Font.createGlyphVector(FontRenderContext
frc, int[] glyphCodes) is not implemented)

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java?rev=584088&r1=584087&r2=584088&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/Font.java Fri
Oct 12 00:31:08 2007
@@ -319,11 +319,6 @@
     }
 
     public GlyphVector createGlyphVector(FontRenderContext frc, int[] glyphCodes) throws
org.apache.harmony.luni.util.NotImplementedException {
-        if (!FontManager.IS_FONTLIB) {
-            // TODO : to find out, how to operate with glyphcodes
-            throw new NotImplementedException();
-        }
-        
         int length = glyphCodes.length;        
         char[] chars = new char[length];        
         FontPeerImpl peer = (FontPeerImpl) getPeer();

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java?rev=584088&r1=584087&r2=584088&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontPeerImpl.java
Fri Oct 12 00:31:08 2007
@@ -462,15 +462,13 @@
         }
     }
     
+    /**
+     * Returns unicode by glyph index.
+     */
     public char getUnicodeByIndex(int glyphCode) {
         return 0;
     }
 
-    /**
-     * Sets new font type to the font object.
-     * 
-     * @param newType new type value
-     */
     @Override
     protected void finalize() throws Throwable {
       super.finalize();

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java?rev=584088&r1=584087&r2=584088&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
Fri Oct 12 00:31:08 2007
@@ -46,6 +46,8 @@
     
     // table with loaded cached Glyphs
     private final Hashtable<Integer, WinGlyph> glyphs = new Hashtable<Integer, WinGlyph>();
+    // table with loaded glyph codes
+    private final Hashtable<Integer, Integer> glyphCodes = new Hashtable<Integer,
Integer>();
 
     // Pairs of [begin, end],[..].. unicode ranges values 
     private int[] fontUnicodeRanges;
@@ -404,7 +406,33 @@
 
         return faceName;
     }
-    
+
+    /**
+     * Returns unicode by index from the 'cmap' table of this font.
+     */
+    @Override
+    public char getUnicodeByIndex(int glyphCode) {
+        char result;
+
+        if (glyphCodes.isEmpty()) {
+            for (int i = 0; i < fontUnicodeRanges.length - 1; i += 2) {
+                for (int j = fontUnicodeRanges[i]; j <= fontUnicodeRanges[i + 1]; j++)
+                {
+                    int code = NativeFont.getGlyphCodeNative(pFont, (char) j);
+                    glyphCodes.put(code, j);
+                }
+            }
+        }
+
+        if (glyphCodes.containsKey(glyphCode)) {
+            result = (char) glyphCodes.get(glyphCode).intValue();
+        } else {
+            result = defaultChar;
+        }
+
+        return result;
+    }
+
     /**
      * Returns initiated FontExtraMetrics instance of this WindowsFont.
      */



Mime
View raw message