OpenType is a format for scalable computer fonts. It was built on its predecessor TrueType, retaining TrueType’s basic structure and adding many intricate data structures for prescribing typographic behavior.
Note
Please find more information on the OpenType format here: https://en.wikipedia.org/wiki/OpenType.
Reading OpenType metadata
The GroupDocs.Metadata API supports extracting format-specific information from OpenType font files.
The following are the steps to read the header of an OpenType file.
using(Metadatametadata=newMetadata(Constants.InputTtf)){varroot=metadata.GetRootPackage<OpenTypeRootPackage>();// Read the OpenType font metadataforeach(varmetadataEntryinroot.OpenTypePackage.Fonts){// Display the values of some metadata propertiesConsole.WriteLine(metadataEntry.Created);Console.WriteLine(metadataEntry.DirectionHint);Console.WriteLine(metadataEntry.EmbeddingLicensingRights);Console.WriteLine(metadataEntry.Flags);Console.WriteLine(metadataEntry.FontFamilyName);Console.WriteLine(metadataEntry.FontRevision);Console.WriteLine(metadataEntry.FontSubfamilyName);Console.WriteLine(metadataEntry.FullFontName);Console.WriteLine(metadataEntry.GlyphBounds);Console.WriteLine(metadataEntry.MajorVersion);Console.WriteLine(metadataEntry.MinorVersion);Console.WriteLine(metadataEntry.Modified);Console.WriteLine(metadataEntry.SfntVersion);Console.WriteLine(metadataEntry.Style);Console.WriteLine(metadataEntry.TypographicFamily);Console.WriteLine(metadataEntry.TypographicSubfamily);Console.WriteLine(metadataEntry.Weight);Console.WriteLine(metadataEntry.Width);foreach(OpenTypeBaseNameRecordnameRecordinmetadataEntry.Names){Console.WriteLine(nameRecord.NameID);Console.WriteLine(nameRecord.Platform);Console.WriteLine(nameRecord.Value);OpenTypeMacintoshNameRecordmacintoshNameRecord=nameRecordasOpenTypeMacintoshNameRecord;if(macintoshNameRecord!=null){Console.WriteLine(macintoshNameRecord.Encoding);Console.WriteLine(macintoshNameRecord.Language);}else{OpenTypeUnicodeNameRecordunicodeNameRecord=nameRecordasOpenTypeUnicodeNameRecord;if(unicodeNameRecord!=null){Console.WriteLine(unicodeNameRecord.Encoding);}else{OpenTypeWindowsNameRecordwindowsNameRecord=nameRecordasOpenTypeWindowsNameRecord;if(windowsNameRecord!=null){Console.WriteLine(windowsNameRecord.Encoding);Console.WriteLine(windowsNameRecord.Language);}}}}}}
Reading digital signatures
The code snippet bellow demonstrates how to extract information about digital signatures associated with an OpenType font.
publicstaticvoidRun(){using(Metadatametadata=newMetadata(Constants.InputTtf)){varroot=metadata.GetRootPackage<OpenTypeRootPackage>();if(root.DigitalSignaturePackage!=null){Console.WriteLine(root.DigitalSignaturePackage.Flags);foreach(varsignatureinroot.DigitalSignaturePackage.Signatures){Console.WriteLine(signature.SignTime);if(signature.DigestAlgorithms!=null){foreach(varsignatureDigestAlgorithminsignature.DigestAlgorithms){PrintOid(signatureDigestAlgorithm);}}if(signature.EncapsulatedContent!=null){PrintOid(signature.EncapsulatedContent.ContentType);Console.WriteLine(signature.EncapsulatedContent.ContentRawData.Length);}if(signature.Certificates!=null){foreach(varcertificateinsignature.Certificates){Console.WriteLine(certificate.NotAfter);Console.WriteLine(certificate.NotBefore);Console.WriteLine(certificate.RawData.Length);}}if(signature.Signers!=null){foreach(varsignerInfoEntryinsignature.Signers){Console.WriteLine(signerInfoEntry.SignatureValue);PrintOid(signerInfoEntry.DigestAlgorithm);PrintOid(signerInfoEntry.SignatureAlgorithm);Console.WriteLine(signerInfoEntry.SigningTime);PrintAttributes(signerInfoEntry.SignedAttributes);PrintAttributes(signerInfoEntry.UnsignedAttributes);}}}}}}privatestaticvoidPrintOid(Oidoid){// Display the property name and value of OIDif(oid!=null){Console.WriteLine(oid.FriendlyName);Console.WriteLine(oid.Value);}}privatestaticvoidPrintAttributes(CmsAttribute[]attributes){//Display the CmsAttributes of an OIDif(attributes!=null){foreach(CmsAttributeattributeinattributes){PrintOid(attribute.Oid);Console.WriteLine(attribute.Value);}}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.