今天要写一个给图片加文字水印的小应用,其中涉及到getFontMetrics这个方法,它用于描述字体对象的特征,查了一下它的构造函数(有两个):
public final FontMetrics getFontMetrics()
public final FontMetrics getFontMetrics( Graphics gr )
返回值是FontMetrics对象,该对象已被初始化为描述这个字体对象的基本字体。
需要说明的是,虽然字体对象维护的FontMetrics对象会包含请求的字体特性,但是,调用该方法后的对象可能会不匹配所设置的参数信息,出现这样的问题是因为有的字体信息是不可用的,我试了一下,自己新增的字体类,或者是框架外的字体信息在参数化时会出现异常哦。。
public final FontMetrics getFontMetrics()
public final FontMetrics getFontMetrics( Graphics gr )
返回值是FontMetrics对象,该对象已被初始化为描述这个字体对象的基本字体。
需要说明的是,虽然字体对象维护的FontMetrics对象会包含请求的字体特性,但是,调用该方法后的对象可能会不匹配所设置的参数信息,出现这样的问题是因为有的字体信息是不可用的,我试了一下,自己新增的字体类,或者是框架外的字体信息在参数化时会出现异常哦。。