You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by ap...@apache.org on 2007/06/10 19:31:25 UTC
svn commit: r545915 [1/5] - in /harmony/enhanced/classlib/trunk/modules/awt:
./ src/main/java/common/java/awt/
src/main/java/common/org/apache/harmony/awt/gl/
src/main/java/common/org/apache/harmony/awt/gl/font/
src/main/java/common/org/apache/harmony/...
Author: apetrenko
Date: Sun Jun 10 10:31:22 2007
New Revision: 545915
URL: http://svn.apache.org/viewvc?view=rev&rev=545915
Log:
Font library contribution
HARMONY-3583 and HARMONY-4104
Added:
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontManager.java (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontPeer.java (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLGlyph.java (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLOutline.java (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLPath.java (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLTextRenderer.java (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/AGL.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/EncodedValue.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Environment.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Font.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Glyph.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Outline.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/ParsingTables.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Font.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Glyph.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/T1Glyph.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/TTCurve.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/TTCurve.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/TTFont.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/TTFont.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Tables.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/Type1Structs.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/fljni.cpp (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/fljni.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLFontManager.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLFontPeer.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLGlyph.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/shared/include/org_apache_harmony_awt_gl_font_fontlib_FLPath.h (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/exports.txt (with props)
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/unix/makefile
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/fl.def
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/fl.rc
harmony/enhanced/classlib/trunk/modules/awt/src/main/native/fontlib/windows/makefile
Modified:
harmony/enhanced/classlib/trunk/modules/awt/build.xml
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/CommonGraphics2D.java
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphicsEnvironment.java
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.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/common/org/apache/harmony/awt/gl/font/Glyph.java
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLGraphics2D.java
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java
harmony/enhanced/classlib/trunk/modules/awt/src/main/java/windows/org/apache/harmony/awt/gl/windows/WinGDIPGraphics2D.java
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=545915&r1=545914&r2=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/build.xml (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/build.xml Sun Jun 10 10:31:22 2007
@@ -178,6 +178,16 @@
<exclude name="*${manifest.suffix}"/>
</fileset>
</copy>
+
+ <make dir="${hy.awt.src.main.native}/fontlib/${hy.os.family}" />
+ <!-- Copy the built shared libs over to the jre/bin dir -->
+ <copy todir="${hy.jdk}/jre/bin" overwrite="yes">
+ <fileset dir="${hy.awt.src.main.native}/fontlib">
+ <include name="*${shlib.suffix}*"/>
+ <include name="*${progdb.suffix}*" if="is.windows" />
+ <exclude name="*${manifest.suffix}"/>
+ </fileset>
+ </copy>
</target>
<target name="-build-native-unix" if="is.unix">
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?view=diff&rev=545915&r1=545914&r2=545915
==============================================================================
--- 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 Sun Jun 10 10:31:22 2007
@@ -24,6 +24,7 @@
import java.awt.font.TransformAttribute;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
+import java.awt.peer.FontPeer;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -38,11 +39,12 @@
import java.util.Map;
import java.util.StringTokenizer;
-import java.awt.peer.FontPeer;
-
import org.apache.harmony.awt.gl.font.CommonGlyphVector;
+import org.apache.harmony.awt.gl.font.FontManager;
import org.apache.harmony.awt.gl.font.FontPeerImpl;
+import org.apache.harmony.awt.gl.font.fontlib.FLFontManager;
import org.apache.harmony.awt.internal.nls.Messages;
+import org.apache.harmony.luni.util.NotImplementedException;
import org.apache.harmony.misc.HashCode;
@@ -245,8 +247,14 @@
if (!Character.isValidCodePoint(i)) {
throw new IllegalArgumentException();
}
- //TODO implement true code point support
- return canDisplay((char)i);
+
+ if (!FontManager.IS_FONTLIB) {
+ //TODO implement true code point support
+ return canDisplay((char)i);
+ } else {
+ FontPeerImpl peer = (FontPeerImpl)this.getPeer();
+ return peer.canDisplay(peer.getUnicodeByIndex(i));
+ }
}
public int canDisplayUpTo(char[] text, int start, int limit) {
@@ -311,19 +319,25 @@
}
public GlyphVector createGlyphVector(FontRenderContext frc, int[] glyphCodes) throws org.apache.harmony.luni.util.NotImplementedException {
- // TODO : to find out, how to operate with glyphcodes
- if (true) {
- throw new RuntimeException("Method is not implemented"); //$NON-NLS-1$
+ if (!FontManager.IS_FONTLIB) {
+ // TODO : to find out, how to operate with glyphcodes
+ throw new NotImplementedException();
}
- return null;
+
+ int length = glyphCodes.length;
+ char[] chars = new char[length];
+ FontPeerImpl peer = (FontPeerImpl) getPeer();
+
+ for (int i = 0; i < length; i ++) {
+ chars[i] = peer.getUnicodeByIndex(glyphCodes[i]);
+ }
+
+ return new CommonGlyphVector(chars, frc, this, 0);
}
public GlyphVector createGlyphVector(FontRenderContext frc, String str) {
-
return new CommonGlyphVector(str.toCharArray(), frc, this, 0);
-
-
}
/**
@@ -596,7 +610,7 @@
}
- public String getFontName() {
+ public String getFontName() {
FontPeerImpl peer = (FontPeerImpl)this.getPeer();
return peer.getFontName();
}
@@ -608,6 +622,7 @@
public LineMetrics getLineMetrics(char[] chars, int start, int end,
FontRenderContext frc) {
+
if (frc == null) {
// awt.00=FontRenderContext is null
throw new NullPointerException(Messages.getString("awt.00")); //$NON-NLS-1$
@@ -845,9 +860,14 @@
* @deprecated
*/
@Deprecated
- public FontPeer getPeer() {
+ public FontPeer getPeer() {
if (fontPeer == null){
- fontPeer = (FontPeerImpl)Toolkit.getDefaultToolkit().getGraphicsFactory().getFontPeer(this);
+ fontPeer = (FontPeerImpl) FontManager.getInstance().getFontPeer(
+ this.getName(),
+ this.getStyle(),
+ this.getSize()
+ );
+
}
return fontPeer;
}
@@ -936,11 +956,22 @@
public static Font createFont(int fontFormat, File fontFile) throws FontFormatException,
IOException {
- InputStream is = new FileInputStream(fontFile);
- try {
- return createFont(fontFormat, is);
- } finally {
- is.close();
+ if (fontFile == null) throw new NullPointerException();
+
+ if (FontManager.IS_FONTLIB) {
+ if (fontFormat != TRUETYPE_FONT && fontFormat != TYPE1_FONT) {
+ // awt.9A=Unsupported font format
+ throw new IllegalArgumentException ( Messages.getString("awt.9A") ); //$NON-NLS-1$
+ }
+
+ return ((FLFontManager)FontManager.getInstance()).embedFont(fontFile.getAbsolutePath(), fontFormat);
+ } else {
+ InputStream is = new FileInputStream(fontFile);
+ try {
+ return createFont(fontFormat, is);
+ } finally {
+ is.close();
+ }
}
}
@@ -952,13 +983,14 @@
int size = 8192; // memory page size, for the faster reading
byte buf[] = new byte[size];
- if (fontFormat != TRUETYPE_FONT) {
+ if (fontFormat != TRUETYPE_FONT && !FontManager.IS_FONTLIB) {
// awt.9A=Unsupported font format
throw new IllegalArgumentException ( Messages.getString("awt.9A") ); //$NON-NLS-1$
}
/* Get font file in system-specific directory */
- File fontFile = Toolkit.getDefaultToolkit().getGraphicsFactory().getFontManager().getTempFontFile();
+ File fontFile = FontManager.getInstance().getTempFontFile();
+// File fontFile = Toolkit.getDefaultToolkit().getGraphicsFactory().getFontManager().getTempFontFile();
buffStream = new BufferedInputStream ( fontStream );
@@ -975,8 +1007,12 @@
fOutStream.close();
Font font = null;
-
- font = Toolkit.getDefaultToolkit().getGraphicsFactory().embedFont(fontFile.getAbsolutePath());
+
+ if (FontManager.IS_FONTLIB) {
+ font = ((FLFontManager)FontManager.getInstance()).embedFont(fontFile.getAbsolutePath(), fontFormat);
+ } else {
+ font = Toolkit.getDefaultToolkit().getGraphicsFactory().embedFont(fontFile.getAbsolutePath());
+ }
if ( font == null ) {
// awt.9B=Can't create font - bad font data
throw new FontFormatException ( Messages.getString("awt.9B") ); //$NON-NLS-1$
@@ -985,4 +1021,5 @@
}
}
+
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java?view=diff&rev=545915&r1=545914&r2=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2D.java Sun Jun 10 10:31:22 2007
@@ -58,6 +58,8 @@
import java.util.Map;
import org.apache.harmony.awt.gl.Surface;
+import org.apache.harmony.awt.gl.font.FontManager;
+import org.apache.harmony.awt.gl.font.fontlib.FLTextRenderer;
import org.apache.harmony.awt.gl.image.OffscreenImage;
import org.apache.harmony.awt.gl.render.Blitter;
import org.apache.harmony.awt.gl.render.JavaArcRasterizer;
@@ -145,7 +147,10 @@
protected Font font = new Font("Dialog", Font.PLAIN, 12);; //$NON-NLS-1$
- protected TextRenderer jtr = JavaTextRenderer.inst;
+ protected TextRenderer jtr =
+ FontManager.IS_FONTLIB ?
+ FLTextRenderer.getInstance() :
+ JavaTextRenderer.inst;
// Current graphics transform
protected AffineTransform transform = new AffineTransform();
@@ -1129,4 +1134,4 @@
//copy.origTransform = new AffineTransform(origTransform);
copy.origPoint = new Point(origPoint);
}
-}
\ No newline at end of file
+}
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphicsEnvironment.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphicsEnvironment.java?view=diff&rev=545915&r1=545914&r2=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphicsEnvironment.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphicsEnvironment.java Sun Jun 10 10:31:22 2007
@@ -27,6 +27,8 @@
import java.util.ArrayList;
import java.util.Locale;
+import org.apache.harmony.awt.gl.font.FontManager;
+import org.apache.harmony.awt.gl.font.fontlib.FLFontManager;
import org.apache.harmony.awt.gl.image.BufferedImageGraphics2D;
/**
@@ -57,11 +59,11 @@
@Override
public Font[] getAllFonts() {
- return CommonGraphics2DFactory.inst.getFontManager().getAllFonts();
+ return FontManager.getInstance().getAllFonts();
}
@Override
public String[] getAvailableFontFamilyNames() {
- return CommonGraphics2DFactory.inst.getFontManager().getAllFamilies();
+ return FontManager.getInstance().getAllFamilies();
}
}
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java?view=diff&rev=545915&r1=545914&r2=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java Sun Jun 10 10:31:22 2007
@@ -21,6 +21,7 @@
package org.apache.harmony.awt.gl.font;
import java.awt.Font;
+import java.awt.GraphicsEnvironment;
import java.awt.peer.FontPeer;
import java.io.File;
import java.io.FileInputStream;
@@ -34,16 +35,20 @@
import java.util.Vector;
import org.apache.harmony.awt.gl.CommonGraphics2DFactory;
+import org.apache.harmony.awt.gl.font.fontlib.FLFontManager;
public abstract class FontManager {
+ public static final boolean IS_FONTLIB = "true".equals(System.getProperty("java.awt.fontlib")) ||
+ GraphicsEnvironment.isHeadless();
+
/**
* array of font families names
*/
public String[] allFamilies;
- public static final String DEFAULT_NAME = "Default"; /* Default font name */ //$NON-NLS-1$
+ public static final String DEFAULT_NAME = IS_FONTLIB ? "Luxi Sans" : "Default"; /* Default font name */ //$NON-NLS-1$
public static final String DIALOG_NAME = "Dialog"; /* Dialog font name */ //$NON-NLS-1$
/**
@@ -197,13 +202,16 @@
public Hashtable<String, Vector<FontProperty>> fProperties = new Hashtable<String, Vector<FontProperty>>();
public FontManager(){
- allFamilies = getAllFamilies();
- /*
- * Creating and registering shutdown hook to free resources
- * before object is destroyed.
- */
- DisposeNativeHook shutdownHook = new DisposeNativeHook();
- Runtime.getRuntime().addShutdownHook(shutdownHook);
+
+ if (!IS_FONTLIB) {
+ allFamilies = getAllFamilies();
+ /*
+ * Creating and registering shutdown hook to free resources
+ * before object is destroyed.
+ */
+ DisposeNativeHook shutdownHook = new DisposeNativeHook();
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+ }
}
/**
@@ -214,7 +222,7 @@
/**
* Locale - Language ID hash table.
*/
- Hashtable<String, Short> tableLCID = new Hashtable<String, Short>();
+ protected Hashtable<String, Short> tableLCID = new Hashtable<String, Short>();
/**
* Hash table that contains FontPeers instances.
@@ -231,7 +239,10 @@
/**
* Singleton instance
*/
- public final static FontManager inst = CommonGraphics2DFactory.inst.getFontManager();
+ private static FontManager inst =
+ IS_FONTLIB ?
+ new FLFontManager() :
+ CommonGraphics2DFactory.inst.getFontManager();
/**
@@ -305,7 +316,7 @@
* @param logicalIndex index of the logical face name in LOGICAL_FONT_FACES
* array or -1 if desired font peer is not logical.
*/
- private FontPeer createFontPeer(String name, int style, int size, int logicalIndex){
+ protected FontPeer createFontPeer(String name, int style, int size, int logicalIndex){
FontPeer peer;
if (logicalIndex != -1){
peer = createLogicalFontPeer(name, style, size);
@@ -765,7 +776,7 @@
* Class contains SoftReference instance that can be stored in the
* Hashtable by means of key field corresponding to it.
*/
- private class HashMapReference extends SoftReference<FontPeer> {
+ protected class HashMapReference extends SoftReference<FontPeer> {
/**
* The key for Hashtable.
@@ -808,5 +819,6 @@
}
}
+
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java?view=diff&rev=545915&r1=545914&r2=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java Sun Jun 10 10:31:22 2007
@@ -84,7 +84,7 @@
this.maxAscent = ascent;
this.maxDescent = descent;
this.maxAdvance = lm.getLogicalMaxCharWidth();
- initWidths();
+// initWidths();
}
/**
@@ -134,9 +134,9 @@
*/
@Override
public int charWidth(int ch) {
- if (ch < 256){
- return widths[ch];
- }
+// if (ch < 256){
+// return widths[ch];
+// }
return getFontPeer().charWidth((char)ch);
}
@@ -151,9 +151,9 @@
*/
@Override
public int charWidth(char ch) {
- if (ch < 256){
- return widths[ch];
- }
+// if (ch < 256){
+// return widths[ch];
+// }
return (int)(getFontPeer().charWidth(ch)*scaleX);
}
@@ -202,6 +202,10 @@
*/
@Override
public int[] getWidths() {
+ this.widths = new int[256];
+ for (int chr=0; chr < 256; chr++){
+ widths[chr] = (int)(getFontPeer().charWidth((char)chr)*scaleX);
+ }
return this.widths;
}
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?view=diff&rev=545915&r1=545914&r2=545915
==============================================================================
--- 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 Sun Jun 10 10:31:22 2007
@@ -21,12 +21,11 @@
package org.apache.harmony.awt.gl.font;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.peer.FontPeer;
-
-import java.awt.font.FontRenderContext;
-import java.awt.font.LineMetrics;
import java.util.ArrayList;
import java.util.Locale;
@@ -53,16 +52,16 @@
float height;
// the style of this font peer
- int style;
+ protected int style;
// the point size of this font peer (in pixels)
- int size;
+ protected int size;
// the logical hight of this font peer (in pixels)
int logicalHeight;
// the name of this font peer
- String name;
+ protected String name;
// family name of this font peer
String fontFamilyName;
@@ -71,7 +70,7 @@
String faceName;
// bounds rectanlge of the largest character in this font peer
- Rectangle2D maxCharBounds;
+ protected Rectangle2D maxCharBounds;
// italic angle value of this font peer
float italicAngle = 0.0f;
@@ -80,13 +79,13 @@
int numGlyphs = 0;
// native font handle
- long pFont;
+ protected long pFont;
// cached line metrics object
- LineMetricsImpl nlm;
+ protected LineMetricsImpl nlm = null;
// the postscript name of this font peer
- String psName = null;
+ protected String psName = null;
/**
* Default glyph index, that is used, when the desired glyph
@@ -402,6 +401,9 @@
* Returns cached LineMetrics object of this font peer.
*/
public LineMetrics getLineMetrics(){
+ if (nlm == null) {
+ nlm = (LineMetricsImpl) getLineMetrics("", null, AffineTransform.getTranslateInstance(0,0));
+ }
return nlm;
}
@@ -458,6 +460,10 @@
if (newType == FontManager.FONT_TYPE_T1 || newType == FontManager.FONT_TYPE_TT){
fontType = newType;
}
+ }
+
+ public char getUnicodeByIndex(int glyphCode) {
+ return 0;
}
/**
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/Glyph.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/Glyph.java?view=diff&rev=545915&r1=545914&r2=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/Glyph.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/Glyph.java Sun Jun 10 10:31:22 2007
@@ -28,13 +28,13 @@
public abstract class Glyph{
// character of the glyph
- char glChar;
+ protected char glChar;
// precise glyph metrics
- GlyphMetrics glMetrics;
+ protected GlyphMetrics glMetrics;
// glyph metrics in pixels
- GlyphMetrics glPointMetrics;
+ protected GlyphMetrics glPointMetrics;
// glyph code of this Glyph
int glCode;
@@ -55,7 +55,7 @@
BufferedImage image;
// shape that representing the outline of this glyph
- Shape glOutline = null;
+ protected Shape glOutline = null;
/**
* image bitmap parameters
@@ -94,14 +94,14 @@
* Retruns precise width of this glyph object
*/
public int getWidth(){
- return Math.round((float)glMetrics.getBounds2D().getWidth());
+ return Math.round((float)getGlyphMetrics().getBounds2D().getWidth());
}
/**
* Retruns precise height of this glyph object
*/
public int getHeight(){
- return Math.round((float)glMetrics.getBounds2D().getHeight());
+ return Math.round((float)getGlyphMetrics().getBounds2D().getHeight());
}
/**
@@ -150,9 +150,9 @@
*/
public int[] getABC(){
int[] abc = new int[3];
- abc[0] = (int)glMetrics.getLSB();
- abc[1] = (int)glMetrics.getBounds2D().getWidth();
- abc[2] = (int)glMetrics.getRSB();
+ abc[0] = (int)getGlyphMetrics().getLSB();
+ abc[1] = (int)getGlyphMetrics().getBounds2D().getWidth();
+ abc[2] = (int)getGlyphMetrics().getRSB();
return abc;
}
@@ -194,14 +194,14 @@
* Returns height of the glyph in points.
*/
public int getPointHeight(){
- return (int)glPointMetrics.getBounds2D().getHeight();
+ return (int)getGlyphPointMetrics().getBounds2D().getHeight();
}
/**
* Returns width of the glyph in points.
*/
public int getPointWidth(){
- return (int)glPointMetrics.getBounds2D().getWidth();
+ return (int)getGlyphPointMetrics().getBounds2D().getWidth();
}
public Shape getShape(){
@@ -232,5 +232,6 @@
public abstract Shape initOutline(char c);
}
+
Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontManager.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontManager.java?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontManager.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontManager.java Sun Jun 10 10:31:22 2007
@@ -0,0 +1,529 @@
+/*
+ * 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.
+ */
+package org.apache.harmony.awt.gl.font.fontlib;
+
+import java.awt.Font;
+import java.awt.FontFormatException;
+import java.awt.peer.FontPeer;
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.harmony.awt.gl.font.CompositeFont;
+import org.apache.harmony.awt.gl.font.FontManager;
+import org.apache.harmony.awt.gl.font.FontPeerImpl;
+import org.apache.harmony.awt.internal.nls.Messages;
+
+public class FLFontManager extends FontManager {
+
+ private ArrayList<Font> allFonts = new ArrayList<Font>();
+
+ static {
+ System.loadLibrary("FL");
+ }
+
+ public FLFontManager() {
+
+ Runtime.getRuntime().addShutdownHook(new DisposeNativeHook());
+
+ initManager();
+
+ addPath(new File(System.getProperty("java.home") + "/lib/fonts/"));
+ addPath(new File("C:\\WINNT\\Fonts"));
+ addPath(new File("/usr/X11R6/lib/X11/fonts/Type1/"));
+ addPath(new File("/usr/X11R6/lib/X11/fonts/truetype/"));
+
+ Font[] nativeFonts = getAllFontsNative();
+
+ if (nativeFonts != null)
+ for(int i = 0; i < nativeFonts.length; i ++) {
+ allFonts.add(nativeFonts[i]);
+ }
+
+ allFamilies = getAllFamilies();
+ }
+
+ class FLFilenameFilter implements FilenameFilter {
+
+ public boolean accept(File dir, String str) {
+ String suffix = str.substring(str.length() - 3).toLowerCase();
+ return suffix.equals("pfb") || suffix.equals("pfa") || suffix.equals("ttf");
+ }
+
+ }
+
+ FilenameFilter filter = new FLFilenameFilter();
+
+ private void addPath(File path){
+ if (!path.canRead() || !path.isDirectory()) return;
+
+ String[] strMas = path.list(filter);
+
+ String dir = path.getAbsolutePath();
+
+ Font newFont;
+
+ for (int i = 0; i < strMas.length; i++) {
+ String str = strMas[i].substring(strMas[i].length() - 3).toLowerCase();
+ newFont = addFont(dir + "/" + strMas[i], str.equals("ttf") ? Font.TRUETYPE_FONT : Font.TYPE1_FONT);
+
+ if (newFont != null) {
+ allFonts.add(newFont);
+ }
+ }
+
+ allFamilies = getAllFamilies();
+ }
+
+ @Override
+ public FontPeer createPhysicalFontPeer(String name, int style, int size) {
+ FontPeerImpl peer = null;
+
+ if (isFontExistInList(name, style)){
+ try {
+ peer = new FLFontPeer(name, style, size);
+
+ peer.setFamily(name);
+ } catch(NullPointerException e) {
+ peer = new FLFontPeer(DEFAULT_NAME, style, size);
+
+ peer.setFamily(DEFAULT_NAME);
+ }
+ } else {
+ peer = new FLFontPeer(DEFAULT_NAME, style, size);
+
+ peer.setFamily(DEFAULT_NAME);
+ }
+
+ return peer;
+ }
+
+ private boolean isFontExistInList(String name, int style) {
+ for (Font font : allFonts) {
+ if (font.getStyle() == style && font.getName().equals(name)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public FontPeer createDefaultFont(int style, int size) {
+ //return getFontPeer(DIALOG_NAME, style, size);
+ return createPhysicalFontPeer(DEFAULT_NAME, style, size);
+ }
+
+ /**
+ * Initializes LCID table
+ */
+ @Override
+ public void initLCIDTable(){
+
+ Hashtable<String, Short> ht = tableLCID;
+
+ /*
+ * Language records with LCID values (0x04**).
+ */
+ ht.put(new String("ar"), new Short((short)0x0401)); // ar-dz //$NON-NLS-1$
+ ht.put(new String("bg"), new Short((short)0x0402)); //$NON-NLS-1$
+ ht.put(new String("ca"), new Short((short)0x0403)); //$NON-NLS-1$
+ ht.put(new String("zh"), new Short((short)0x0404)); // zh-tw //$NON-NLS-1$
+ ht.put(new String("cs"), new Short((short)0x0405)); //$NON-NLS-1$
+ ht.put(new String("da"), new Short((short)0x0406)); //$NON-NLS-1$
+ ht.put(new String("de"), new Short((short)0x0407)); // de-de //$NON-NLS-1$
+ ht.put(new String("el"), new Short((short)0x0408)); //$NON-NLS-1$
+ ht.put(new String("fi"), new Short((short)0x040b)); //$NON-NLS-1$
+ ht.put(new String("fr"), new Short((short)0x040c)); // fr-fr //$NON-NLS-1$
+ ht.put(new String("iw"), new Short((short)0x040d)); // "he" //$NON-NLS-1$
+ ht.put(new String("hu"), new Short((short)0x040e)); //$NON-NLS-1$
+ ht.put(new String("is"), new Short((short)0x040f)); //$NON-NLS-1$
+ ht.put(new String("it"), new Short((short)0x0410)); // it-it //$NON-NLS-1$
+ ht.put(new String("ja"), new Short((short)0x0411)); //$NON-NLS-1$
+ ht.put(new String("ko"), new Short((short)0x0412)); //$NON-NLS-1$
+ ht.put(new String("nl"), new Short((short)0x0413)); // nl-nl //$NON-NLS-1$
+ ht.put(new String("no"), new Short((short)0x0414)); // no_no //$NON-NLS-1$
+ ht.put(new String("pl"), new Short((short)0x0415)); //$NON-NLS-1$
+ ht.put(new String("pt"), new Short((short)0x0416)); // pt-br //$NON-NLS-1$
+ ht.put(new String("rm"), new Short((short)0x0417)); //$NON-NLS-1$
+ ht.put(new String("ro"), new Short((short)0x0418)); //$NON-NLS-1$
+ ht.put(new String("ru"), new Short((short)0x0419)); //$NON-NLS-1$
+ ht.put(new String("hr"), new Short((short)0x041a)); //$NON-NLS-1$
+ ht.put(new String("sk"), new Short((short)0x041b)); //$NON-NLS-1$
+ ht.put(new String("sq"), new Short((short)0x041c)); //$NON-NLS-1$
+ ht.put(new String("sv"), new Short((short)0x041d)); // sv-se //$NON-NLS-1$
+ ht.put(new String("th"), new Short((short)0x041e)); //$NON-NLS-1$
+ ht.put(new String("tr"), new Short((short)0x041f)); //$NON-NLS-1$
+ ht.put(new String("ur"), new Short((short)0x0420)); //$NON-NLS-1$
+ ht.put(new String("in"), new Short((short)0x0421)); // "id" //$NON-NLS-1$
+ ht.put(new String("uk"), new Short((short)0x0422)); //$NON-NLS-1$
+ ht.put(new String("be"), new Short((short)0x0423)); //$NON-NLS-1$
+ ht.put(new String("sl"), new Short((short)0x0424)); //$NON-NLS-1$
+ ht.put(new String("et"), new Short((short)0x0425)); //$NON-NLS-1$
+ ht.put(new String("lv"), new Short((short)0x0426)); //$NON-NLS-1$
+ ht.put(new String("lt"), new Short((short)0x0427)); //$NON-NLS-1$
+ ht.put(new String("fa"), new Short((short)0x0429)); //$NON-NLS-1$
+ ht.put(new String("vi"), new Short((short)0x042a)); //$NON-NLS-1$
+ ht.put(new String("hy"), new Short((short)0x042b)); //$NON-NLS-1$
+ ht.put(new String("eu"), new Short((short)0x042d)); //$NON-NLS-1$
+ ht.put(new String("sb"), new Short((short)0x042e)); //$NON-NLS-1$
+ ht.put(new String("mk"), new Short((short)0x042f)); //$NON-NLS-1$
+ ht.put(new String("sx"), new Short((short)0x0430)); //$NON-NLS-1$
+ ht.put(new String("ts"), new Short((short)0x0431)); //$NON-NLS-1$
+ ht.put(new String("tn"), new Short((short)0x0432)); //$NON-NLS-1$
+ ht.put(new String("xh"), new Short((short)0x0434)); //$NON-NLS-1$
+ ht.put(new String("zu"), new Short((short)0x0435)); //$NON-NLS-1$
+ ht.put(new String("af"), new Short((short)0x0436)); //$NON-NLS-1$
+ ht.put(new String("fo"), new Short((short)0x0438)); //$NON-NLS-1$
+ ht.put(new String("hi"), new Short((short)0x0439)); //$NON-NLS-1$
+ ht.put(new String("mt"), new Short((short)0x043a)); //$NON-NLS-1$
+ ht.put(new String("gd"), new Short((short)0x043c)); //$NON-NLS-1$
+ ht.put(new String("yi"), new Short((short)0x043d)); //$NON-NLS-1$
+ ht.put(new String("sw"), new Short((short)0x0441)); //$NON-NLS-1$
+ ht.put(new String("tt"), new Short((short)0x0444)); //$NON-NLS-1$
+ ht.put(new String("ta"), new Short((short)0x0449)); //$NON-NLS-1$
+ ht.put(new String("mr"), new Short((short)0x044e)); //$NON-NLS-1$
+ ht.put(new String("sa"), new Short((short)0x044f)); //$NON-NLS-1$
+
+ /*
+ * Language-country records.
+ */
+ ht.put(new String("ar_SA"), new Short((short)0x401)); //$NON-NLS-1$
+ ht.put(new String("bg_BG"), new Short((short)0x402)); //$NON-NLS-1$
+ ht.put(new String("ca_ES"), new Short((short)0x403)); //$NON-NLS-1$
+ ht.put(new String("zh_TW"), new Short((short)0x404)); //$NON-NLS-1$
+ ht.put(new String("cs_CZ"), new Short((short)0x405)); //$NON-NLS-1$
+ ht.put(new String("da_DK"), new Short((short)0x406)); //$NON-NLS-1$
+ ht.put(new String("de_DE"), new Short((short)0x407)); //$NON-NLS-1$
+ ht.put(new String("el_GR"), new Short((short)0x408)); //$NON-NLS-1$
+ ht.put(new String("en_US"), new Short((short)0x409)); //$NON-NLS-1$
+ ht.put(new String("es_ES"), new Short((short)0x40a)); //$NON-NLS-1$
+ ht.put(new String("fi_FI"), new Short((short)0x40b)); //$NON-NLS-1$
+ ht.put(new String("fr_FR"), new Short((short)0x40c)); //$NON-NLS-1$
+ ht.put(new String("he_IL"), new Short((short)0x40d)); //$NON-NLS-1$
+ ht.put(new String("hu_HU"), new Short((short)0x40e)); //$NON-NLS-1$
+ ht.put(new String("is_IS"), new Short((short)0x40f)); //$NON-NLS-1$
+ ht.put(new String("it_IT"), new Short((short)0x410)); //$NON-NLS-1$
+ ht.put(new String("ja_JP"), new Short((short)0x411)); //$NON-NLS-1$
+ ht.put(new String("ko_KR"), new Short((short)0x412)); //$NON-NLS-1$
+ ht.put(new String("nl_NL"), new Short((short)0x413)); //$NON-NLS-1$
+ ht.put(new String("nb_NO"), new Short((short)0x414)); //$NON-NLS-1$
+ ht.put(new String("pl_PL"), new Short((short)0x415)); //$NON-NLS-1$
+ ht.put(new String("pt_BR"), new Short((short)0x416)); //$NON-NLS-1$
+ ht.put(new String("ro_RO"), new Short((short)0x418)); //$NON-NLS-1$
+ ht.put(new String("ru_RU"), new Short((short)0x419)); //$NON-NLS-1$
+ ht.put(new String("hr_HR"), new Short((short)0x41a)); //$NON-NLS-1$
+ ht.put(new String("sk_SK"), new Short((short)0x41b)); //$NON-NLS-1$
+ ht.put(new String("sq_AL"), new Short((short)0x41c)); //$NON-NLS-1$
+ ht.put(new String("sv_SE"), new Short((short)0x41d)); //$NON-NLS-1$
+ ht.put(new String("th_TH"), new Short((short)0x41e)); //$NON-NLS-1$
+ ht.put(new String("tr_TR"), new Short((short)0x41f)); //$NON-NLS-1$
+ ht.put(new String("ur_PK"), new Short((short)0x420)); //$NON-NLS-1$
+ ht.put(new String("id_ID"), new Short((short)0x421)); //$NON-NLS-1$
+ ht.put(new String("uk_UA"), new Short((short)0x422)); //$NON-NLS-1$
+ ht.put(new String("be_BY"), new Short((short)0x423)); //$NON-NLS-1$
+ ht.put(new String("sl_SI"), new Short((short)0x424)); //$NON-NLS-1$
+ ht.put(new String("et_EE"), new Short((short)0x425)); //$NON-NLS-1$
+ ht.put(new String("lv_LV"), new Short((short)0x426)); //$NON-NLS-1$
+ ht.put(new String("lt_LT"), new Short((short)0x427)); //$NON-NLS-1$
+ ht.put(new String("fa_IR"), new Short((short)0x429)); //$NON-NLS-1$
+ ht.put(new String("vi_VN"), new Short((short)0x42a)); //$NON-NLS-1$
+ ht.put(new String("hy_AM"), new Short((short)0x42b)); //$NON-NLS-1$
+ ht.put(new String("az_AZ"), new Short((short)0x42c)); //$NON-NLS-1$
+ ht.put(new String("eu_ES"), new Short((short)0x42d)); //$NON-NLS-1$
+ ht.put(new String("mk_MK"), new Short((short)0x42f)); //$NON-NLS-1$
+ ht.put(new String("af_ZA"), new Short((short)0x436)); //$NON-NLS-1$
+ ht.put(new String("ka_GE"), new Short((short)0x437)); //$NON-NLS-1$
+ ht.put(new String("fo_FO"), new Short((short)0x438)); //$NON-NLS-1$
+ ht.put(new String("hi_IN"), new Short((short)0x439)); //$NON-NLS-1$
+ ht.put(new String("ms_MY"), new Short((short)0x43e)); //$NON-NLS-1$
+ ht.put(new String("kk_KZ"), new Short((short)0x43f)); //$NON-NLS-1$
+ ht.put(new String("ky_KG"), new Short((short)0x440)); //$NON-NLS-1$
+ ht.put(new String("sw_KE"), new Short((short)0x441)); //$NON-NLS-1$
+ ht.put(new String("uz_UZ"), new Short((short)0x443)); //$NON-NLS-1$
+ ht.put(new String("tt_TA"), new Short((short)0x444)); //$NON-NLS-1$
+ ht.put(new String("pa_IN"), new Short((short)0x446)); //$NON-NLS-1$
+ ht.put(new String("gu_IN"), new Short((short)0x447)); //$NON-NLS-1$
+ ht.put(new String("ta_IN"), new Short((short)0x449)); //$NON-NLS-1$
+ ht.put(new String("te_IN"), new Short((short)0x44a)); //$NON-NLS-1$
+ ht.put(new String("kn_IN"), new Short((short)0x44b)); //$NON-NLS-1$
+ ht.put(new String("mr_IN"), new Short((short)0x44e)); //$NON-NLS-1$
+ ht.put(new String("sa_IN"), new Short((short)0x44f)); //$NON-NLS-1$
+ ht.put(new String("mn_MN"), new Short((short)0x450)); //$NON-NLS-1$
+ ht.put(new String("gl_ES"), new Short((short)0x456)); //$NON-NLS-1$
+ ht.put(new String("ko_IN"), new Short((short)0x457)); //$NON-NLS-1$
+ ht.put(new String("sy_SY"), new Short((short)0x45a)); //$NON-NLS-1$
+ ht.put(new String("di_MV"), new Short((short)0x465)); //$NON-NLS-1$
+ ht.put(new String("ar_IQ"), new Short((short)0x801)); //$NON-NLS-1$
+ ht.put(new String("zh_CN"), new Short((short)0x804)); //$NON-NLS-1$
+ ht.put(new String("de_CH"), new Short((short)0x807)); //$NON-NLS-1$
+ ht.put(new String("en_GB"), new Short((short)0x809)); //$NON-NLS-1$
+ ht.put(new String("es_MX"), new Short((short)0x80a)); //$NON-NLS-1$
+ ht.put(new String("fr_BE"), new Short((short)0x80c)); //$NON-NLS-1$
+ ht.put(new String("it_CH"), new Short((short)0x810)); //$NON-NLS-1$
+ ht.put(new String("nl_BE"), new Short((short)0x813)); //$NON-NLS-1$
+ ht.put(new String("nn_NO"), new Short((short)0x814)); //$NON-NLS-1$
+ ht.put(new String("pt_PT"), new Short((short)0x816)); //$NON-NLS-1$
+ ht.put(new String("sr_SP"), new Short((short)0x81a)); //$NON-NLS-1$
+ ht.put(new String("sv_FI"), new Short((short)0x81d)); //$NON-NLS-1$
+ ht.put(new String("az_AZ"), new Short((short)0x82c)); //$NON-NLS-1$
+ ht.put(new String("ms_BN"), new Short((short)0x83e)); //$NON-NLS-1$
+ ht.put(new String("uz_UZ"), new Short((short)0x843)); //$NON-NLS-1$
+ ht.put(new String("ar_EG"), new Short((short)0xc01)); //$NON-NLS-1$
+ ht.put(new String("zh_HK"), new Short((short)0xc04)); //$NON-NLS-1$
+ ht.put(new String("de_AT"), new Short((short)0xc07)); //$NON-NLS-1$
+ ht.put(new String("en_AU"), new Short((short)0xc09)); //$NON-NLS-1$
+ ht.put(new String("es_ES"), new Short((short)0xc0a)); //$NON-NLS-1$
+ ht.put(new String("fr_CA"), new Short((short)0xc0c)); //$NON-NLS-1$
+ ht.put(new String("sr_SP"), new Short((short)0xc1a)); //$NON-NLS-1$
+ ht.put(new String("ar_LY"), new Short((short)0x1001)); //$NON-NLS-1$
+ ht.put(new String("zh_SG"), new Short((short)0x1004)); //$NON-NLS-1$
+ ht.put(new String("de_LU"), new Short((short)0x1007)); //$NON-NLS-1$
+ ht.put(new String("en_CA"), new Short((short)0x1009)); //$NON-NLS-1$
+ ht.put(new String("es_GT"), new Short((short)0x100a)); //$NON-NLS-1$
+ ht.put(new String("fr_CH"), new Short((short)0x100c)); //$NON-NLS-1$
+ ht.put(new String("ar_DZ"), new Short((short)0x1401)); //$NON-NLS-1$
+ ht.put(new String("zh_MO"), new Short((short)0x1404)); //$NON-NLS-1$
+ ht.put(new String("de_LI"), new Short((short)0x1407)); //$NON-NLS-1$
+ ht.put(new String("en_NZ"), new Short((short)0x1409)); //$NON-NLS-1$
+ ht.put(new String("es_CR"), new Short((short)0x140a)); //$NON-NLS-1$
+ ht.put(new String("fr_LU"), new Short((short)0x140c)); //$NON-NLS-1$
+ ht.put(new String("ar_MA"), new Short((short)0x1801)); //$NON-NLS-1$
+ ht.put(new String("en_IE"), new Short((short)0x1809)); //$NON-NLS-1$
+ ht.put(new String("es_PA"), new Short((short)0x180a)); //$NON-NLS-1$
+ ht.put(new String("fr_MC"), new Short((short)0x180c)); //$NON-NLS-1$
+ ht.put(new String("ar_TN"), new Short((short)0x1c01)); //$NON-NLS-1$
+ ht.put(new String("en_ZA"), new Short((short)0x1c09)); //$NON-NLS-1$
+ ht.put(new String("es_DO"), new Short((short)0x1c0a)); //$NON-NLS-1$
+ ht.put(new String("ar_OM"), new Short((short)0x2001)); //$NON-NLS-1$
+ ht.put(new String("en_JM"), new Short((short)0x2009)); //$NON-NLS-1$
+ ht.put(new String("es_VE"), new Short((short)0x200a)); //$NON-NLS-1$
+ ht.put(new String("ar_YE"), new Short((short)0x2401)); //$NON-NLS-1$
+ ht.put(new String("en_CB"), new Short((short)0x2409)); //$NON-NLS-1$
+ ht.put(new String("es_CO"), new Short((short)0x240a)); //$NON-NLS-1$
+ ht.put(new String("ar_SY"), new Short((short)0x2801)); //$NON-NLS-1$
+ ht.put(new String("en_BZ"), new Short((short)0x2809)); //$NON-NLS-1$
+ ht.put(new String("es_PE"), new Short((short)0x280a)); //$NON-NLS-1$
+ ht.put(new String("ar_JO"), new Short((short)0x2c01)); //$NON-NLS-1$
+ ht.put(new String("en_TT"), new Short((short)0x2c09)); //$NON-NLS-1$
+ ht.put(new String("es_AR"), new Short((short)0x2c0a)); //$NON-NLS-1$
+ ht.put(new String("ar_LB"), new Short((short)0x3001)); //$NON-NLS-1$
+ ht.put(new String("en_ZW"), new Short((short)0x3009)); //$NON-NLS-1$
+ ht.put(new String("es_EC"), new Short((short)0x300a)); //$NON-NLS-1$
+ ht.put(new String("ar_KW"), new Short((short)0x3401)); //$NON-NLS-1$
+ ht.put(new String("en_PH"), new Short((short)0x3409)); //$NON-NLS-1$
+ ht.put(new String("es_CL"), new Short((short)0x340a)); //$NON-NLS-1$
+ ht.put(new String("ar_AE"), new Short((short)0x3801)); //$NON-NLS-1$
+ ht.put(new String("es_UY"), new Short((short)0x380a)); //$NON-NLS-1$
+ ht.put(new String("ar_BH"), new Short((short)0x3c01)); //$NON-NLS-1$
+ ht.put(new String("es_PY"), new Short((short)0x3c0a)); //$NON-NLS-1$
+ ht.put(new String("ar_QA"), new Short((short)0x4001)); //$NON-NLS-1$
+ ht.put(new String("es_BO"), new Short((short)0x400a)); //$NON-NLS-1$
+ ht.put(new String("es_SV"), new Short((short)0x440a)); //$NON-NLS-1$
+ ht.put(new String("es_HN"), new Short((short)0x480a)); //$NON-NLS-1$
+ ht.put(new String("es_NI"), new Short((short)0x4c0a)); //$NON-NLS-1$
+ ht.put(new String("es_PR"), new Short((short)0x500a)); //$NON-NLS-1$
+ }
+
+
+ @Override
+ public String[] getAllFamilies() {
+ if (allFamilies != null) {
+ return allFamilies;
+ }
+ if (allFonts == null) {
+ return null;
+ }
+
+ ArrayList<String> al = new ArrayList<String>();
+ String str;
+
+ for (Font font : allFonts) {
+ str = font.getName();
+ if (!al.contains(str)) {
+ al.add(str);
+ }
+ }
+
+ allFamilies = new String[al.size()];
+ al.toArray(allFamilies);
+
+// if (allFamilies != null)
+// for (int i = 0; i < allFamilies.length; i ++) {
+// System.out.println(allFamilies[i]);
+// }
+
+ return allFamilies;
+ }
+
+ @Override
+ public Font[] getAllFonts() {
+ return allFonts.toArray(new Font[0]);
+ }
+
+ public Font embedFont(String path, int type) throws FontFormatException, IOException {
+ Font newFont = addFont(path, type);
+
+ if (newFont == null) {
+ if ((new File(path)).canRead()) {
+ //awt.9B=Can't create font - bad font data
+ throw new FontFormatException ( Messages.getString("awt.9B") ); //$NON-NLS-1$
+ } else {
+ throw new IOException();
+ }
+ }
+
+ allFonts.add(newFont);
+
+ allFamilies = getAllFamilies();
+
+ return newFont;
+ }
+
+ private native Font addFont(String path, int type);
+
+ private native void initManager();
+
+ private native Font[] getAllFontsNative();
+
+ private native void dispose();
+
+ /**
+ * Returns platform-dependent Font peer created from the specified
+ * Font object from the table with cached FontPeers instances.
+ *
+ * Note, this method checks whether FontPeer with specified parameters
+ * exists in the table with cached FontPeers' instances. If there is no needed
+ * instance - it is created and cached.
+ *
+ * @param fontName name of the font
+ * @param _fontStyle style of the font
+ * @param size font size
+ *
+ * @return platform dependent FontPeer implementation created from
+ * the specified parameters
+ */
+ public FontPeer getFontPeer(String fontName, int _fontStyle, int size) {
+
+ //updateFontsTable();
+
+ FontPeer peer = null;
+ String key;
+ String name;
+ int fontStyle = _fontStyle;
+
+ int logicalIndex = getLogicalFaceIndex(fontName);
+
+ if (logicalIndex != -1){
+ name = getLogicalFaceFromFont(fontStyle, logicalIndex);
+ fontStyle = getStyleFromLogicalFace(name);
+ key = name.concat(String.valueOf(size));
+ } else {
+ name = fontName;
+ key = name.concat(String.valueOf(fontStyle)).
+ concat(String.valueOf(size));
+ }
+
+ HashMapReference hmr = fontsTable.get(key);
+ if (hmr != null) {
+ peer = hmr.get();
+ }
+
+ if (peer == null) {
+ peer = createFontPeer(name, fontStyle, size, logicalIndex);
+ if (peer == null){
+ peer = getFontPeer(DIALOG_NAME, fontStyle, size);
+ } else if (logicalIndex == -1) {
+ fontsTable.put(key, new HashMapReference(key, peer, queue));
+ }
+ }
+
+ return peer;
+ }
+
+ /**
+ * Returns default font peer class with "Default" name that is usually
+ * used when font with specified font names and style doesn't exsist
+ * on a system.
+ *
+ * @param style style of the font
+ * @param size size of the font
+ */
+ public FontPeer getDefaultFont(int style, int size){
+
+ FontPeer peer = null;
+ String key = DEFAULT_NAME.concat(String.valueOf(style)).
+ concat(String.valueOf(size));
+
+ HashMapReference hmr = fontsTable.get(key);
+ if (hmr != null) {
+ peer = hmr.get();
+ }
+
+ if (peer == null) {
+ peer = createDefaultFont(style, size);
+
+ ((FontPeerImpl)peer).setFamily(DEFAULT_NAME);
+ ((FontPeerImpl)peer).setPSName(DEFAULT_NAME);
+ ((FontPeerImpl)peer).setFontName(DEFAULT_NAME);
+
+ fontsTable.put(key, new HashMapReference(key, peer, queue));
+ }
+
+ return peer;
+ }
+
+ public void removeFontFromHash(FontPeerImpl font) {
+ fontsTable.remove(font.getName().concat(String.valueOf(font.getStyle())).concat(String.valueOf(font.getSize())));
+ }
+
+ /**
+ * Freeing native resources. This hook is used to avoid
+ * sudden application exit and to free resources created in native code.
+ */
+ private class DisposeNativeHook extends Thread {
+
+ @Override
+ public void run() {
+ try{
+ /* Disposing native font peer's resources */
+ Enumeration<String> kEnum = fontsTable.keys();
+
+ while(kEnum.hasMoreElements()){
+ Object key = kEnum.nextElement();
+ HashMapReference hmr = fontsTable.get(key);
+ FontPeerImpl delPeer = (FontPeerImpl)hmr.get();
+
+ if ((delPeer != null) && (delPeer.getClass() != CompositeFont.class)){
+ // there's nothing to dispose in CompositeFont objects
+
+ delPeer.dispose();
+ }
+ }
+
+ dispose();
+
+ } catch (Throwable t){
+ throw new RuntimeException(t);
+ }
+ }
+ }
+}
Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontPeer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontPeer.java?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontPeer.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontPeer.java Sun Jun 10 10:31:22 2007
@@ -0,0 +1,309 @@
+/*
+ * 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.
+ */
+package org.apache.harmony.awt.gl.font.fontlib;
+
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.util.Hashtable;
+
+import org.apache.harmony.awt.gl.font.FontExtraMetrics;
+import org.apache.harmony.awt.gl.font.FontManager;
+import org.apache.harmony.awt.gl.font.FontPeerImpl;
+import org.apache.harmony.awt.gl.font.Glyph;
+import org.apache.harmony.awt.gl.font.LineMetricsImpl;
+
+final public class FLFontPeer extends FontPeerImpl {
+ private static final boolean USE_CONSTANT_METRICS = false;
+ private static final Hashtable<String, FontPeerNativeHandler> handlersTable = new Hashtable<String, FontPeerNativeHandler>();
+ private static final Hashtable<Integer, FLGlyph> glyphTable = new Hashtable<Integer, FLGlyph>();
+
+ private static long getHandler(String name, int style) {
+ String hash = name.concat(String.valueOf(style));
+
+ FontPeerNativeHandler handl = handlersTable.get(hash);
+
+ if (handl == null) {
+ handl = new FontPeerNativeHandler(name, style);
+
+ handlersTable.put(hash, handl);
+ }
+
+ handl.incriment();
+
+ return handl.getHandl();
+ }
+
+ private static void releaseHandler(String name, int style) {
+ handlersTable.get(name.concat(String.valueOf(style))).decriment();
+ }
+
+ private static final class FontPeerNativeHandler {
+ private long pFont;
+ private char count = 0;
+ private String name;
+ private int style;
+
+ FontPeerNativeHandler(String name, int style) {
+ this.name = name;
+ this.style = style;
+ }
+
+ void incriment(){
+ if (count == 0) {
+ pFont = initFLFontPeer(name, style);
+
+ //System.out.println("pFont = " + pFont + "name = " + name + ", style = " + style);
+ }
+
+ if (pFont == 0) {
+ throw new NullPointerException();
+ }
+
+ count ++;
+ }
+
+ void decriment(){
+ count --;
+
+ if (count == 0) {
+ //System.out.println("native dispose " + pFont);
+
+ dispose(pFont);
+ }
+ }
+
+ long getHandl() {
+ return pFont;
+ }
+
+ }
+ private int missingGlyphCode = -1;
+
+ private Glyph defGlyph;
+
+ public FLFontPeer(String name, int style, int size) {
+ super();
+// if (true) throw new NullPointerException();
+ this.size = size;
+ this.style = style;
+ this.name = name;
+
+ pFont = getHandler(name, style);
+
+ getLineMetrics();
+
+ /* if (pFont != 0){
+ this.numGlyphs = LinuxNativeFont.getNumGlyphsNative(pFont);
+ this.italicAngle = LinuxNativeFont.getItalicAngleNative(pFont, this.fontType);
+ }
+
+ this.nlm = new LinuxLineMetrics(this, null, " "); //$NON-NLS-1$
+
+ this.ascent = nlm.getLogicalAscent();
+ this.descent = nlm.getLogicalDescent();
+ this.height = nlm.getHeight();
+ this.leading = nlm.getLogicalLeading();
+ this.maxAdvance = nlm.getLogicalMaxCharWidth();
+
+ if (this.fontType == FontManager.FONT_TYPE_T1){
+ this.defaultChar = 1;
+ } else {
+ this.defaultChar = 0;
+ }
+
+ this.maxCharBounds = new Rectangle2D.Float(0, -nlm.getAscent(), nlm.getMaxCharWidth(), this.height);
+
+*/
+
+ maxCharBounds = new Rectangle2D.Float(0, -nlm.getAscent(), nlm.getMaxCharWidth(), nlm.getHeight());
+
+ //if (pFont == 0) throw new NullPointerException();
+
+ //System.out.println("create font size " + size + " style " + style + " name " + name + " pFont " + pFont);
+ }
+
+ @Override
+ public FontExtraMetrics getExtraMetrics() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public LineMetrics getLineMetrics(String str, FontRenderContext frc, AffineTransform at) {
+ /*
+ * metrics[0] - ascent<p>
+ * metrics[1] - descent<p>
+ * metrics[2] - external leading<p>
+ * metrics[3] - underline thickness<p>
+ * -metrics[4] - underline offset<p>
+ * metrics[5] - strikethrough thickness<p>
+ * -metrics[6] - strikethrough offset<p>
+ * metrics[7] - maximum char width<p>*/
+
+
+ /*System.out.println("LineMetrics length " + metrics.length + " Font " + pFont);
+ for (int i = 0; i < metrics.length; i ++) {
+ System.out.println(metrics[i]);
+ }//*/
+
+ /**
+ * Creates LineMetricsImpl object from specified parameters. If baseline data parameter
+ * is null than {0, (-ascent+descent)/2, -ascent} values are used for baseline offsets.
+ *
+ * @param _numChars number of chars
+ * @param _baseLineIndex index of the baseline offset
+ * @param _baselineOffsets an array of baseline offsets
+ * @param _underlineThickness underline thickness
+ * @param _underlineOffset underline offset
+ * @param _strikethroughThickness strikethrough thickness
+ * @param _strikethroughOffset strinkethrough offset
+ * @param _leading leading of the font
+ * @param _height font height
+ * @param _ascent ascent of the font
+ * @param _descent descent of the font
+ * @param _maxCharWidth max char width
+ *
+ public LineMetricsImpl(int _numChars, int _baseLineIndex,
+ float[] _baselineOffsets, float _underlineThickness,
+ float _underlineOffset, float _strikethroughThickness,
+ float _strikethroughOffset, float _leading, float _height,
+ float _ascent, float _descent, float _maxCharWidth) {*/
+
+// System.out.println("LineMetricsImpl");
+
+
+ LineMetricsImpl lm;
+ if (USE_CONSTANT_METRICS) {
+ float height = size;
+ float ascent = canDisplay('H') ?
+ getGlyph('H').getHeight() :
+ (height *3) /4;
+ float descent = canDisplay('p') ?
+ (float) getGlyph('p').getGlyphMetrics().getBounds2D().getMaxY() :
+ height / 4;
+
+ lm = new LineMetricsImpl(
+ str.length(), //_numChars number of chars
+ 0, //_baseLineIndex index of the baseline offset
+ new float[]{0, (-ascent+descent)/2, -ascent}, //_baselineOffsets an array of baseline offsets
+ ascent/13, //_underlineThickness underline thickness
+ -descent/2, //_underlineOffset underline offset
+ ascent/13, //_strikethroughThickness strikethrough thickness
+ ascent/2, //_strikethroughOffset strinkethrough offset
+ height - ascent- descent, //_leading leading of the font
+ height, //_height font height
+ ascent, //_ascent ascent of the font
+ descent, //_descent descent of the font
+ canDisplay('W') ? getGlyph('W').getWidth() : getGlyph(' ').getWidth()); //_maxCharWidth max char width
+
+ } else {
+ float[] metrics = getLineMetrics(pFont);
+ lm = new LineMetricsImpl(
+ str.length(), //_numChars number of chars
+ 0, //_baseLineIndex index of the baseline offset
+ new float[]{0, (-metrics[0]+metrics[1])*size/2, -metrics[0]*size}, //_baselineOffsets an array of baseline offsets
+ metrics[3]*size, //_underlineThickness underline thickness
+ metrics[4]*size, //_underlineOffset underline offset
+ metrics[5]*size, //_strikethroughThickness strikethrough thickness
+ metrics[6]*size, //_strikethroughOffset strinkethrough offset
+ metrics[2]*size, //_leading leading of the font
+ (metrics[0] + metrics[1] + metrics[2])*size, //_height font height
+ metrics[0]*size, //_ascent ascent of the font
+ metrics[1]*size, //_descent descent of the font
+ metrics[7]*size); //_maxCharWidth max char width
+ }
+
+
+
+ if ((at != null) && (!at.isIdentity())){
+ lm.scale((float)at.getScaleX(), (float)at.getScaleY());
+ }
+
+ return lm;
+ }
+
+ @Override
+ public String getPSName() {
+ psName = getPSName(pFont);
+ return psName;
+ }
+
+ @Override
+ public int getMissingGlyphCode() {
+ if (missingGlyphCode == -1) {
+ missingGlyphCode = getMissingGlyphCode(pFont);
+ }
+ return missingGlyphCode;
+ }
+
+ @Override
+ public Glyph getGlyph(char ch) {
+ Integer id = new Integer((size << 8) + ch);
+
+ if (!glyphTable.containsKey(id)) {
+ //System.out.println("size = " + size + ", char " + ch + ", id = " + id);
+ glyphTable.put(id, new FLGlyph(ch, pFont, size));
+ }
+
+ return glyphTable.get(id);
+ }
+
+ @Override
+ public void dispose() {
+ ((FLFontManager) FontManager.getInstance()).removeFontFromHash(this);
+
+ //System.out.println("dispose " + pFont);
+
+ releaseHandler(name, style);
+
+ //dispose(pFont);
+ }
+
+ @Override
+ public Glyph getDefaultGlyph() {
+ if (defGlyph == null) {
+ defGlyph = getGlyph((char)0);
+ }
+ return defGlyph;
+ }
+
+ @Override
+ public boolean canDisplay(char c) {
+ return canDisplay(c, pFont);
+ }
+
+ @Override
+ public char getUnicodeByIndex(int glyphCode) {
+ return getUnicodeByIndex(glyphCode, pFont);
+ }
+
+ private static native long initFLFontPeer(String family, int style);
+
+ private static native float[] getLineMetrics(long fontPeerPointer);
+
+ private static native String getPSName(long fontPeerPointer);
+
+ private static native int getMissingGlyphCode(long fontPeerPointer);
+
+ private static native void dispose(long fontPeerPointer);
+
+ private static native boolean canDisplay(char c, long fontPeerPointer);
+
+ private static native char getUnicodeByIndex(int glyphCode, long fontPeerPointer);
+}
Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLFontPeer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLGlyph.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLGlyph.java?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLGlyph.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLGlyph.java Sun Jun 10 10:31:22 2007
@@ -0,0 +1,135 @@
+/*
+ * 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.
+ */
+package org.apache.harmony.awt.gl.font.fontlib;
+
+import java.awt.Shape;
+import java.awt.font.GlyphMetrics;
+
+import org.apache.harmony.awt.gl.font.Glyph;
+
+final public class FLGlyph extends Glyph {
+
+ private long glyphPointer;
+
+// private static final JavaShapeRasterizer jsr = new JavaShapeRasterizer();
+
+ //this.glMetrics = new GlyphMetrics((float)Math.ceil(metrics[2]), rect, (byte)0);
+ /*
+ values[0] = - extents.x ; // Glyph Pixels Bounds : X
+ values[1] = extents.y ; // Glyph Pixels Bounds : Y
+ values[2] = extents.xOff; // Pixels AdvanceX
+ values[3] = extents.yOff; // Pixels AdvanceY ?= Ascent+Descent
+ values[4] = acbox.xMax-acbox.xMin; // Glyph Pixels Bounds : width
+ values[5] = acbox.yMax-acbox.yMin; // Glyph Pixels Bounds : height
+ */
+
+ FLGlyph(char c, long fontPeerPointer, int size) {
+// System.out.println("create glyph char " + (new Integer(c)).intValue() + " " + c + " size " + size + " pfont " + fontPeerPointer);
+
+ glChar = c;
+ glyphPointer = initGlyph(c, size, fontPeerPointer);
+ }
+
+ @Override
+ public byte[] getBitmap() {
+ /*MultiRectArea mra = jsr.rasterize(initOutline(), 0.5);
+
+ Rectangle rec = mra.getBounds();
+ int w = rec.width;
+ int h = rec.height;
+
+ System.out.println(" " + w + " " + h);
+ if(w <= 0 || h <= 0) {
+ return null;
+ }
+
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+
+ ((Graphics2D)bim.getGraphics()).draw(mra);
+
+// bim.getRaster().
+
+
+ int dbufferLenght = w * h;
+
+ DataBufferByte dbuffer = new DataBufferByte(dbufferLenght);
+
+ WritableRaster scanRaster = Raster.createInterleavedRaster(dbuffer, w, h, w, 1,new int[]{0}, null);
+
+ /*WritableRaster scanRaster = Raster.createPackedRaster(
+ dbuffer,
+ (dbufferLenght / h) << 3,
+ h,
+ 1,
+ null
+ );*
+
+ scanRaster.setRect(bim.getRaster());*/
+
+// return dbuffer.getData();
+
+ return null;
+ }
+
+ public Shape initOutline() {
+ if (glOutline == null) {
+ FLPath path = new FLPath(glyphPointer);
+ glOutline = path.getShape();
+ }
+
+ return glOutline;
+ }
+
+ @Override
+ public Shape initOutline(char arg0) {
+ return initOutline();
+ }
+
+ public GlyphMetrics getGlyphMetrics(){
+ if (glMetrics == null) {
+ //System.out.println("getGlyphMetrics");
+ float[] metrics = getGlyphMetrics(glyphPointer);
+
+// System.out.println("x = " + metrics[0] + ", y = " + metrics[1]);
+// System.out.println("after x = " + Math.round(metrics[0]) + ", y = " + Math.round(metrics[1]));
+
+ this.glMetrics = new GlyphMetrics(
+ true,
+ Math.round(metrics[0]),//metrics[0],
+ Math.round(metrics[1]),//metrics[1],
+ //new Rectangle2D.Double(initOutline().getBounds2D().getMinX(), initOutline().getBounds2D().getMinY(), initOutline().getBounds2D().getMaxX() + 5, initOutline().getBounds2D().getMaxY()),
+ initOutline().getBounds2D(),//new Rectangle2D.Float(metrics[2], -metrics[5]-1,metrics[4]- metrics[2] + 1, metrics[5] - metrics[3] + 1),
+ GlyphMetrics.STANDARD);
+
+ /*System.out.println("GlyphMetrics length " + metrics.length + " glyph " + new Integer(glChar));
+ for (int i = 0; i < metrics.length; i ++) {
+ System.out.println(metrics[i]);
+ }*/
+ }
+
+ return glMetrics;
+ }
+
+ public GlyphMetrics getGlyphPointMetrics(){
+ //System.out.println("getGlyphPointMetrics");
+ return glPointMetrics = getGlyphMetrics();
+ }
+
+ private native float[] getGlyphMetrics(long glyphPointer);
+
+ private native long initGlyph(char c, int size, long fontPeerPointer);
+}
Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLGlyph.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLOutline.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLOutline.java?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLOutline.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLOutline.java Sun Jun 10 10:31:22 2007
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+package org.apache.harmony.awt.gl.font.fontlib;
+
+public class FLOutline {
+
+ byte[] commands;
+ float[] points;
+
+ FLOutline() {
+ }
+
+ public void setOutline(byte[] commands, float[] points) {
+ this.commands = commands;
+ this.points = points;
+ }
+
+}
Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLOutline.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLPath.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLPath.java?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLPath.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLPath.java Sun Jun 10 10:31:22 2007
@@ -0,0 +1,117 @@
+/*
+ * 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.
+ */
+package org.apache.harmony.awt.gl.font.fontlib;
+
+import java.awt.Shape;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.PathIterator;
+import java.util.NoSuchElementException;
+
+import org.apache.harmony.awt.internal.nls.Messages;
+
+final public class FLPath implements PathIterator {
+
+ /**
+ * The space amount in points buffer for different segmenet's types
+ */
+ /*private static int pointShift[] = {
+ 0, // CLOSE
+ 2, // LINETO
+ 2, // MOVETO
+ 6, // CUBICTO
+ 4}; // QUADTO*/
+
+ //General path
+ static int pointShift[] = {
+ 2, // MOVETO
+ 2, // LINETO
+ 4, // QUADTO
+ 6, // CUBICTO
+ 0}; // CLOSE
+
+
+
+ /**
+ * The current cursor position in types buffer
+ */
+ int commandsIndex;
+
+ /**
+ * The current cursor position in points buffer
+ */
+ int pointIndex = 0;
+
+ private int size;
+
+ private final FLOutline outline = new FLOutline();
+
+ FLPath(long glyphPointer) {
+ getShape(outline, glyphPointer);
+
+ size = outline.commands.length;
+ }
+
+ public int getWindingRule() {
+ return PathIterator.WIND_EVEN_ODD;
+ }
+
+ public boolean isDone() {
+ return commandsIndex >= size;
+ }
+
+ public void next() {
+ commandsIndex++;
+ }
+
+ public int currentSegment(double[] coords) {
+ if (isDone()) {
+ // awt.4B=Iterator out of bounds
+ throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
+ }
+ int type = outline.commands[commandsIndex];
+ int count = pointShift[type];
+ for (int i = 0; i < count; i++) {
+ coords[i] = outline.points[pointIndex + i];
+ }
+ pointIndex += count;
+ return type;
+ }
+
+ public int currentSegment(float[] coords) {
+ if (isDone()) {
+ // awt.4B=Iterator out of bounds
+ throw new NoSuchElementException(Messages.getString("awt.4B")); //$NON-NLS-1$
+ }
+
+ int type = outline.commands[commandsIndex];
+ int count = pointShift[type];
+
+ System.arraycopy(outline.points, pointIndex, coords, 0, count);
+ pointIndex += count;
+ return type;
+ }
+
+ Shape getShape() {
+ GeneralPath gp = new GeneralPath();
+
+ gp.append(this, false);
+
+ return gp;
+ }
+
+ private native void getShape(FLOutline outline, long glyphPointer);
+}
Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLPath.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLTextRenderer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLTextRenderer.java?view=auto&rev=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLTextRenderer.java (added)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLTextRenderer.java Sun Jun 10 10:31:22 2007
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+package org.apache.harmony.awt.gl.font.fontlib;
+
+import java.awt.Graphics2D;
+import java.awt.font.GlyphVector;
+
+import org.apache.harmony.awt.gl.TextRenderer;
+
+public class FLTextRenderer extends TextRenderer {
+
+ private static final FLTextRenderer inst = new FLTextRenderer();
+
+ public static FLTextRenderer getInstance() {
+ return inst;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.harmony.awt.gl.TextRenderer#drawString(java.awt.Graphics2D, java.lang.String, float, float)
+ */
+ @Override
+ public void drawString(Graphics2D g2d, String str, float x, float y) {
+ g2d.fill(g2d.getFont().createGlyphVector(g2d.getFontRenderContext(), str).getOutline(x, y));
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.harmony.awt.gl.TextRenderer#drawGlyphVector(java.awt.Graphics2D, java.awt.font.GlyphVector, float, float)
+ */
+ @Override
+ public void drawGlyphVector(Graphics2D g2d, GlyphVector gv, float x, float y) {
+ g2d.fill(gv.getOutline(x,y));
+ }
+
+}
Propchange: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/fontlib/FLTextRenderer.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLGraphics2D.java?view=diff&rev=545915&r1=545914&r2=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLGraphics2D.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/opengl/OGLGraphics2D.java Sun Jun 10 10:31:22 2007
@@ -25,6 +25,7 @@
import org.apache.harmony.awt.gl.MultiRectArea;
import org.apache.harmony.awt.gl.Utils;
import org.apache.harmony.awt.gl.Surface;
+import org.apache.harmony.awt.gl.font.FontManager;
import org.apache.harmony.awt.gl.render.NullBlitter;
import org.apache.harmony.awt.wtk.NativeWindow;
import org.apache.harmony.awt.nativebridge.Int32Pointer;
@@ -197,7 +198,9 @@
blitter = OGLBlitter.getInstance();
- jtr = new OGLTextRenderer();
+ if (!FontManager.IS_FONTLIB) {
+ jtr = new OGLTextRenderer();
+ }
}
public OGLGraphics2D(NativeWindow nwin, int tx, int ty, int width, int height) {
Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java?view=diff&rev=545915&r1=545914&r2=545915
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java (original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/unix/org/apache/harmony/awt/gl/linux/XGraphics2D.java Sun Jun 10 10:31:22 2007
@@ -82,7 +82,7 @@
blitter = XBlitter.getInstance();
Rectangle bounds = clip.getBounds();
dstSurf = new XSurface(this, bounds.width, bounds.height);
- jtr = DrawableTextRenderer.inst;
+// jtr = DrawableTextRenderer.inst;
//setTransformedClip(clip);
setClip(clip);