Hello Alexey

This commit broke classlib compilation on windows x86_64. The compiler from MSVC 2005 which is used on x86_64 gives a warning when compiling file FontLibExports.cpp and this warning is treated as error. Please take a look and fix this problem if you can.

[EMAIL PROTECTED] wrote:
Author: apetrenko
Date: Sun Jul 22 04:51:09 2007
New Revision: 558473

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

Added:
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/FontLibExports.cpp
   (with props)
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/FontLibExports.h
   (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/awt/build.xml
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2DFactory.java
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/NativeFont.java
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/WindowsFont.java
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphics2DFactory.java
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/makefile
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/include/org_apache_harmony_awt_gl_font_NativeFont.h
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/makefile
    
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/winFont.cpp

Modified: harmony/enhanced/classlib/trunk/modules/awt/build.xml
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/build.xml?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/build.xml (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/build.xml Sun Jul 22 04:51:09 
2007
@@ -138,7 +138,9 @@
     </target>
<target name="build-native"
-        depends="-build-native-unix,-build-native-windows">
+        depends="-build-native-common,-build-native-unix,-build-native-windows" 
/>
+ + <target name="-build-native-common">
         <make dir="${hy.awt.src.main.native}/lcmm/${hy.os.family}" />
         <!-- Copy the built shared libs over to the jre/bin dir -->
         <copy todir="${hy.jdk}/jre/bin" overwrite="yes">

Modified: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2DFactory.java
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2DFactory.java?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2DFactory.java
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2DFactory.java
 Sun Jul 22 04:51:09 2007
@@ -24,6 +24,8 @@
 import java.awt.FontMetrics;
 import java.awt.peer.FontPeer;
+import java.io.IOException;
+
 import org.apache.harmony.awt.wtk.GraphicsFactory;
/**
@@ -46,6 +48,6 @@
* @param fontFilePath path to the font file * @return Font object that was created from the file.
      */
-    public abstract Font embedFont(String fontFilePath);
+    public abstract Font embedFont(String fontFilePath) throws IOException;
}

Modified: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/internal/nls/messages.properties
 Sun Jul 22 04:51:09 2007
@@ -487,6 +487,7 @@
 awt.296=can't allocate memory on video card to create new display list
 awt.297=Invalid keyLocation
 awt.298=dataBuffer is too small
+awt.299=Font file can not be read
awt.err.00=file dialog {0} error!
 awt.err.01=error: {0}

Modified: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java
 Sun Jul 22 04:51:09 2007
@@ -25,6 +25,7 @@
 import java.awt.Graphics2D;
 import java.awt.GraphicsEnvironment;
 import java.awt.peer.FontPeer;
+import java.io.IOException;
 import org.apache.harmony.awt.gl.MultiRectArea;
 import org.apache.harmony.awt.gl.font.FontManager;
@@ -71,5 +72,5 @@
     // Font methods
     FontManager getFontManager();
     FontPeer getFontPeer(Font font);
-    Font embedFont(String fontFilePath);
+    Font embedFont(String fontFilePath) throws IOException;
 }

Modified: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/NativeFont.java
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/NativeFont.java?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/NativeFont.java
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/font/NativeFont.java
 Sun Jul 22 04:51:09 2007
@@ -21,10 +21,13 @@
 package org.apache.harmony.awt.gl.font;
