BlackBerry 编程 - 设置标签字体大小
我试图使 LabelField 上的字体与 Storm 和 Torch 上的内置数字时钟大小相同。
无论我设置什么尺寸,它似乎都只能达到一定的尺寸,并且不会再增加。
如何增加字体大小/标签宽度?
// set up custom font for timer label
if (FontManager.getInstance().load("Digital Readout Thick Upright.ttf", "DigitalFont", FontManager.APPLICATION_FONT) == FontManager.SUCCESS) {}
try {
FontFamily family = FontFamily.forName("DigitalFont");
// I've tried to set it to 100 but it doesn't make any different
Font digitalFont = family.getFont(Font.BOLD, 72);
lblSpotTime.setFont(digitalFont);
} catch (ClassNotFoundException e) {
System.out.println(e.getMessage());
}
I'm trying to make the font on a LabelField the same size as the built-in digital clock on the Storm and Torch.
No matter what I set the size too, it seems to only goto a certain size and it will no longer increase.
How do I increase the font size / label width?
// set up custom font for timer label
if (FontManager.getInstance().load("Digital Readout Thick Upright.ttf", "DigitalFont", FontManager.APPLICATION_FONT) == FontManager.SUCCESS) {}
try {
FontFamily family = FontFamily.forName("DigitalFont");
// I've tried to set it to 100 but it doesn't make any different
Font digitalFont = family.getFont(Font.BOLD, 72);
lblSpotTime.setFont(digitalFont);
} catch (ClassNotFoundException e) {
System.out.println(e.getMessage());
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这只是该字体的限制 - 你不能让它大于 72。火炬和风暴上的数字时钟可能(几乎肯定)使用嵌入式图像文件来呈现数字。如果您想要一个包含那么大字符的标签字段,您必须通过重写继承字段的绘制方法并自己绘制字符,复制嵌入的图像而不是绘制文本来自己创建。这是一项繁重的工作,我当然不推荐这样做。
I think that's just a limit of that font - you can't make it bigger than 72. The digital clock on the Torch and the Storm probably (almost certainly) uses embedded image files to render the numbers. If you want a label field with characters that big, you'd have to roll your own by overriding your inherited field's paint method and drawing the characters yourself, copying embedded images instead of drawing text. This is a lot of work and I certainly don't recommend it.