简体   繁体   中英

How can I get the directory of the offending file from this Java code

I'm trying to locate the directory of the offending font file per these instructions: http://devnet.jetbrains.com/docs/DOC-172

I am getting an error with the font name. I have searched and deleted matching files, however, but the script keeps throwing an error on the same font name. I suspect there's a hidden copy somewhere on Windows 7 and I'd like to add file directory information to the output.

Is there a way to obtain directory information about the file prior to the exception output? Or is java using something other than file directory structure to derive the list of fonts in the system?

import java.awt.Font;
import java.awt.GraphicsEnvironment;

public class FontTest {
  public static void main(String[] args) {
    Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
    for (int i = 0; i < fonts.length; i++) {
      final Font font = fonts[i];
      final String name = font.getName();

      System.out.print("Checking Font: " + name);

      if (font.canDisplay('a') &&
        font.canDisplay('z') &&
        font.canDisplay('A') &&
        font.canDisplay('Z') &&
        font.canDisplay('0') &&
        font.canDisplay('1')) {
        System.out.println(" OK.");
      } else {
       System.out.println();
      }
    }
  }
}

I figured this out. Windows 7 implements a slick UI for font management. However, this did not display the Adobe Type 1 fonts in the directory. I did a command-line directory inspection and then did a 'search' for one of the files I found. This finally gave me the directory in File Explorer and from there I was able to remove all the Type1 files. PHEW. Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM