Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2002-02-13 20:35:42 +0000
committerSilenio Quarti2002-02-13 20:35:42 +0000
commitbf08d579419148691d68ff3d58785f1979e00e55 (patch)
tree17fdc49f02b747f289fa27959b0496a4332198c4 /bundles/org.eclipse.swt
parentdaa2e3b2a72646e1ec016748054dc47ef1a447f2 (diff)
downloadeclipse.platform.swt-bf08d579419148691d68ff3d58785f1979e00e55.tar.gz
eclipse.platform.swt-bf08d579419148691d68ff3d58785f1979e00e55.tar.xz
eclipse.platform.swt-bf08d579419148691d68ff3d58785f1979e00e55.zip
*** empty log message ***
Diffstat (limited to 'bundles/org.eclipse.swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/OS.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java50
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java2
4 files changed, 65 insertions, 18 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/OS.java
index 83f1c28420..4b7531caa9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/photon/org/eclipse/swt/internal/photon/OS.java
@@ -2567,11 +2567,12 @@ public static final native PhRect_t PfExtentText(PhRect_t extent, PhPoint_t pos,
public static final native int PfQueryFonts(int symbol, int flags, int list, int n);
public static final native byte[] PfGenerateFontName(byte[] pkucDescription, int kuiFlags, int kuiSize, byte[] pucBuff);
//public static final native int PfFindFont(byte[] pkucDescription, int kulFlags, int kulSize);
-//public static final native int PfFreeFont(int ptsID);
-//public static final native int PfFontDescription(int ptsID);
-//public static final native int PfFontSize(int ptsID);
-//public static final native int PfFontFlags(int ptsID);
+public static final native int PfFreeFont(int ptsID);
+public static final native int PfFontDescription(int ptsID);
+public static final native int PfFontSize(int ptsID);
+public static final native int PfFontFlags(int ptsID);
//public static final native int PfConvertFontID(int ptsID);
+public static final native int PfDecomposeStemToID(byte [] pkszStem);
public static final native PhRect_t PgExtentMultiText(PhRect_t extent, PhPoint_t pos, byte[] font, byte[] str, int n, int linespacing);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
index 7a373583f3..ec4f93a710 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
@@ -35,8 +35,13 @@ public final class Font {
*/
Device device;
- static final byte[] DefaultFontName = {(byte)'h', (byte)'e', (byte)'l', (byte)'v'};
- static final byte[] DefaultFont = {(byte)'h', (byte)'e', (byte)'l', (byte)'v', (byte)'1', (byte)'2'};
+ static final byte[] DefaultFontName;
+ static final byte[] DefaultFont;
+
+ static {
+ DefaultFontName = Converter.wcsToMbcs(null, "TextFont", true);
+ DefaultFont = Converter.wcsToMbcs(null, "TextFont09", true);
+ }
Font() {
}
@@ -124,9 +129,10 @@ public boolean equals(Object object) {
byte[] h = ((Font)object).handle;
if (h == handle) return true;
if (h == null || handle == null) return false;
- if (h.length != handle.length) return false;
- for (int i = 0; i < handle.length; i++) {
+ int end = Math.min(h.length, handle.length);
+ for (int i=0; i<end; i++) {
if (handle[i] != h[i]) return false;
+ if (handle[i] == 0) break;
}
return true;
}
@@ -211,7 +217,13 @@ public static Font photon_new(Device device, byte[] stem) {
*/
public String toString () {
if (isDisposed()) return "Font {*DISPOSED*}";
- return "Font {" + new String(handle).trim() + "}";
+ int index = 0;
+ while (index < handle.length) {
+ if (handle[index] == 0) break;
+ index++;
+ }
+ String text = new String(handle, 0, index);
+ return "Font {" + text + "}";
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
index 36c58e834c..26a0e177d2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
@@ -40,19 +40,19 @@ public final class FontData {
* the font name
* (Warning: This field is platform dependent)
*/
- String name;
+ public String name;
/**
* The height of the font data in points
* (Warning: This field is platform dependent)
*/
- int height;
+ public int height;
/**
* the font style
* (Warning: This field is platform dependent)
*/
- int style;
+ public int style;
/**
* A Photon stem
@@ -67,24 +67,57 @@ public final class FontData {
String lang, country, variant;
FontData(byte[] stem) {
+ this.stem = stem;
+ int fontID = OS.PfDecomposeStemToID(stem);
+ if (fontID != 0) {
+ int desc = OS.PfFontDescription(fontID);
+ int size = OS.PfFontSize(fontID);
+ int flags = OS.PfFontFlags(fontID);
+ int length = OS.strlen(desc);
+ byte[] buffer = new byte[length];
+ OS.memmove(buffer, desc, length);
+ name = new String(Converter.mbcsToWcs(null, buffer));
+ height = size;
+ style = SWT.NORMAL;
+ if ((flags & OS.PF_STYLE_BOLD) != 0) style |= SWT.BOLD;
+ if ((flags & OS.PF_STYLE_ITALIC) != 0) style |= SWT.ITALIC;
+ OS.PfFreeFont(fontID);
+ return;
+ }
+ /*
+ * For some reason, PfDecomposeStemToID sometimes fails to decompose
+ * a valid stem (e.g. TextFont09bi).
+ */
FontQueryInfo info = new FontQueryInfo();
if (OS.PfQueryFontInfo(stem, info) == 0) {
this.stem = info.font;
- name = new String(Converter.mbcsToWcs(null, info.desc)).trim();
+ char[] chars = Converter.mbcsToWcs(null, info.desc);
+ int index = 0;
+ while (index < chars.length) {
+ if (chars[index] == 0) break;
+ index++;
+ }
+ name = new String(chars, 0, index);
if ((info.style & OS.PHFONT_INFO_PLAIN) != 0) style = SWT.NORMAL;
else if ((info.style & OS.PHFONT_INFO_BOLD) != 0) style = SWT.BOLD;
else if ((info.style & OS.PHFONT_INFO_ITALIC) != 0) style = SWT.ITALIC;
else if ((info.style & OS.PHFONT_INFO_BLDITC) != 0) style = SWT.BOLD | SWT.ITALIC;
else style = SWT.NORMAL;
/*
- * For some reason, sometimes PfQueryFontInfo does not
+ * For some reason, PfQueryFontInfo sometimes does not
* set the size of the font. In that case, the size is
* parsed from the stem.
*/
if (info.size != 0) {
height = info.size;
} else {
- String fontName = new String(Converter.mbcsToWcs(null, this.stem)).trim();
+ chars = Converter.mbcsToWcs(null, this.stem);
+ index = 0;
+ while (index < chars.length) {
+ if (chars[index] == 0) break;
+ index++;
+ }
+ String fontName = new String(chars, 0, index);
int end = fontName.length();
for (int i = end - 1; i >= 0; i--) {
if (Character.isDigit(fontName.charAt(i))) break;
@@ -99,8 +132,6 @@ FontData(byte[] stem) {
height = Integer.parseInt(fontName.substring(start, end));
} catch (NumberFormatException e) {}
}
- } else {
- this.stem = stem;
}
}
@@ -284,6 +315,7 @@ public int hashCode () {
public void setHeight(int height) {
if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
this.height = height;
+ this.stem = null;
}
/**
@@ -314,6 +346,7 @@ public void setHeight(int height) {
public void setName(String name) {
if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
this.name = name;
+ this.stem = null;
}
/**
@@ -364,6 +397,7 @@ public void setLocale(String locale) {
*/
public void setStyle(int style) {
this.style = style;
+ this.stem = null;
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
index ad618d1c5c..64746c9a99 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
@@ -81,7 +81,7 @@ public int getAscent() {
*/
public int getAverageCharWidth() {
if ((handle.style & OS.PHFONT_INFO_FIXED) != 0) return handle.width;
- return handle.width / 2;
+ return handle.width / 3;
}
/**

Back to the top