类sun.awt.X11FontManager源码实例Demo

下面列出了怎么用sun.awt.X11FontManager的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dragonwell8_jdk   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码2 项目: TencentKona-8   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码3 项目: jdk8u60   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码4 项目: jdk8u60   文件: FcFontConfiguration.java
@Override
public String[] getPlatformFontNames() {
    HashSet<String> nameSet = new HashSet<String>();
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FcCompFont[] fcCompFonts = fcm.loadFontConfig();
    for (int i=0; i<fcCompFonts.length; i++) {
        for (int j=0; j<fcCompFonts[i].allFonts.length; j++) {
            nameSet.add(fcCompFonts[i].allFonts[j].fontFile);
        }
    }
    return nameSet.toArray(new String[0]);
}
 
源代码5 项目: openjdk-jdk8u   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码6 项目: openjdk-jdk8u-backup   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码7 项目: openjdk-jdk9   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码8 项目: jdk8u-jdk   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码9 项目: hottub   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码10 项目: openjdk-8-source   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码11 项目: openjdk-8-source   文件: FcFontConfiguration.java
@Override
public String[] getPlatformFontNames() {
    HashSet<String> nameSet = new HashSet<String>();
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FcCompFont[] fcCompFonts = fcm.loadFontConfig();
    for (int i=0; i<fcCompFonts.length; i++) {
        for (int j=0; j<fcCompFonts[i].allFonts.length; j++) {
            nameSet.add(fcCompFonts[i].allFonts[j].fontFile);
        }
    }
    return nameSet.toArray(new String[0]);
}
 
源代码12 项目: openjdk-8   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码13 项目: openjdk-8   文件: FcFontConfiguration.java
@Override
public String[] getPlatformFontNames() {
    HashSet<String> nameSet = new HashSet<String>();
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FcCompFont[] fcCompFonts = fcm.loadFontConfig();
    for (int i=0; i<fcCompFonts.length; i++) {
        for (int j=0; j<fcCompFonts[i].allFonts.length; j++) {
            nameSet.add(fcCompFonts[i].allFonts[j].fontFile);
        }
    }
    return nameSet.toArray(new String[0]);
}
 
源代码14 项目: jdk8u_jdk   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码15 项目: jdk8u-jdk   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码16 项目: jdk8u-jdk   文件: FcFontConfiguration.java
@Override
public String[] getPlatformFontNames() {
    HashSet<String> nameSet = new HashSet<String>();
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FcCompFont[] fcCompFonts = fcm.loadFontConfig();
    for (int i=0; i<fcCompFonts.length; i++) {
        for (int j=0; j<fcCompFonts[i].allFonts.length; j++) {
            nameSet.add(fcCompFonts[i].allFonts[j].fontFile);
        }
    }
    return nameSet.toArray(new String[0]);
}
 
源代码17 项目: jdk8u-dev-jdk   文件: MFontConfiguration.java
protected String getFileNameFromComponentFontName(String componentFontName) {
    // for X11, component font name is XLFD
    // if we have a file name already, just use it; otherwise let's see
    // what the graphics environment can provide
    String fileName = getFileNameFromPlatformName(componentFontName);
    if (fileName != null && fileName.charAt(0) == '/' &&
        !needToSearchForFile(fileName)) {
        return fileName;
    }
    return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
}
 
源代码18 项目: jdk8u-dev-jdk   文件: FcFontConfiguration.java
@Override
public String[] getPlatformFontNames() {
    HashSet<String> nameSet = new HashSet<String>();
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FcCompFont[] fcCompFonts = fcm.loadFontConfig();
    for (int i=0; i<fcCompFonts.length; i++) {
        for (int j=0; j<fcCompFonts[i].allFonts.length; j++) {
            nameSet.add(fcCompFonts[i].allFonts[j].fontFile);
        }
    }
    return nameSet.toArray(new String[0]);
}
 
源代码19 项目: jdk8u60   文件: FcFontConfiguration.java
@Override
public synchronized boolean init() {
    if (fcCompFonts != null) {
        return true;
    }

    setFontConfiguration();
    readFcInfo();
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    if (fcCompFonts == null) {
        fcCompFonts = fcm.loadFontConfig();
        if (fcCompFonts != null) {
            try {
                writeFcInfo();
            } catch (Exception e) {
                if (FontUtilities.debugFonts()) {
                    warning("Exception writing fcInfo " + e);
                }
            }
        } else if (FontUtilities.debugFonts()) {
            warning("Failed to get info from libfontconfig");
        }
    } else {
        fcm.populateFontConfig(fcCompFonts);
    }

    if (fcCompFonts == null) {
        return false; // couldn't load fontconfig.
    }

    // NB already in a privileged block from SGE
    String javaHome = System.getProperty("java.home");
    if (javaHome == null) {
        throw new Error("java.home property not set");
    }
    String javaLib = javaHome + File.separator + "lib";
    getInstalledFallbackFonts(javaLib);

    return true;
}
 
