Almost all Forums have a Discussion relating to 'Only true type fonts are Supported.This is not a true Type Font' Exception thrown in C#/.NET when a non true type font or a true type font with invalid metadata is selected from a Font Dialog.
This exception occurs because GDI+ Only supports True Type fonts. Modern/open type fonts are not Supported by C#.Open Type fonts has been created by merging the old True Type and PostScript Fonts, as the result the Open type font may have a true type or postscript specification.
Although the Font Dialog control was designed to filter out these Non True Type fonts by using ChooseFont() API call with the CF_TTONLY option ,some Fonts may represent or call themselves as true type fonts.These are the Fonts with bad/Invalid MetaData that causes the Exception.
The Solution???
Unfortunately there is NO SOLUTION,I have found articles on the web giving the following solutions these include
These don't solve the Problem,A person had reported this bug to MicroSoft and here is their Reply:This exception occurs because GDI+ Only supports True Type fonts. Modern/open type fonts are not Supported by C#.Open Type fonts has been created by merging the old True Type and PostScript Fonts, as the result the Open type font may have a true type or postscript specification.
Although the Font Dialog control was designed to filter out these Non True Type fonts by using ChooseFont() API call with the CF_TTONLY option ,some Fonts may represent or call themselves as true type fonts.These are the Fonts with bad/Invalid MetaData that causes the Exception.
The Solution???
Unfortunately there is NO SOLUTION,I have found articles on the web giving the following solutions these include
- Setting FontDialog.AllowSimulations property to false.
- Setting FontDialog.AllowScriptChange property to false
Posted by Microsoft
This is a GDI+ issue and no changes are planned to that code base, therefore we cannot fix this bug.
Posted by Microsoft
The Microsoft Sub-status is now "Investigating"
Posted by Microsoft
Note to customer: This only seems to be an issue at design time. You *can* set the font to VisualUI at runtime. We will continue looking into this from the designer perspective.
Posted by Microsoft
Thanks for reporting this bug, we have been able to repro this issue and are investigating.
Posted by Microsoft
The Microsoft Sub-status is now "Reproduced"
Thanks for reporting this bug, we have been able to repro this issue and are investigating.
Thanks for reporting this bug, we have been able to repro this issue and are investigating.
This was Reported in 2005 and there is not a solution yet.The only Solution that i can offer is designing your own custom font picker or font selector that displays only true type fonts using the FontFamily class that returns only valid true type fonts.
See these links to get started
Custom Font Dialog in WPF
Color and Font Selector Project hosted at Code Project
So,these are the currently available solutions to the Invalid Font Problem of the Font Dialgo control in C#.
Comments are always appreciated.
Python Course in Bangalore
ReplyDeleteReact Course in Bangalore
Automation Anywhere Course in Bangalore
Blue Prism Course in Bangalore
RPA Course in Bangalore
UI Path Course in Bangalore
Clinical SAS Course in Bangalore
Oracle DBA Course in Bangalore
iOS Course in Bangalore
SolidWorks Course in Bangalore