损坏的TrueType字体检测 [英] Corrupt TrueType Font Detection

查看:146
本文介绍了损坏的TrueType字体检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在处理一个腐败的TrueType字体。可用的程序告诉我, maxp有问题 表 - maxContours 成员的值太大。有没有一个确定的方法来检测 maxContours 值是太高还是太低(是的,这也可能是一个问题)? (字体是程序,所以检测字体文件的一种方法是执行它们,但这不是一个可以接受的解决方案。)

我不需要一个字体库,因为我不能添加一个。我已经推出了我自己的TrueType字体解析器。剩下的是检查上述表格的给定值是否不正确。然后我将我的解析器和检查添加到我的产品。

我没有重建字体的选项。我是一个消费者 - 我需要检测传入的字体是否损坏,如果它是尽可能少的工作纾困。

如果它帮助 - 我在Windows XP / Vista上都是32& 64位及其服务器版本!

解决方案


有没有一种可靠的方法来检测maxContours值太高或太低(是的,也可能是一个问题)?

是。如果您已经建立/拥有了一个TrueType / OpenType解析库,那么这个特定的值就很容易验证。您需要解析每个字形(从'glyf'表 ,使用'loca'表作为索引),从每个字形中逐个获取轮廓的数量,并将字体宽度最大值与存储在'maxp'



请注意,'maxp 不是这个简单的测试;例如,maxZones,maxTwilightPoints,maxStorage,maxFunctionDefs,maxInstructionDefs,maxStackElements,maxSizeOfInstructions都需要解析额外的表,其中一些表可以访问TrueType定标器和解释器。



一点背景:'maxp'(最大配置文件)表旨在作为内存分配的一种辅助手段,作为潜在有用的字体最大值的快捷方式/摘要。所以一般来说,如果'maxp'中的值高于实际的字体值,最糟糕的情况就是分配的内存太多了......也就是说,如果你在一个实际使用所有为此目的的'maxp'值。


I am at present dealing with a corrupt TrueType font. Programs available to me tell me there is a problem with the maxp table -- the maxContours member has a value that is too large. Is there a sure-fire way to detect when a maxContours value is too high or too low (yes that too can be a problem)? (Fonts are programs so one way to detect a font file is good is to execute them, but this is not an acceptable solution for me.)

I don't need a font library because I can't add one. I have already rolled my own TrueType font parser. What remains is to check if a given value of the above mentioned table is incorrect. I'll then add my parser and the checks to my product.

I don't have the option of rebuilding the font. I am a consumer -- I need to detect if the incoming font is corrupt or not and if it is bail out with as little work done as possible.

In case it helps -- I'm on Windows XP/Vista both 32 & 64 bit and their server versions!

解决方案

Is there a sure-fire way to detect when a maxContours value is too high or too low (yes that too can be a problem)?

Yes. If you've already built/have a TrueType/OpenType parsing library as you've indicated, this particular value is fairly easy to validate. You'll need to parse each of the glyphs (from the 'glyf' table, using the 'loca' table as an index), obtain the number of contours from each glyph, one-by-one, and compare the font-wide maximum to that stored in the 'maxp'.

Note that some other values in the 'maxp' are not this simple to test; for example, maxZones, maxTwilightPoints, maxStorage, maxFunctionDefs, maxInstructionDefs, maxStackElements, maxSizeOfInstructions all require parsing of additional tables and for some of those, access to a TrueType scaler and interpreter.

A little background: the 'maxp' (maximum profile) table was intended to be a shortcut/ summary of potentially-useful font-wide maximums, as an aid in memory allocation. So generally speaking, if a value in the 'maxp' is higher than the actual font value, the worst that will happen is that you allocate too much memory...that is, if you're on a platform that actually uses all of the 'maxp' values for that purpose.

这篇关于损坏的TrueType字体检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