源代码20 项目: jdk8u60   文件: FcFontConfiguration.java
@Override
public CompositeFontDescriptor[] get2DCompositeFontInfo() {

    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FcCompFont[] fcCompFonts = fcm.loadFontConfig();

    CompositeFontDescriptor[] result =
            new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES];

    for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) {
        String fontName = publicFontNames[fontIndex];

        for (int styleIndex = 0; styleIndex < NUM_STYLES; styleIndex++) {

            String faceName = fontName + "." + styleNames[styleIndex];
            FontConfigFont[] fcFonts =
                getFcFontList(fcCompFonts,
                              fontNames[fontIndex], styleIndex);

            int numFonts = fcFonts.length;
            // fall back fonts listed in the lib/fonts/fallback directory
            if (installedFallbackFontFiles != null) {
                numFonts += installedFallbackFontFiles.length;
            }

            String[] fileNames = new String[numFonts];
            String[] faceNames = new String[numFonts];

            int index;
            for (index = 0; index < fcFonts.length; index++) {
                fileNames[index] = fcFonts[index].fontFile;
                faceNames[index] = fcFonts[index].familyName;
            }

            if (installedFallbackFontFiles != null) {
                System.arraycopy(installedFallbackFontFiles, 0,
                                 fileNames, fcFonts.length,
                                 installedFallbackFontFiles.length);
            }

            result[fontIndex * NUM_STYLES + styleIndex]
                    = new CompositeFontDescriptor(
                        faceName,
                        1,
                        faceNames,
                        fileNames,
                        null, null);
        }
    }
    return result;
}
 
源代码21 项目: jdk8u60   文件: FcFontConfiguration.java
private void writeFcInfo() {
    Properties props = new Properties();
    props.setProperty("version", fileVersion);
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FontConfigInfo fcInfo = fcm.getFontConfigInfo();
    props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion));
    if (fcInfo.cacheDirs != null) {
        for (int i=0;i<fcInfo.cacheDirs.length;i++) {
            if (fcInfo.cacheDirs[i] != null) {
               props.setProperty("cachedir."+i,  fcInfo.cacheDirs[i]);
            }
        }
    }
    for (int i=0; i<fcCompFonts.length; i++) {
        FcCompFont fci = fcCompFonts[i];
        String styleKey = fci.jdkName+"."+fci.style;
        props.setProperty(styleKey+".length",
                          Integer.toString(fci.allFonts.length));
        for (int j=0; j<fci.allFonts.length; j++) {
            props.setProperty(styleKey+"."+j+".family",
                              fci.allFonts[j].familyName);
            props.setProperty(styleKey+"."+j+".file",
                              fci.allFonts[j].fontFile);
        }
    }
    try {
        /* This writes into a temp file then renames when done.
         * Since the rename is an atomic action within the same
         * directory no client will ever see a partially written file.
         */
        File fcInfoFile = getFcInfoFile();
        File dir = fcInfoFile.getParentFile();
        dir.mkdirs();
        File tempFile = Files.createTempFile(dir.toPath(), "fcinfo", null).toFile();
        FileOutputStream fos = new FileOutputStream(tempFile);
        props.store(fos,
                  "JDK Font Configuration Generated File: *Do Not Edit*");
        fos.close();
        boolean renamed = tempFile.renameTo(fcInfoFile);
        if (!renamed && FontUtilities.debugFonts()) {
            System.out.println("rename failed");
            warning("Failed renaming file to "+ getFcInfoFile());
        }
    } catch (Exception e) {
        if (FontUtilities.debugFonts()) {
            warning("IOException writing to "+ getFcInfoFile());
        }
    }
}
 
源代码22 项目: openjdk-8-source   文件: FcFontConfiguration.java
@Override
public synchronized boolean init() {
    if (fcCompFonts != null) {
        return true;
    }

    setFontConfiguration();
    readFcInfo();
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    if (fcCompFonts == null) {
        fcCompFonts = fcm.loadFontConfig();
        if (fcCompFonts != null) {
            try {
                writeFcInfo();
            } catch (Exception e) {
                if (FontUtilities.debugFonts()) {
                    warning("Exception writing fcInfo " + e);
                }
            }
        } else if (FontUtilities.debugFonts()) {
            warning("Failed to get info from libfontconfig");
        }
    } else {
        fcm.populateFontConfig(fcCompFonts);
    }

    if (fcCompFonts == null) {
        return false; // couldn't load fontconfig.
    }

    // NB already in a privileged block from SGE
    String javaHome = System.getProperty("java.home");
    if (javaHome == null) {
        throw new Error("java.home property not set");
    }
    String javaLib = javaHome + File.separator + "lib";
    getInstalledFallbackFonts(javaLib);

    return true;
}
 
源代码23 项目: openjdk-8-source   文件: FcFontConfiguration.java
@Override
public CompositeFontDescriptor[] get2DCompositeFontInfo() {

    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FcCompFont[] fcCompFonts = fcm.loadFontConfig();

    CompositeFontDescriptor[] result =
            new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES];

    for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) {
        String fontName = publicFontNames[fontIndex];

        for (int styleIndex = 0; styleIndex < NUM_STYLES; styleIndex++) {

            String faceName = fontName + "." + styleNames[styleIndex];
            FontConfigFont[] fcFonts =
                getFcFontList(fcCompFonts,
                              fontNames[fontIndex], styleIndex);

            int numFonts = fcFonts.length;
            // fall back fonts listed in the lib/fonts/fallback directory
            if (installedFallbackFontFiles != null) {
                numFonts += installedFallbackFontFiles.length;
            }

            String[] fileNames = new String[numFonts];

            int index;
            for (index = 0; index < fcFonts.length; index++) {
                fileNames[index] = fcFonts[index].fontFile;
            }

            if (installedFallbackFontFiles != null) {
                System.arraycopy(installedFallbackFontFiles, 0,
                                 fileNames, fcFonts.length,
                                 installedFallbackFontFiles.length);
            }

            result[fontIndex * NUM_STYLES + styleIndex]
                    = new CompositeFontDescriptor(
                        faceName,
                        1,
                        null,
                        fileNames,
                        null, null);
        }
    }
    return result;
}
 
源代码24 项目: openjdk-8-source   文件: FcFontConfiguration.java
private void writeFcInfo() {
    Properties props = new Properties();
    props.setProperty("version", fileVersion);
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FontConfigInfo fcInfo = fcm.getFontConfigInfo();
    props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion));
    if (fcInfo.cacheDirs != null) {
        for (int i=0;i<fcInfo.cacheDirs.length;i++) {
            if (fcInfo.cacheDirs[i] != null) {
               props.setProperty("cachedir."+i,  fcInfo.cacheDirs[i]);
            }
        }
    }
    for (int i=0; i<fcCompFonts.length; i++) {
        FcCompFont fci = fcCompFonts[i];
        String styleKey = fci.jdkName+"."+fci.style;
        props.setProperty(styleKey+".length",
                          Integer.toString(fci.allFonts.length));
        for (int j=0; j<fci.allFonts.length; j++) {
            props.setProperty(styleKey+"."+j+".family",
                              fci.allFonts[j].familyName);
            props.setProperty(styleKey+"."+j+".file",
                              fci.allFonts[j].fontFile);
        }
    }
    try {
        /* This writes into a temp file then renames when done.
         * Since the rename is an atomic action within the same
         * directory no client will ever see a partially written file.
         */
        File fcInfoFile = getFcInfoFile();
        File dir = fcInfoFile.getParentFile();
        dir.mkdirs();
        File tempFile = Files.createTempFile(dir.toPath(), "fcinfo", null).toFile();
        FileOutputStream fos = new FileOutputStream(tempFile);
        props.store(fos,
                  "JDK Font Configuration Generated File: *Do Not Edit*");
        fos.close();
        boolean renamed = tempFile.renameTo(fcInfoFile);
        if (!renamed && FontUtilities.debugFonts()) {
            System.out.println("rename failed");
            warning("Failed renaming file to "+ getFcInfoFile());
        }
    } catch (Exception e) {
        if (FontUtilities.debugFonts()) {
            warning("IOException writing to "+ getFcInfoFile());
        }
    }
}
 
源代码25 项目: openjdk-8   文件: FcFontConfiguration.java
@Override
public synchronized boolean init() {
    if (fcCompFonts != null) {
        return true;
    }

    setFontConfiguration();
    readFcInfo();
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    if (fcCompFonts == null) {
        fcCompFonts = fcm.loadFontConfig();
        if (fcCompFonts != null) {
            try {
                writeFcInfo();
            } catch (Exception e) {
                if (FontUtilities.debugFonts()) {
                    warning("Exception writing fcInfo " + e);
                }
            }
        } else if (FontUtilities.debugFonts()) {
            warning("Failed to get info from libfontconfig");
        }
    } else {
        fcm.populateFontConfig(fcCompFonts);
    }

    if (fcCompFonts == null) {
        return false; // couldn't load fontconfig.
    }

    // NB already in a privileged block from SGE
    String javaHome = System.getProperty("java.home");
    if (javaHome == null) {
        throw new Error("java.home property not set");
    }
    String javaLib = javaHome + File.separator + "lib";
    getInstalledFallbackFonts(javaLib);

    return true;
}
 
源代码26 项目: openjdk-8   文件: FcFontConfiguration.java
@Override
public CompositeFontDescriptor[] get2DCompositeFontInfo() {

    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FcCompFont[] fcCompFonts = fcm.loadFontConfig();

    CompositeFontDescriptor[] result =
            new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES];

    for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) {
        String fontName = publicFontNames[fontIndex];

        for (int styleIndex = 0; styleIndex < NUM_STYLES; styleIndex++) {

            String faceName = fontName + "." + styleNames[styleIndex];
            FontConfigFont[] fcFonts =
                getFcFontList(fcCompFonts,
                              fontNames[fontIndex], styleIndex);

            int numFonts = fcFonts.length;
            // fall back fonts listed in the lib/fonts/fallback directory
            if (installedFallbackFontFiles != null) {
                numFonts += installedFallbackFontFiles.length;
            }

            String[] fileNames = new String[numFonts];

            int index;
            for (index = 0; index < fcFonts.length; index++) {
                fileNames[index] = fcFonts[index].fontFile;
            }

            if (installedFallbackFontFiles != null) {
                System.arraycopy(installedFallbackFontFiles, 0,
                                 fileNames, fcFonts.length,
                                 installedFallbackFontFiles.length);
            }

            result[fontIndex * NUM_STYLES + styleIndex]
                    = new CompositeFontDescriptor(
                        faceName,
                        1,
                        null,
                        fileNames,
                        null, null);
        }
    }
    return result;
}
 
源代码27 项目: openjdk-8   文件: FcFontConfiguration.java
private void writeFcInfo() {
    Properties props = new Properties();
    props.setProperty("version", fileVersion);
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FontConfigInfo fcInfo = fcm.getFontConfigInfo();
    props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion));
    if (fcInfo.cacheDirs != null) {
        for (int i=0;i<fcInfo.cacheDirs.length;i++) {
            if (fcInfo.cacheDirs[i] != null) {
               props.setProperty("cachedir."+i,  fcInfo.cacheDirs[i]);
            }
        }
    }
    for (int i=0; i<fcCompFonts.length; i++) {
        FcCompFont fci = fcCompFonts[i];
        String styleKey = fci.jdkName+"."+fci.style;
        props.setProperty(styleKey+".length",
                          Integer.toString(fci.allFonts.length));
        for (int j=0; j<fci.allFonts.length; j++) {
            props.setProperty(styleKey+"."+j+".family",
                              fci.allFonts[j].familyName);
            props.setProperty(styleKey+"."+j+".file",
                              fci.allFonts[j].fontFile);
        }
    }
    try {
        /* This writes into a temp file then renames when done.
         * Since the rename is an atomic action within the same
         * directory no client will ever see a partially written file.
         */
        File fcInfoFile = getFcInfoFile();
        File dir = fcInfoFile.getParentFile();
        dir.mkdirs();
        File tempFile = Files.createTempFile(dir.toPath(), "fcinfo", null).toFile();
        FileOutputStream fos = new FileOutputStream(tempFile);
        props.store(fos,
                  "JDK Font Configuration Generated File: *Do Not Edit*");
        fos.close();
        boolean renamed = tempFile.renameTo(fcInfoFile);
        if (!renamed && FontUtilities.debugFonts()) {
            System.out.println("rename failed");
            warning("Failed renaming file to "+ getFcInfoFile());
        }
    } catch (Exception e) {
        if (FontUtilities.debugFonts()) {
            warning("IOException writing to "+ getFcInfoFile());
        }
    }
}
 
源代码28 项目: jdk8u-jdk   文件: FcFontConfiguration.java
@Override
public synchronized boolean init() {
    if (fcCompFonts != null) {
        return true;
    }

    setFontConfiguration();
    readFcInfo();
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    if (fcCompFonts == null) {
        fcCompFonts = fcm.loadFontConfig();
        if (fcCompFonts != null) {
            try {
                writeFcInfo();
            } catch (Exception e) {
                if (FontUtilities.debugFonts()) {
                    warning("Exception writing fcInfo " + e);
                }
            }
        } else if (FontUtilities.debugFonts()) {
            warning("Failed to get info from libfontconfig");
        }
    } else {
        fcm.populateFontConfig(fcCompFonts);
    }

    if (fcCompFonts == null) {
        return false; // couldn't load fontconfig.
    }

    // NB already in a privileged block from SGE
    String javaHome = System.getProperty("java.home");
    if (javaHome == null) {
        throw new Error("java.home property not set");
    }
    String javaLib = javaHome + File.separator + "lib";
    getInstalledFallbackFonts(javaLib);

    return true;
}
 
源代码29 项目: jdk8u-jdk   文件: FcFontConfiguration.java
@Override
public CompositeFontDescriptor[] get2DCompositeFontInfo() {

    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FcCompFont[] fcCompFonts = fcm.loadFontConfig();

    CompositeFontDescriptor[] result =
            new CompositeFontDescriptor[NUM_FONTS * NUM_STYLES];

    for (int fontIndex = 0; fontIndex < NUM_FONTS; fontIndex++) {
        String fontName = publicFontNames[fontIndex];

        for (int styleIndex = 0; styleIndex < NUM_STYLES; styleIndex++) {

            String faceName = fontName + "." + styleNames[styleIndex];
            FontConfigFont[] fcFonts =
                getFcFontList(fcCompFonts,
                              fontNames[fontIndex], styleIndex);

            int numFonts = fcFonts.length;
            // fall back fonts listed in the lib/fonts/fallback directory
            if (installedFallbackFontFiles != null) {
                numFonts += installedFallbackFontFiles.length;
            }

            String[] fileNames = new String[numFonts];
            String[] faceNames = new String[numFonts];

            int index;
            for (index = 0; index < fcFonts.length; index++) {
                fileNames[index] = fcFonts[index].fontFile;
                faceNames[index] = fcFonts[index].familyName;
            }

            if (installedFallbackFontFiles != null) {
                System.arraycopy(installedFallbackFontFiles, 0,
                                 fileNames, fcFonts.length,
                                 installedFallbackFontFiles.length);
            }

            result[fontIndex * NUM_STYLES + styleIndex]
                    = new CompositeFontDescriptor(
                        faceName,
                        1,
                        faceNames,
                        fileNames,
                        null, null);
        }
    }
    return result;
}
 
源代码30 项目: jdk8u-jdk   文件: FcFontConfiguration.java
private void writeFcInfo() {
    Properties props = new Properties();
    props.setProperty("version", fileVersion);
    X11FontManager fm = (X11FontManager) fontManager;
    FontConfigManager fcm = fm.getFontConfigManager();
    FontConfigInfo fcInfo = fcm.getFontConfigInfo();
    props.setProperty("fcversion", Integer.toString(fcInfo.fcVersion));
    if (fcInfo.cacheDirs != null) {
        for (int i=0;i<fcInfo.cacheDirs.length;i++) {
            if (fcInfo.cacheDirs[i] != null) {
               props.setProperty("cachedir."+i,  fcInfo.cacheDirs[i]);
            }
        }
    }
    for (int i=0; i<fcCompFonts.length; i++) {
        FcCompFont fci = fcCompFonts[i];
        String styleKey = fci.jdkName+"."+fci.style;
        props.setProperty(styleKey+".length",
                          Integer.toString(fci.allFonts.length));
        for (int j=0; j<fci.allFonts.length; j++) {
            props.setProperty(styleKey+"."+j+".family",
                              fci.allFonts[j].familyName);
            props.setProperty(styleKey+"."+j+".file",
                              fci.allFonts[j].fontFile);
        }
    }
    try {
        /* This writes into a temp file then renames when done.
         * Since the rename is an atomic action within the same
         * directory no client will ever see a partially written file.
         */
        File fcInfoFile = getFcInfoFile();
        File dir = fcInfoFile.getParentFile();
        dir.mkdirs();
        File tempFile = Files.createTempFile(dir.toPath(), "fcinfo", null).toFile();
        FileOutputStream fos = new FileOutputStream(tempFile);
        props.store(fos,
                  "JDK Font Configuration Generated File: *Do Not Edit*");
        fos.close();
        boolean renamed = tempFile.renameTo(fcInfoFile);
        if (!renamed && FontUtilities.debugFonts()) {
            System.out.println("rename failed");
            warning("Failed renaming file to "+ getFcInfoFile());
        }
    } catch (Exception e) {
        if (FontUtilities.debugFonts()) {
            warning("IOException writing to "+ getFcInfoFile());
        }
    }
}
 
 类所在包
 类方法
 同包方法