import java.awt.Font;
+import java.io.IOException;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Hashtable;
+import org.apache.harmony.awt.internal.nls.Messages;
+
 public class NativeFont {
/**
@@ -70,7 +73,7 @@
* * @param absolutePath String that represent absolute path to the font resource. */
-    public static native boolean embedFontNative(String absolutePath);
+    public static native String embedFontNative(String absolutePath);
/** * Initialize native GDI font object and return font handle, also sets font @@ -463,9 +466,14 @@ * * @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) {
+            System.err.println("Exception!");
+            throw new IOException(Messages.getString("awt.299"));
+        }
+
+        return new Font(familyName, Font.PLAIN, 1);
     }
/**

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?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- 
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
 Sun Jul 22 04:51:09 2007
@@ -30,6 +30,7 @@
 import java.awt.image.IndexColorModel;
 import java.awt.image.Raster;
 import java.awt.image.WritableRaster;
+import java.io.IOException;
 import java.util.Hashtable;
 import java.util.Locale;
@@ -340,7 +341,7 @@
     /**
      * Return Font object if it was successfully embedded in the system.
      */
-    public static Font embedFont(String absolutePath){
+    public static Font embedFont(String absolutePath) throws IOException {
         return NativeFont.embedFont(absolutePath);
     }
Modified: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphics2DFactory.java
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphics2DFactory.java?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphics2DFactory.java
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGraphics2DFactory.java
 Sun Jul 22 04:51:09 2007
@@ -22,6 +22,8 @@
import java.awt.*; +import java.io.IOException;
+
 import org.apache.harmony.awt.gl.CommonGraphics2DFactory;
 import org.apache.harmony.awt.gl.MultiRectArea;
 import org.apache.harmony.awt.gl.opengl.OGLGraphics2D;
@@ -70,7 +72,7 @@
     }
@Override
-    public Font embedFont(String fontFilePath) {
+    public Font embedFont(String fontFilePath) throws IOException {
         return WindowsFont.embedFont(fontFilePath);
     }
Added: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/FontLibExports.cpp
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/FontLibExports.cpp?view=auto&rev=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/FontLibExports.cpp
 (added)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/FontLibExports.cpp
 Sun Jul 22 04:51:09 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(fwchar_t *path, fwchar_t 
**familyName) {
+    FILE *f = _wfopen(path, L"rb");
+    if (!f)
+        return;
+ + parseNameTable(f, familyName, 0, 0);
+    fclose(f);
+}

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

Added: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/FontLibExports.h
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/FontLibExports.h?view=auto&rev=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/FontLibExports.h
 (added)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/FontLibExports.h
 Sun Jul 22 04:51:09 2007
@@ -0,0 +1,34 @@
+/*
+ *  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>
+#include "TypeDefinition.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT void JNICALL getFontFamilyName(fwchar_t *path, fwchar_t 
**familyName);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

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

Modified: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/makefile
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/makefile?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/makefile
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/makefile
 Sun Jul 22 04:51:09 2007
@@ -35,7 +35,8 @@
   $(SHAREDSUB)T1Glyph.obj \
   $(SHAREDSUB)TTCurve.obj \
   $(SHAREDSUB)TTFont.obj \
-  $(SHAREDSUB)TypeDefinition.obj
+  $(SHAREDSUB)TypeDefinition.obj \
+  $(SHAREDSUB)FontLibExports.obj
VIRTFILES = $(LIBBASE).res
 SYSLIBFILES = ws2_32.lib Iphlpapi.lib

Modified: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/include/org_apache_harmony_awt_gl_font_NativeFont.h
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/include/org_apache_harmony_awt_gl_font_NativeFont.h?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/include/org_apache_harmony_awt_gl_font_NativeFont.h
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/include/org_apache_harmony_awt_gl_font_NativeFont.h
 Sun Jul 22 04:51:09 2007
@@ -63,7 +63,7 @@
 /*
  * Method: 
org.apache.harmony.awt.gl.font.NativeFont.embedFontNative(Ljava/lang/String;)Z
  */
-JNIEXPORT jboolean JNICALL
+JNIEXPORT jstring JNICALL
Java_org_apache_harmony_awt_gl_font_NativeFont_embedFontNative(JNIEnv *, jclass, jstring);
Modified: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/makefile
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/makefile?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/makefile
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/makefile
 Sun Jul 22 04:51:09 2007
@@ -22,15 +22,15 @@
 LIBNAME=$(LIBPATH)$(LIBBASE).lib
 HYLDFLAGS = $(HYLDFLAGS) -def:$(LIBBASE).def
-HYCFLAGS = $(HYCFLAGS) /Iinclude /I..\..\gl\windows\include \
+HYCFLAGS = $(HYCFLAGS) /Iinclude /I..\..\gl\windows\include 
/I..\..\fontlib\shared \
   -DUNICODE -D_UNICODE
BUILDFILES = winFont.obj VIRTFILES = $(LIBBASE).res
-SYSLIBFILES = ws2_32.lib Iphlpapi.lib gdi32.lib GdiPlus.lib advapi32.lib
+SYSLIBFILES = ws2_32.lib Iphlpapi.lib gdi32.lib GdiPlus.lib advapi32.lib -MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) 
$(LIBPATH)vmi$(HY_LINKLIB_SUFFIX) $(LIBPATH)FL$(HY_LINKLIB_SUFFIX)
DLLBASE=0x13300000
 COMMENT=/comment:"Win32 Font native code. (c) Copyright 2005 - 2006 The Apache 
Software Foundation or its licensors, as applicable."

Modified: 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/winFont.cpp
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/winFont.cpp?view=diff&rev=558473&r1=558472&r2=558473
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/winFont.cpp
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/winfont/windows/winFont.cpp
 Sun Jul 22 04:51:09 2007
@@ -33,6 +33,8 @@
 #include "org_apache_harmony_awt_gl_font_WinGlyph.h"
 #include "exceptions.h"
+#include <FontLibExports.h> // Font file tables parsing routines for embedFontNative method
+
 static LCIDS lcidTable;
 static FontRecords fonts;           /* Cached system fonts data             */
 static int famSize = 256;           /* Size of families array               */
@@ -457,7 +459,7 @@
 * Signature: (Ljava/lang/String;)Z
 * Description: Returns TRUE if Font resource from font file added successfully 
to a system.
 */
-JNIEXPORT jboolean JNICALL +JNIEXPORT jstring JNICALL Java_org_apache_harmony_awt_gl_font_NativeFont_embedFontNative(JNIEnv *env, jclass obj, jstring absPath) { jboolean iscopy;
@@ -465,12 +467,24 @@
     const TCHAR * path;
     path = (TCHAR *)(env->GetStringCritical(absPath, &iscopy));
- fontAdded = AddFontResource(path);
+    fontAdded = AddFontResourceEx(path, FR_PRIVATE, 0);
+ + fwchar_t *familyName = 0;
+
+    if (fontAdded) {
+        getFontFamilyName((fwchar_t *)path, &familyName);
+ } - // message to other applications about installed font
-    //  SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
     env->ReleaseStringCritical(absPath, (const jchar *)path);
-    return fontAdded;
+ + jstring res = 0;
+    if (fontAdded && familyName) {
+        int len = wcslen(familyName);
+        res = env->NewString((jchar *)familyName, len);
+        delete familyName;
+    }
+ + return res;
 }
/*





--
Gregory

Reply via email to