jdk7:sun.font.fontManager替换/如何从fontname获取文件名信息 [英] jdk7: sun.font.fontManager replacement/how to get filename information from fontname

查看:224
本文介绍了jdk7:sun.font.fontManager替换/如何从fontname获取文件名信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Oracle(Sun)JDK6并尝试迁移到Oracle JDK7



我正在使用 sun.awt .GraphicsEnvironment 查找所有系统字体,以便使用它们来更改我的pdf文件中使用的pdf字体。这里是我正在使用的确切代码:

pre $ GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();

//获取所有系统字体
final字体[] fonts = gEnv.getAllFonts();

之后,我需要在系统上得到确切的字体文件路径,所以我使用:

  FontManager.getFontPath(true)+/+ 
FontManager.getFileNameForFontName(font_name);

现在的问题是 sun.font.FontManager 不再是一个类,并已被转换为一个接口。我在网上搜索,并提出了一些我不满意的解决方案,我正在寻找其他的想法来帮助解决我的问题。

发现:
$ b


  1. 在Java 6上部署我的项目而不是Java 7(不建议使用Java 7中的一些新功能)。

  2. 我在网上找到了FontManager类的代码,但是使用它需要包含很多其他的类/接口,这个过程似乎是虚假和耗时的。此外,如果我被允许使用该代码,因为它是Sun公司的所有权。

我需要的是: * 一种在系统上查找确切字体文件路径的方法 *。所有的想法都欢迎。

您不是在说使用哪个JDK(Oracle,OpenJDK,..)。可能您还有

pre $ FontCodeFactory.getInstance()

可用。或者是inteface的实现 Win32FontManager (如果你在Windows上)?


Using Oracle(Sun) JDK6 and trying to move to Oracle JDK7

I am using sun.awt.GraphicsEnvironment to find all system fonts in order to use them to change pdf font used in my pdf file. Here is the exact code I am using:

GraphicsEnvironment gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();

// get all system fonts
final Font[] fonts = gEnv.getAllFonts();

After that I will need to get the exact font file path on the system, so I use:

FontManager.getFontPath(true) + "/" +
               FontManager.getFileNameForFontName(font_name);

The problem now is that sun.font.FontManager is no longer a class and has been converted to an interface. I searched online and came up with some solutions that I am not satisfied with and I am looking for other ideas to help solve my problem.

The solutions that I found:

  1. Deploy my project on Java 6 instead of Java 7 (Not recommend as I use some new features in Java 7).
  2. I found the code of the FontManager class online, but using it will require including a lot of other classes/interfaces and the process seems dummy and time consuming. Also I am not if I am allowed to use that code as it's proprietary of Sun company.

What I need is: *A way to find the exact font file path on the system*. All ideas are welcomed.

解决方案

You're not saying which JDK you use (Oracle, OpenJDK, ..). Possibly you have

FontManagerFactory.getInstance()

available. Or the inteface implementation Win32FontManager (if you're on Windows)?

这篇关于jdk7:sun.font.fontManager替换/如何从fontname获取文件名信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