PDA

View Full Version : How to verify the validity of opentyoe or truetype fonts?



geotdw
22nd April 2013, 21:23
Hi all,

I have a Qt application that requires me to validate the font resources. Basically I have a file ex font.ttf or font.otf that I would like to load in Qt and see if it's a valid file.

Basically my validation I think would need to consist of the following,
1) load the font resource (load face)
2) get the face properties
3) create a glyph container for the loaded font resource
4) see if I could load each glyph present and if failed then conclude that the font file is bad.

Thanks

Santosh Reddy
22nd April 2013, 21:59
Use QFont, QFontInfo, QFontMetrics, QFontMetricsF, and refer Character Map Example (http://qt-project.org/doc/qt-4.8/widgets-charactermap.html)

geotdw
22nd April 2013, 23:41
Thanks for the reply.

I still can't find where in any of the ones you sent me, can I verify it's validity.

I basically do not know how to verify it's validity even though I load it into QFont?
The step example I wrote was one that I had retrieved from FreeType but I am trying
not to include FreeType into my Qt program and see if I could use Qt build in functionalities
to test a font.

What I mean is, once I load my font file into QFont, by retrieving the info of the font using
QFontInfo, is that sufficient enough to verify that the font file is valid?

Thanks

ChrisW67
23rd April 2013, 00:44
is that sufficient enough to verify that the font file is valid?
No. The technical validity, i.e. adherence to standards, of a TrueType or OpenType font is different from the ability of Qt to use some or all of the features offered by the font. Qt is uses FreeType to handle fonts so there's a reasonable chance that a badly corrupted font won't load, but that does not mean everything contained within the font file is perfectly correct, checked, or used. FreeType won't use an OpenType Layout tables even if they are present. FreeType, like all other renderers, contends with (covers for) a range of minor malformations and ambiguities in fonts that arise from a variety of sources.

There are dedicated tools out there for editing, validating and/or correcting fonts:
Microsoft Font Validator (http://www.microsoft.com/typography/fontvalidator.mspx)
Font Forge (http://fontforge.sourceforge.net/)

I believe you can script FontForge.