Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2001-09-04 16:24:19 +0000
committerSilenio Quarti2001-09-04 16:24:19 +0000
commitc834e343fe7b1e9703499118bb4656485bc6fc8e (patch)
tree2603567fae74de4f4dd820bd64979b28ced56e91 /bundles
parentd07e719160ad9b5428874b3929f88d189e7c89ac (diff)
downloadeclipse.platform.swt-c834e343fe7b1e9703499118bb4656485bc6fc8e.tar.gz
eclipse.platform.swt-c834e343fe7b1e9703499118bb4656485bc6fc8e.tar.xz
eclipse.platform.swt-c834e343fe7b1e9703499118bb4656485bc6fc8e.zip
ssq -codepage work
Diffstat (limited to 'bundles')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java96
-rw-r--r--bundles/org.eclipse.swt/ws/motif/libswt-linux-2002.sobin377140 -> 371914 bytes
2 files changed, 76 insertions, 20 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
index 3345d70dde..838b61bfe4 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
@@ -8,6 +8,7 @@ package org.eclipse.swt.graphics;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.motif.*;
import org.eclipse.swt.*;
+import java.util.Locale;
/**
* Instances of this class manage operating system resources that
@@ -174,6 +175,7 @@ public FontData[] getFontData() {
int length = OS.strlen(ptr);
byte[] nameBuf = new byte[length];
OS.memmove(nameBuf, ptr, length);
+ /* Use the character encoding for the default locale */
String xlfd = new String(Converter.mbcsToWcs(null, nameBuf)).toLowerCase();
/* Add the xlfd to the array */
String[] newXlfds = new String[xlfds.length + 1];
@@ -251,26 +253,35 @@ public int hashCode () {
return handle;
}
int loadFont(int xDisplay, FontData fd) {
+ /* Use the character encoding for the default locale */
byte[] buffer = Converter.wcsToMbcs(null, fd.getXlfd(), true);
return OS.XLoadQueryFont(xDisplay, buffer);
}
-int matchFont(int xDisplay, FontData fd) {
- int fontStruct = loadFont(xDisplay, fd);
- if (fontStruct != 0) return fontStruct;
+int loadFontSet(int xDisplay, FontData fd) {
+ /* Use the character encoding for the default locale */
+ byte[] buffer = Converter.wcsToMbcs(null, fd.getXlfd(), true);
+ int [] missing_charset = new int [1];
+ int [] missing_charset_count = new int [1];
+ int [] def_string = new int [1];
+ return OS.XCreateFontSet(xDisplay, buffer, missing_charset, missing_charset_count, def_string);
+}
+int matchFont(int xDisplay, FontData fd, boolean fontSet) {
+ int font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);
+ if (font != 0) return font;
if (fd.slant != null) {
fd.slant = null;
- fontStruct = loadFont(xDisplay, fd);
- if (fontStruct != 0) return fontStruct;
+ font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);
+ if (font != 0) return font;
}
if (fd.weight != null) {
fd.weight = null;
- fontStruct = loadFont(xDisplay, fd);
- if (fontStruct != 0) return fontStruct;
+ font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);
+ if (font != 0) return font;
}
if (fd.points != 0) {
fd.points = 0;
- fontStruct = loadFont(xDisplay, fd);
- if (fontStruct != 0) return fontStruct;
+ font = fontSet ? loadFontSet(xDisplay, fd) : loadFont(xDisplay, fd);
+ if (font != 0) return font;
}
return 0;
}
@@ -279,8 +290,53 @@ void init (Device device, FontData fd) {
if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
this.device = device;
int xDisplay = device.xDisplay;
- int fontStruct = loadFont(xDisplay, fd);
- if (fontStruct == 0) {
+ int fontListEntry;
+// int fontStruct = loadFont(xDisplay, fd);
+// if (fontStruct == 0) {
+// /*
+// * If the desired font can not be loaded, the XLFD fields are wildcard
+// * in order to preserve the font style and height. If there is no
+// * font with the desired style and height, the slant, weight and points
+// * are wildcard in that order, until a font can be loaded.
+// */
+// FontData newFD = new FontData();
+// newFD.slant = fd.slant;
+// newFD.weight = fd.weight;
+// newFD.points = fd.points;
+// newFD.characterSetName = fd.characterSetName;
+// if (newFD.characterSetName == null) {
+// newFD.characterSetName = device.characterSetName;
+// }
+// newFD.characterSetRegistry = fd.characterSetRegistry;
+// if (newFD.characterSetRegistry == null) {
+// newFD.characterSetRegistry = device.characterSetRegistry;
+// }
+// fontStruct = matchFont(xDisplay, newFD, false);
+//
+// /* Failed to load any font. Use the system font. */
+// if (fontStruct == 0) {
+// handle = device.systemFont;
+// if (handle != 0) return;
+// }
+// }
+// fontListEntry = OS.XmFontListEntryCreate(OS.XmFONTLIST_DEFAULT_TAG, OS.XmFONT_IS_FONT, fontStruct);
+ Locale locale = fd.locale;
+ if (locale != null) {
+ String lang = locale.getLanguage();
+ String country = locale.getCountry();
+ String variant = locale.getVariant();
+ String osLocale = lang;
+ if (country != null && country.length() > 0) osLocale += "_" + country;
+ if (variant != null && variant.length() > 0) osLocale += "." + variant;
+ int length = osLocale.length();
+ byte [] buffer = new byte[length + 1];
+ for (int i=0; i<length; i++) {
+ buffer[i] = (byte)osLocale.charAt(i);
+ }
+ OS.setlocale (OS.LC_CTYPE, buffer);
+ }
+ int fontSet = loadFontSet(xDisplay, fd);
+ if (fontSet == 0) {
/*
* If the desired font can not be loaded, the XLFD fields are wildcard
* in order to preserve the font style and height. If there is no
@@ -299,16 +355,16 @@ void init (Device device, FontData fd) {
if (newFD.characterSetRegistry == null) {
newFD.characterSetRegistry = device.characterSetRegistry;
}
- fontStruct = matchFont(xDisplay, newFD);
-
- /* Failed to load any font. Use the system font. */
- if (fontStruct == 0) {
- handle = device.systemFont;
- if (handle != 0) return;
- }
+ fontSet = matchFont(xDisplay, newFD, true);
+ }
+ if (locale != null) OS.setlocale (OS.LC_CTYPE, new byte [0]);
+
+ /* Failed to load any font. Use the system font. */
+ if (fontSet == 0) {
+ handle = device.systemFont;
+ if (handle != 0) return;
}
- if (fontStruct == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int fontListEntry = OS.XmFontListEntryCreate(OS.XmFONTLIST_DEFAULT_TAG, OS.XmFONT_IS_FONT, fontStruct);
+ fontListEntry = OS.XmFontListEntryCreate(OS.XmFONTLIST_DEFAULT_TAG, OS.XmFONT_IS_FONTSET, fontSet);
if (fontListEntry == 0) SWT.error(SWT.ERROR_NO_HANDLES);
handle = OS.XmFontListAppendEntry(0, fontListEntry);
OS.XmFontListEntryFree(new int[]{fontListEntry});
diff --git a/bundles/org.eclipse.swt/ws/motif/libswt-linux-2002.so b/bundles/org.eclipse.swt/ws/motif/libswt-linux-2002.so
index ea19ae6c3b..7caed1bfbe 100644
--- a/bundles/org.eclipse.swt/ws/motif/libswt-linux-2002.so
+++ b/bundles/org.eclipse.swt/ws/motif/libswt-linux-2002.so
Binary files differ

Back to the top