Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. import java.io.File;
  2. import java.awt.Font;
  3. import java.awt.GraphicsEnvironment;
  4.  
  5. public class myFontCheck {
  6. public static void main(String[] args) {
  7. Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
  8. for (int i = 0; i < fonts.length; i++) {
  9. final Font font = fonts[i];
  10. final String name = font.getFontName();
  11.  
  12. if (font.canDisplay('a') &&
  13. font.canDisplay('z') &&
  14. font.canDisplay('A') &&
  15. font.canDisplay('Z') &&
  16. font.canDisplay('0') &&
  17. font.canDisplay('1')) {
  18. //System.out.println(" OK.");
  19. } else {
  20. File file = new File("c:\Windows\Fonts\" + name + ".ttf");
  21. if(file.exists()) {
  22. System.out.println("Bad Font: " + name);
  23. file.delete();
  24. }
  25. }
  26. }
  27. }
  28. }
  29.  
  30. if (font.canDisplay('a') &&
  31. font.canDisplay('z') &&
  32. font.canDisplay('A') &&
  33. font.canDisplay('Z') &&
  34. font.canDisplay('0') &&
  35. font.canDisplay('1')) {
  36. //System.out.println(" OK.");
  37. } else {
  38. System.out.println("Bad Font: " + name);
  39. File file = new File("c:\Windows\Fonts\" + name + ".ttf");
  40. file.delete();
  41. }
  42.  
  43. } else {
  44. System.out.println("Bad Font: " + name);
  45. String fn = "c:\Windows\Fonts\" + name + ".ttf";
  46. System.out.println("Trying to delete: " + fn);
  47. File file = new File(fn);
  48. file.delete();
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement