harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r558725 - in /harmony/enhanced/classlib/trunk/modules/awt/src/main: java/unix/org/apache/harmony/awt/gl/font/ java/unix/org/apache/harmony/awt/gl/linux/ native/fontlib/unix/ native/linuxfont/unix/ native/linuxfont/unix/include/
Date Mon, 23 Jul 2007 13:42:18 GMT
Author: apetrenko
Date: Mon Jul 23 06:42:17 2007
New Revision: 558725

URL: http://svn.apache.org/viewvc?view=rev&rev=558725
Log:
Patch for HARMONY-4496 "[classlib][awt] 
org.apache.harmony.awt.gl.font.LinuxNativeFont.embedFont is not 
implemented"

Added:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.cpp
  (with props)
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.h
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFontManager.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxNativeFont.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/LinuxGraphics2DFactory.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/exports.txt
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/makefile
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/LinuxNativeFont.c
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h
    harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/makefile

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java?view=diff&rev=558725&r1=558724&r2=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFont.java
Mon Jul 23 06:42:17 2007
@@ -26,6 +26,7 @@
 import java.awt.font.LineMetrics;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Rectangle2D;
+import java.io.IOException;
 import java.io.File;
 import java.util.Hashtable;
 import java.util.Locale;
@@ -290,7 +291,7 @@
     /**
      * Return Font object if it was successfully embedded in System
      */
-    public static Font embedFont(String absolutePath){
+    public static Font embedFont(String absolutePath) throws IOException {
         return LinuxNativeFont.embedFont(absolutePath);
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFontManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFontManager.java?view=diff&rev=558725&r1=558724&r2=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFontManager.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxFontManager.java
Mon Jul 23 06:42:17 2007
@@ -66,7 +66,7 @@
      * font files should be installed.
      */
     public File getTempFontFile()throws IOException{
-        File fontFile = File.createTempFile("jFont", ".ttf", new File(System.getProperty("user.home")
+"/.fonts")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+        File fontFile = File.createTempFile("jFont", ".ttf"); //$NON-NLS-1$ //$NON-NLS-2$
         fontFile.deleteOnExit();
 
         return fontFile;

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxNativeFont.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxNativeFont.java?view=diff&rev=558725&r1=558724&r2=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxNativeFont.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/font/LinuxNativeFont.java
Mon Jul 23 06:42:17 2007
@@ -21,10 +21,12 @@
 package org.apache.harmony.awt.gl.font;
 
 import java.awt.Font;
+import java.io.IOException;
 
 import java.util.*;
 
 import org.apache.harmony.awt.gl.font.FontPeerImpl;
+import org.apache.harmony.awt.internal.nls.Messages;
 
 /**
  *
@@ -50,7 +52,7 @@
      *   
      * @param absolutePath absolute path to the font.
      */
-    public synchronized static native boolean embedFontNative(String absolutePath);
+    public synchronized static native String embedFontNative(String absolutePath);
 
     /**
      * Initiailzes native Xft font object from specified parameters and returns 
@@ -690,9 +692,12 @@
      *  
      * @param absolutePath absolute path to the font resource file
      */
-    public static Font embedFont(String absolutePath){
-        // TODO: implement method
-        return null;
+    public static Font embedFont(String absolutePath) throws IOException {
+        String familyName = embedFontNative(absolutePath);
+        if (familyName == null)
+            throw new IOException(Messages.getString("awt.299"));
+
+        return new Font(familyName, Font.PLAIN, 1);
     }
 
     /** flag, returns true if native linuxfont was loaded */

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/LinuxGraphics2DFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/LinuxGraphics2DFactory.java?view=diff&rev=558725&r1=558724&r2=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/LinuxGraphics2DFactory.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/LinuxGraphics2DFactory.java
Mon Jul 23 06:42:17 2007
@@ -23,6 +23,7 @@
 import java.awt.Font;
 import java.awt.Graphics2D;
 import java.awt.GraphicsEnvironment;
+import java.io.IOException;
 
 import org.apache.harmony.awt.gl.CommonGraphics2DFactory;
 import org.apache.harmony.awt.gl.MultiRectArea;
@@ -67,7 +68,7 @@
         return LinuxFontManager.inst;
     }
 
-    public Font embedFont(String fontFilePath) {
+    public Font embedFont(String fontFilePath) throws IOException {
         return LinuxFont.embedFont(fontFilePath);
     }
 

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.cpp?view=auto&rev=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.cpp
(added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.cpp
Mon Jul 23 06:42:17 2007
@@ -0,0 +1,29 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#include "FontLibExports.h"
+#include "Tables.h"
+#include <stdio.h>
+
+JNIEXPORT void JNICALL getFontFamilyName(char *path, unsigned short **familyName) {
+    FILE *f = fopen(path, "rb");
+    if (!f)
+        return;
+        
+    parseNameTable(f, familyName, 0, 0);
+    fclose(f);
+}

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.cpp
------------------------------------------------------------------------------
    svn:executable = *

Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.h?view=auto&rev=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.h
(added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.h
Mon Jul 23 06:42:17 2007
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#if !defined __FontLibExports_H__
+#define __FontLibExports_H__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT void JNICALL getFontFamilyName(char *path, unsigned short **familyName);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/FontLibExports.h
------------------------------------------------------------------------------
    svn:executable = *

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/exports.txt?view=diff&rev=558725&r1=558724&r2=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/exports.txt (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/exports.txt Mon
Jul 23 06:42:17 2007
@@ -1,3 +1,4 @@
+getFontFamilyName
 Java_org_apache_harmony_awt_gl_font_fontlib_FLFontManager_initManager
 Java_org_apache_harmony_awt_gl_font_fontlib_FLFontManager_getAllFontsNative
 Java_org_apache_harmony_awt_gl_font_fontlib_FLFontManager_dispose

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/makefile?view=diff&rev=558725&r1=558724&r2=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/makefile (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/makefile Mon
Jul 23 06:42:17 2007
@@ -30,6 +30,7 @@
   $(SHAREDSUB)T1Glyph.o \
   $(SHAREDSUB)TTCurve.o \
   $(SHAREDSUB)TTFont.o \
+  FontLibExports.o \
   $(SHAREDSUB)TypeDefinition.o
 
 ifneq ($(HY_ZIP_API),true)

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/LinuxNativeFont.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/LinuxNativeFont.c?view=diff&rev=558725&r1=558724&r2=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/LinuxNativeFont.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/LinuxNativeFont.c
Mon Jul 23 06:42:17 2007
@@ -23,6 +23,10 @@
 #include <freetype/tttables.h>
 #include <freetype/t1tables.h>
 
+#include <jni.h>
+
+#include "FontLibExports.h"
+
 #if (FREETYPE_MAJOR >= 2 && FREETYPE_MINOR >= 2)
 
 #undef HAS_FREETYPE_INTERNAL
@@ -173,36 +177,37 @@
  * Methods checks if the number of system fonts changed after font configutation
  * was rebuilded.
  */
-JNIEXPORT jboolean JNICALL 
+JNIEXPORT jstring JNICALL 
     Java_org_apache_harmony_awt_gl_font_LinuxNativeFont_embedFontNative(JNIEnv *env, jclass
obj, jstring fName){
 
     int fontAdded = FALSE;
     FcConfig *config;
-    FcFontSet *set;
-    int numFonts;
 
     config = FcConfigGetCurrent();
     if (!config){
-        return fontAdded;
+        return 0;
     }
 
-    set = FcConfigGetFonts(config, FcSetSystem);
-    if (!set){
-        return fontAdded;
-    }
+    char *path = (char *)(*env)->GetStringUTFChars(env, fName, 0);
+    fontAdded = FcConfigAppFontAddFile(config, path);
 
-    numFonts = set->nfont;
+    unsigned short *familyName = 0;
 
-    fontAdded = FcConfigBuildFonts(config);
+    if (fontAdded) {
+        getFontFamilyName(path, &familyName);
+    }    
+
+    (*env)->ReleaseStringUTFChars(env, fName, path);    
     
-    set = FcConfigGetFonts(config, FcSetSystem);
-    if (!set){
-        return fontAdded;
+    jstring res = 0;
+    if (fontAdded && familyName) {
+        int len = 0;
+        for (; familyName[len] != 0; len++);
+        res = (*env)->NewString(env, (jchar *)familyName, len);
+        free(familyName);
     }
 
-    fontAdded = fontAdded && (numFonts < set->nfont);
-
-    return fontAdded;
+    return res;
 }
 
 /*

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h?view=diff&rev=558725&r1=558724&r2=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/include/org_apache_harmony_awt_gl_font_LinuxNativeFont.h
Mon Jul 23 06:42:17 2007
@@ -63,7 +63,7 @@
 /*
  * Method: org.apache.harmony.awt.gl.font.LinuxNativeFont.embedFontNative(Ljava/lang/String;)Z
  */
-JNIEXPORT jboolean JNICALL
+JNIEXPORT jstring JNICALL
 Java_org_apache_harmony_awt_gl_font_LinuxNativeFont_embedFontNative(JNIEnv *, jclass, 
     jstring);
 

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/makefile
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/makefile?view=diff&rev=558725&r1=558724&r2=558725
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/makefile (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/native/linuxfont/unix/makefile Mon
Jul 23 06:42:17 2007
@@ -17,7 +17,7 @@
 
 CFLAGS += -fpic
 INCLUDES += -I$(SHARED)common -I/usr/X11R6/include -I/usr/include/freetype2 \
-            -Iinclude # TOFIX move includes
+            -Iinclude -I../../fontlib/unix -I../../fontlib/shared # TOFIX move includes
 ifeq ($(HY_OS),freebsd)
 INCLUDES += -I/usr/local/include -I/usr/local/include/freetype2
 endif
@@ -32,7 +32,7 @@
 endif
 
 MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
-	$(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+	$(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX) ../../fontlib/libFL.so
 
 OSLIBS += $(XLIBS)
 



Mime
View raw message