深入了解Font字体的使用
2008-11-10 10:25
507 查看
public final class Font extends Object
采用final进行修饰后,不能被其它类继承.
在帮助文档中,没有查到构造方法,说明该方法被屏蔽,如果使用Font对象,不能通过new来实现
在帮助文档中,发现static Font getFont (int face, int style, int size),说明可以采用该方法,获取Font对象.
第一个参数face:
Font.FACE_MONOSPACE:单空格
Font.FACE_SYSTEM:系统
Font.FACE_PROPORTIONAL:均衡
第二个参数style:
Font.STYLE_BOLD:加粗
Font.STYLE_ITALIC:倾斜
Font.STYLE_UNDERLINED:下划线
Font.STYLE_PLAIN:普通
第三个参数size:
Font.SIZE_LARGE:大号字体
Font.SIZE_MEDIUM:中号字体
Font.SIZE_SMALL:小号字体
有了字体对象了,就可以设置StringItem的样式了.
-------------------------------------------------------------------------------
/**
* @作者 Jcuckoo
* @创建日期 2008-11-10
* @版本 V 1.0
*/
public class StringItemFontMIDlet extends MIDlet {
private Display display;
private Form form;
private Font font;
public StringItemFontMIDlet() {
display=Display.getDisplay(this);
form=new Form("StringItem字体测试");
//原始样式
StringItem st0=new StringItem("字体0:","原始显示",Item.PLAIN);
//单空格-加粗-大号字体
font=Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE);
StringItem st1=new StringItem("字体1:","单空格/加粗/大号字体",Item.PLAIN);
st1.setFont(font);
//系统-倾斜-中号字体
font=Font.getFont(Font.FACE_SYSTEM,Font.STYLE_ITALIC,Font.SIZE_MEDIUM);
StringItem st2=new StringItem("字体2","系统/倾斜/中号字体",Item.PLAIN);
st2.setFont(font);
//均衡-下划线-小号字体
font=Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_UNDERLINED,Font.SIZE_SMALL);
StringItem st3=new StringItem("字体3","均衡/下划线/小号字体",Item.PLAIN);
st3.setFont(font);
//单空格-下划线-小号字体
font=Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_UNDERLINED,Font.SIZE_SMALL);
StringItem st4=new StringItem("字体4","单空格/下划线/小号字体",Item.PLAIN);
st3.setFont(font);
form.append(st0);
form.append(st1);
form.append(st2);
form.append(st3);
form.append(st4);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
display.setCurrent(form);
}
}
相关文章推荐
- 深入了解Font字体的使用
- css3之@font-face---再也不用被迫使用web安全字体了
- java 深入了解DTO及如何使用DTO
- 深入了解接口的使用
- 深入了解C语言(函数的参数传递和函数使用参数的方法)
- android中使用iconfont图标字体
- Google Font字体本地化使用提高网站访问速度
- [ExtJS5学习笔记]第五节 使用fontawesome给你的extjs5应用增加字体图标
- Color & Font - 使用颜色和字体
- 【深入了解cocos2d-x 3.x】定时器(scheduler)的使用和原理探究(3)
- Web字体@font-face对于中文字体的使用
- 使用FontLab Studio制作字体
- 如何在photoshop等图像编辑软件中使用Font Awesome字体图标
- 如何在Axure中使用FontAwesome字体图标
- 免费的位图字体制作工具Bitmap Font Generator使用教程
- Android iconfont字体图标的使用
- Color & Font - 使用颜色和字体
- 【C++】模版的概念、使用方法和深入了解
- Unity3D-使用custom font字体以及重叠问题
- 使用CSS3 @font-face实现个性化字体