BlackBerry 编程 - 设置标签字体大小

发布于 2024-09-30 20:59:20 字数 637 浏览 2 评论 0原文

我试图使 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿忘初心 2024-10-07 20:59:20

我认为这只是该字体的限制 - 你不能让它大于 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文