我见过针对 C#、PHP 等的类似问题的回答。但我无法在我的 Pascal 工作(Lazarus 和 Delphi)中使用这些解决方案。
问题很简单:我想以编程方式知道某种字体是否具有给定 unicode 字符的字形 - 使用 Lazarus(最好)或至少使用 Delphi。
在我的具体情况下,我想在某些 TLabel 中使用 unicode 箭头字符,但我希望能够检查该字体中是否存在该 unicode 箭头字符。
顺便说一句:我当前的迂回解决方案是获取 unicode 字符的 TextWidth 和 TextHeight,并将其与我确定没有字形的字符(例如 U0001)的 TextWidth 和 TextHeight 进行比较。如果它们不同,则表示该字形存在。如果它们相同,则要么该字符没有字形,要么该字形恰好与(“字形缺失”)替换字符具有相同的大小。显然不是一个非常令人满意的解决方案。如果您能想到更好的回旋处解决方案,请也告诉我。
谢谢!
最佳答案
The
GetGlyphIndices
function translates a string into an array of glyph indices. The function can be used to determine whether a glyph exists in a font.
The
GetFontUnicodeRanges
function returns information about which Unicode characters are supported by a font. The information is returned as aGLYPHSET
structure.
关于delphi - 我如何知道字体是否具有给定 Unicode 字符的字形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54111799/