| Method from sun.awt.X11GraphicsEnvironment Detail: |
protected void addFontToPlatformFontPath(String platformName) {
if (xFontDirsMap != null) {
String fontID = specificFontIDForName(platformName);
String dirName = (String)xFontDirsMap.get(fontID);
if (dirName != null) {
fontConfigDirs.add(dirName);
}
}
return;
}
|
protected FontConfiguration createFontConfiguration() {
return new MFontConfiguration(this);
}
|
public FontConfiguration createFontConfiguration(boolean preferLocaleFonts,
boolean preferPropFonts) {
return new MFontConfiguration(this,
preferLocaleFonts, preferPropFonts);
}
|
public Point getCenterPoint() {
if (runningXinerama()) {
Point p = getXineramaCenterPoint();
if (p != null) {
return p;
}
}
return super.getCenterPoint();
}
Override for Xinerama case: call new Solaris API for getting the correct
centering point from the windowing system. |
public String getDefaultFontFaceName() {
return null;
}
Returns face name for default font, or null if
no face names are used for CompositeFontDescriptors
for this platform. |
public GraphicsDevice getDefaultScreenDevice() {
return getScreenDevices()[getDefaultScreenNum()];
}
Returns the default screen graphics device. |
protected native int getDefaultScreenNum()
|
public String getFileNameFromPlatformName(String platName) {
String fileName = null;
String fontID = specificFontIDForName(platName);
/* If the font filename has been explicitly assigned in the
* font configuration file, use it. This avoids accessing
* the wrong fonts on Linux, where different fonts (some
* of which may not be usable by 2D) may share the same
* specific font ID. It may also speed up the lookup.
*/
fileName = super.getFileNameFromPlatformName(platName);
if (fileName != null) {
if (isHeadless() && fileName.startsWith("-")) {
/* if it's headless, no xlfd should be used */
return null;
}
if (fileName.startsWith("/")) {
/* If a path is assigned in the font configuration file,
* it is required that the config file also specify using the
* new awtfontpath key the X11 font directories
* which must be added to the X11 font path to support
* AWT access to that font. For that reason we no longer
* have code here to add the parent directory to the list
* of font config dirs, since the parent directory may not
* be sufficient if fonts are symbolically linked to a
* different directory.
*
* Add this XLFD (platform name) to the list of known
* ones for this file.
*/
Vector xVal = (Vector) xlfdMap.get(fileName);
if (xVal == null) {
/* Try to be robust on Linux distros which move fonts
* around by verifying that the fileName represents a
* file that exists. If it doesn't, set it to null
* to trigger a search.
*/
if (getFontConfiguration().needToSearchForFile(fileName)) {
fileName = null;
}
if (fileName != null) {
xVal = new Vector();
xVal.add(platName);
xlfdMap.put(fileName, xVal);
}
} else {
if (!xVal.contains(platName)) {
xVal.add(platName);
}
}
}
if (fileName != null) {
fontNameMap.put(fontID, fileName);
return fileName;
}
}
if (fontID != null) {
fileName = (String)fontNameMap.get(fontID);
/* On Linux check for the Lucida Oblique fonts */
if (fileName == null && isLinux && !isOpenJDK()) {
if (oblmap == null) {
initObliqueLucidaFontMap();
}
String oblkey = getObliqueLucidaFontID(fontID);
if (oblkey != null) {
fileName = oblmap.get(oblkey);
}
}
if (fontPath == null &&
(fileName == null || !fileName.startsWith("/"))) {
if (debugFonts) {
logger.warning("** Registering all font paths because " +
"can't find file for " + platName);
}
fontPath = getPlatformFontPath(noType1Font);
registerFontDirs(fontPath);
if (debugFonts) {
logger.warning("** Finished registering all font paths");
}
fileName = (String)fontNameMap.get(fontID);
}
if (fileName == null && !isHeadless()) {
/* Query X11 directly to see if this font is available
* as a native font.
*/
fileName = getX11FontName(platName);
}
if (fileName == null) {
fontID = switchFontIDForName(platName);
fileName = (String)fontNameMap.get(fontID);
}
if (fileName != null) {
fontNameMap.put(fontID, fileName);
}
}
return fileName;
}
Takes family name property in the following format:
"-linotype-helvetica-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1"
and returns the name of the corresponding physical font.
This code is used to resolve font configuration fonts, and expects
only to get called for these fonts. |
public String getFileNameFromXLFD(String name) {
String fileName = null;
String fontID = specificFontIDForName(name);
if (fontID != null) {
fileName = (String)fontNameMap.get(fontID);
if (fileName == null) {
fontID = switchFontIDForName(name);
fileName = (String)fontNameMap.get(fontID);
}
if (fileName == null) {
fileName = getDefaultFontFile();
}
}
return fileName;
}
Returns the face name for the given XLFD. |
public Rectangle getMaximumWindowBounds() {
if (runningXinerama()) {
return getXineramaWindowBounds();
} else {
return super.getMaximumWindowBounds();
}
}
Override for Xinerama case |
protected String[] getNativeNames(String fontFileName,
String platformName) {
Vector nativeNames;
if ((nativeNames=(Vector)xlfdMap.get(fontFileName))==null) {
if (platformName == null) {
return null;
} else {
/* back-stop so that at least the name used in the
* font configuration file is known as a native name
*/
String []natNames = new String[1];
natNames[0] = platformName;
return natNames;
}
} else {
int len = nativeNames.size();
return (String[])nativeNames.toArray(new String[len]);
}
}
|
protected native int getNumScreens()
|
protected void getPlatformFontPathFromFontConfig() {
if (fontConfigDirs == null) {
fontConfigDirs = getFontConfiguration().getAWTFontPathSet();
if (debugFonts && fontConfigDirs != null) {
String[] names = fontConfigDirs.toArray(new String[0]);
for (int i=0;i< names.length;i++) {
logger.info("awtfontpath : " + names[i]);
}
}
}
}
|
protected Rectangle getXineramaWindowBounds() {
Point center = getCenterPoint();
Rectangle unionRect, tempRect;
GraphicsDevice[] gds = getScreenDevices();
Rectangle centerMonitorRect = null;
int i;
// if center point is at the center of all monitors
// return union of all bounds
//
// MM*MM MMM M
// M*M *
// MMM M
// if center point is at center of a single monitor (but not of all
// monitors)
// return bounds of single monitor
//
// MMM MM
// MM* *M
// else, center is in some strange spot (such as on the border between
// monitors), and we should just return the union of all monitors
//
// MM MMM
// MM MMM
unionRect = getUsableBounds(gds[0]);
for (i = 0; i < gds.length; i++) {
tempRect = getUsableBounds(gds[i]);
if (centerMonitorRect == null &&
// add a pixel or two for fudge-factor
(tempRect.width / 2) + tempRect.x > center.x - 1 &&
(tempRect.height / 2) + tempRect.y > center.y - 1 &&
(tempRect.width / 2) + tempRect.x < center.x + 1 &&
(tempRect.height / 2) + tempRect.y < center.y + 1) {
centerMonitorRect = tempRect;
}
unionRect = unionRect.union(tempRect);
}
// first: check for center of all monitors (video wall)
// add a pixel or two for fudge-factor
if ((unionRect.width / 2) + unionRect.x > center.x - 1 &&
(unionRect.height / 2) + unionRect.y > center.y - 1 &&
(unionRect.width / 2) + unionRect.x < center.x + 1 &&
(unionRect.height / 2) + unionRect.y < center.y + 1) {
if (screenLog.isLoggable(Level.FINER)) {
screenLog.log(Level.FINER, "Video Wall: center point is at center of all displays.");
}
return unionRect;
}
// next, check if at center of one monitor
if (centerMonitorRect != null) {
if (screenLog.isLoggable(Level.FINER)) {
screenLog.log(Level.FINER, "Center point at center of a particular " +
"monitor, but not of the entire virtual display.");
}
return centerMonitorRect;
}
// otherwise, the center is at some weird spot: return unionRect
if (screenLog.isLoggable(Level.FINER)) {
screenLog.log(Level.FINER, "Center point is somewhere strange - return union of all bounds.");
}
return unionRect;
}
Return the bounds for a centered Window on a system running in Xinerama
mode.
Calculations are based on the assumption of a perfectly rectangular
display area (display edges line up with one another, and displays
have consistent width and/or height).
The bounds to return depend on the arrangement of displays and on where
Windows are to be centered. There are two common situations:
1) The center point lies at the center of the combined area of all the
displays. In this case, the combined area of all displays is
returned.
2) The center point lies at the center of a single display. In this case
the user most likely wants centered Windows to be constrained to that
single display. The boundaries of the one display are returned.
It is possible for the center point to be at both the center of the
entire display space AND at the center of a single monitor (a square of
9 monitors, for instance). In this case, the entire display area is
returned.
Because the center point is arbitrarily settable by the user, it could
fit neither of the cases above. The fallback case is to simply return
the combined area for all screens. |
public static boolean isDisplayLocal() {
if (isDisplayLocal == null) {
SunToolkit.awtLock();
try {
if (isDisplayLocal == null) {
isDisplayLocal = Boolean.valueOf(_isDisplayLocal());
}
} finally {
SunToolkit.awtUnlock();
}
}
return isDisplayLocal.booleanValue();
}
|
public static boolean isGLXAvailable() {
return glxAvailable;
}
|
public static boolean isGLXVerbose() {
return glxVerbose;
}
|
public void loadFonts() {
super.loadFonts();
/* These maps are greatly expanded during a loadFonts but
* can be reset to their initial state afterwards.
* Since preferLocaleFonts() and preferProportionalFonts() will
* trigger a partial repopulating from the FontConfiguration
* it has to be the inital (empty) state for the latter two, not
* simply nulling out.
* xFontDirsMap is a special case in that the implementation
* will typically not ever need to initialise it so it can be null.
*/
xFontDirsMap = null;
xlfdMap = new HashMap(1);
fontNameMap = new HashMap(1);
}
|
protected GraphicsDevice makeScreenDevice(int screennum) {
return new X11GraphicsDevice(screennum);
}
|
public void paletteChanged() {
}
From the DisplayChangedListener interface; devices do not need
to react to this event. |
protected void registerFontDir(String path) {
/* fonts.dir file format looks like :-
* 47
* Arial.ttf -monotype-arial-regular-r-normal--0-0-0-0-p-0-iso8859-1
* Arial-Bold.ttf -monotype-arial-bold-r-normal--0-0-0-0-p-0-iso8859-1
* ...
*/
if (debugFonts) {
logger.info("ParseFontDir " + path);
}
File fontsDotDir = new File(path + File.separator + "fonts.dir");
FileReader fr = null;
try {
if (fontsDotDir.canRead()) {
fr = new FileReader(fontsDotDir);
BufferedReader br = new BufferedReader(fr, 8192);
StreamTokenizer st = new StreamTokenizer(br);
st.eolIsSignificant(true);
int ttype = st.nextToken();
if (ttype == StreamTokenizer.TT_NUMBER) {
int numEntries = (int)st.nval;
ttype = st.nextToken();
if (ttype == StreamTokenizer.TT_EOL) {
st.resetSyntax();
st.wordChars(32, 127);
st.wordChars(128 + 32, 255);
st.whitespaceChars(0, 31);
for (int i=0; i < numEntries; i++) {
ttype = st.nextToken();
if (ttype == StreamTokenizer.TT_EOF) {
break;
}
if (ttype != StreamTokenizer.TT_WORD) {
break;
}
int breakPos = st.sval.indexOf(' ");
if (breakPos < = 0) {
/* On TurboLinux 8.0 a fonts.dir file had
* a line with integer value "24" which
* appeared to be the number of remaining
* entries in the file. This didn't add to
* the value on the first line of the file.
* Seemed like XFree86 didn't like this line
* much either. It failed to parse the file.
* Ignore lines like this completely, and
* don't let them count as an entry.
*/
numEntries++;
ttype = st.nextToken();
if (ttype != StreamTokenizer.TT_EOL) {
break;
}
continue;
}
if (st.sval.charAt(0) == '!") {
/* TurboLinux 8.0 comment line: ignore.
* can't use st.commentChar('!') to just
* skip because this line mustn't count
* against numEntries.
*/
numEntries++;
ttype = st.nextToken();
if (ttype != StreamTokenizer.TT_EOL) {
break;
}
continue;
}
String fileName = st.sval.substring(0, breakPos);
/* TurboLinux 8.0 uses some additional syntax to
* indicate algorithmic styling values.
* Ignore ':' separated files at the beginning
* of the fileName
*/
int lastColon = fileName.lastIndexOf(':");
if (lastColon > 0) {
if (lastColon+1 >= fileName.length()) {
continue;
}
fileName = fileName.substring(lastColon+1);
}
String fontPart = st.sval.substring(breakPos+1);
String fontID = specificFontIDForName(fontPart);
String sVal = (String) fontNameMap.get(fontID);
if (debugFonts) {
logger.info("file=" + fileName +
" xlfd=" + fontPart);
logger.info("fontID=" + fontID +
" sVal=" + sVal);
}
String fullPath = null;
try {
File file = new File(path,fileName);
/* we may have a resolved symbolic link
* this becomes important for an xlfd we
* still need to know the location it was
* found to update the X server font path
* for use by AWT heavyweights - and when 2D
* wants to use the native rasteriser.
*/
if (xFontDirsMap == null) {
xFontDirsMap = new HashMap();
}
xFontDirsMap.put(fontID, path);
fullPath = file.getCanonicalPath();
} catch (IOException e) {
fullPath = path + File.separator + fileName;
}
Vector xVal = (Vector) xlfdMap.get(fullPath);
if (debugFonts) {
logger.info("fullPath=" + fullPath +
" xVal=" + xVal);
}
if ((xVal == null || !xVal.contains(fontPart)) &&
(sVal == null) || !sVal.startsWith("/")) {
if (debugFonts) {
logger.info("Map fontID:"+fontID +
"to file:" + fullPath);
}
fontNameMap.put(fontID, fullPath);
if (xVal == null) {
xVal = new Vector();
xlfdMap.put (fullPath, xVal);
}
xVal.add(fontPart);
}
ttype = st.nextToken();
if (ttype != StreamTokenizer.TT_EOL) {
break;
}
}
}
}
fr.close();
}
} catch (IOException ioe1) {
} finally {
if (fr != null) {
try {
fr.close();
} catch (IOException ioe2) {
}
}
}
}
|
protected void registerFontDirs(String pathName) {
StringTokenizer parser = new StringTokenizer(pathName,
File.pathSeparator);
try {
while (parser.hasMoreTokens()) {
String dirPath = parser.nextToken();
if (dirPath != null && !registeredDirs.containsKey(dirPath)) {
registeredDirs.put(dirPath, null);
registerFontDir(dirPath);
}
}
} catch (NoSuchElementException e) {
}
}
|
protected void registerPlatformFontsUsedByFontConfiguration() {
if (fontConfigDirs == null) {
return;
}
if (isLinux) {
fontConfigDirs.add(jreLibDirName+File.separator+"oblique-fonts");
}
fontdirs = (String[])fontConfigDirs.toArray(new String[0]);
}
|
public boolean runningXinerama() {
if (xinerState == null) {
// pRunningXinerama() simply returns a global boolean variable,
// so there is no need to synchronize here
xinerState = Boolean.valueOf(pRunningXinerama());
if (screenLog.isLoggable(Level.FINER)) {
screenLog.log(Level.FINER, "Running Xinerama: " + xinerState);
}
}
return xinerState.booleanValue();
}
|
public static void setNativeFontPath() {
if (fontdirs == null) {
return;
}
// need to register these individually rather than by one call
// to ensure that one bad directory doesn't cause all to be rejected
for (int i=0; i< fontdirs.length; i++) {
if (debugFonts) {
logger.info("Add " + fontdirs[i] + " to X11 fontpath");
}
FontManager.setNativeFontPath(fontdirs[i]);
}
}
|