简体   繁体   English

为Qt创建位图字体

[英]Creating a bitmap font for Qt

A client has provided files detailing a bitmap font for a very specific LED device. 客户端提供了详细说明非常特定的LED设备的位图字体的文件。 The size of this device is known and will not vary. 该设备的大小是已知的,不会改变。 In addition, the character set is small (ASCII plus some graphics characters). 另外,字符集很小(ASCII加一些图形字符)。

Now we already have software which renders on these devices using a standard Linux font (Arial) with code like: 现在我们已经有了使用标准Linux字体(Arial)在这些设备上呈现的软件,其代码如下:

m_font = new QFont("Arial", m_fontHeight);

So, obviously, it would be easier to take that code and simply substitute our font name in place of Arial, having Qt pick it up automagically. 因此,显然,采用该代码并简单地用我们的字体名称代替Arial会更容易,让Qt自动选择它。

So my question is really to do with how to create a bitmap font in Linux that will be picked up by that. 因此,我的问题确实与如何在Linux中创建一个位图字体有关,该字体将被该字体拾取。 Investigations into tools like FontForge (and indeed the OTF/TTF file formats themselves) seem to indicate that you need to define the fonts in terms of vector graphics, not simple bitmaps. 对诸如FontForge(实际上是OTF / TTF文件格式)之类的工具的调查似乎表明,您需要根据矢量图形而不是简单的位图来定义字体。

I see that pathway fraught with conversion issues, especially since we already have the bitmaps we wish to use for individual characters. 我看到该路径充满转换问题,尤其是因为我们已经有了希望用于单个字符的位图。

Is there an easy way to have Qt (or the underlying Linux font engine) pick up a very simple bitmap-type font file rather than a vector graphics one? 有没有一种简单的方法可以让Qt(或底层的Linux字体引擎)选择一个非常简单的位图类型的字体文件而不是矢量图形文件?

The BDF Format should suit your needs. BDF格式应适合您的需求。 It is able to store raw bitmaps and is compatible to Qt according to their documentation here . 它能够存储原始位图,并且根据此处的文档与Qt兼容。

Qt Documentation Qt文档

Qt uses the FreeType 2 font engine to produce font output. Qt使用FreeType 2字体引擎来生成字体输出。

... ...

The FreeType 2 library can support the following font formats: FreeType 2库可以支持以下字体格式:

  • TrueType (TTF) TrueType(TTF)
  • PostScript Type1 (PFA/PFB) PostScript Type1(PFA / PFB)
  • Bitmap Distribution Format (BDF) 位图分发格式(BDF)
  • CID-keyed Type1 CID键的Type1
  • Compact Font Format (CFF) 紧凑字体格式(CFF)
  • OpenType fonts OpenType字体
  • SFNT-based bitmap fonts 基于SFNT的位图字体
  • Portable Compiled Format (PCF) 便携式编译格式(PCF)
  • Microsoft Windows Font File Format (Windows FNT) Microsoft Windows字体文件格式(Windows FNT)
  • Portable Font Resource (PFR) 便携式字体资源(PFR)
  • Type 42 (limited support) 42型(有限支持)

The future for bitmap fonts is SFNT-based bitmap fonts (basically bitmap glyphs in an OpenType-compatible container). 位图字体的未来是基于SFNT的位图字体(基本上是与OpenType兼容的容器中的位图字形)。 It should work as-is under modern *nix systems, GTK and QT (you may need to make sure no fontconfig rule blacklists bitmap fonts on your target system). 它应该在现代* nix系统,GTK和QT下按原样工作(您可能需要确保目标系统上没有fontconfig规则将位图字体列入黑名单)。

Now the whole "future" for bitmap fonts is bleak and limited, I don't seem them surviving HiDPi and 4K screens . 现在,位图字体的整个“未来”都是黯淡而有限的,我认为它们在HiDPi和4K屏幕上还无法幸存。 Even though SFNT bitmap fonts are your best target, it's not much of one, I doubt the market for bitmap devices is big enough to support an healthy bitmap font software ecosystem. 尽管SFNT位图字体是您的最佳目标,但它的目标并不多,我怀疑位图设备的市场是否足以支持健康的位图字体软件生态系统。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM