This content has moved — please find it at https://devblog.cyotek.com.
Although these pages remain accessible, some content may not display correctly in future as the new blog evolves.
Visit https://devblog.cyotek.com.
One of the exceptions I see with a reasonable frequency (usually
in Gif Animator) is Only TrueType fonts are supported.
This is not a TrueType font.
System.ArgumentException: Only TrueType fonts are supported. This is not a TrueType font.
at System.Drawing.Font.FromLogFont(Object lf, IntPtr hdc)
at System.Windows.Forms.FontDialog.UpdateFont(LOGFONT lf)
at System.Windows.Forms.FontDialog.RunDialog(IntPtr hWndOwner)
at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
This exception is thrown when using the
System.Windows.Forms.FontDialog
component and you select an
invalid font. And you can’t do a thing about it*, as
this exception is buried in a private method of the FontDialog
that isn’t handled.
As the bug has been there for years without being fixed, and
given that fact that Windows Forms isn’t exactly high on the
list of priorities for Microsoft, I suspect it will never be
fixed. This is one wheel I’d prefer not to reinvent, but… here
it is anyway.
The Cyotek.Windows.Forms.FontDialog
component is a drop in
replacement for the original System.Windows.Forms.FontDialog
,
but without the crash that occurs when selecting a non-True Type
font.
This version uses the native Win32 dialog via ChooseFont
— the
hook procedure to handle the Apply
event and hiding the colour
combobox has been taken directly from the original component. As
I’m inheriting from the same base component and have replicated
the API completely, you should simply be able to replace
System.Windows.Forms.FontDialog
with
Cyotek.Windows.Forms.FontDialog
and it will work.
There’s also a fully managed solution buried in one of the
branches of the repository. It is incomplete, mainly because I
wasn’t able to determine which fonts are hidden by settings, and
how to combine families with non standard styles such as
Light. It’s still interesting in its own right, showing how to
use EnumFontFamiliesEx
and other interop calls, but for now it
is on hold as a work in progress.
Have you experienced this crash?
I haven’t actually managed to find a font that causes this
type of crash, although I have quite a few automated error
reports from users who experience it. If you know of such a
font that is (legally!) available for download, please let me
know so that I can test this myself. I assume my version fixes
the problem but at this point I don’t actually know for sure.
Getting the source
The source is available from GitHub.
NuGet Package
A NuGet package is available.
Install-Package Cyotek.Windows.Forms.FontDialog
License
The FontDialog
component is licensed under the MIT License.
See LICENSE.txt
for the full text.
* You might be able to catch it in
Application.ThreadException
or
AppDomain.CurrentDomain.UnhandledException
(or even by just
wrapping the call to ShowDialog
in a try
… catch
block),
but as I haven’t been able to reproduce this crash I have no way
of knowing for sure. Plus I have no idea if it will leave the
Win32 dialog open or destabilize it in some way
Update History
- 2015-08-15 — First published
- 2020-11-21 — Updated formatting
Downloads
Filename | Description | Version | Release Date | |
---|---|---|---|---|
Cyotek.Windows.Forms.FontDialog.zip
|
Working around System.ArgumentException: Only TrueType fonts are supported. This is not a TrueType font project. |
1.0.0 |
24/08/2015 | Download |
About The Author
The founder of Cyotek, Richard enjoys creating new blog content for the site. Much more though, he likes to develop programs, and can often found writing reams of code. A long term gamer, he has aspirations in one day creating an epic video game. Until that time, he is mostly content with adding new bugs to WebCopy and the other Cyotek products.
Leave a Comment
While we appreciate comments from our users, please follow our posting guidelines. Have you tried the Cyotek Forums for support from Cyotek and the community?
Problem
The “Only TrueType fonts are supported and this is not a TrueType font” error occurs when selecting an IDAutomation font using the control properties window in the Visual Studio .NET 2002 IDE. Below are two suggested solutions for this issue.
Solution(s):
Solution 1:
After selecting the font in the VS.NET IDE’s properties window, the error message “Only TrueType fonts are supported, and this is not a TrueType font” will be reported. Click OK, and then close VS.NET. Re-open VS.NET, followed by the project; select the font in the properties window and the error will no longer be generated.
Solution 2:
In the Visual Studio.NET application, reference and apply the fonts through the code window. The following example assigns the evaluation version of IDAutomation’s Code 39 Font with human-readable text displayed on a label in a form during the Form_Load event.
VB.NET:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Font = New Font("IDAutomationSHC39S", 12, FontStyle.Regular) End Sub
C#:
private void Form1_Load(object sender, System.EventArgs e) { label1.Font = new Font("IDAutomationSHC39S", 12, FontStyle.Regular); }
POCO, ACE, Loki и другие продвинутые C++ библиотеки
NullReferenced 13.05.2025
В C++ разработки существует такое обилие библиотек, что порой кажется, будто ты заблудился в дремучем лесу. И среди этого многообразия POCO (Portable Components) – как маяк для тех, кто ищет. . .
Паттерны проектирования GoF на C#
UnmanagedCoder 13.05.2025
Вы наверняка сталкивались с ситуациями, когда код разрастается до неприличных размеров, а его поддержка становится настоящим испытанием. Именно в такие моменты на помощь приходят паттерны Gang of. . .
Создаем CLI приложение на Python с Prompt Toolkit
py-thonny 13.05.2025
Современные командные интерфейсы давно перестали быть черно-белыми текстовыми программами, которые многие помнят по старым операционным системам. CLI сегодня – это мощные, интуитивные и даже. . .
Конвейеры ETL с Apache Airflow и Python
AI_Generated 13.05.2025
ETL-конвейеры – это набор процессов, отвечающих за извлечение данных из различных источников (Extract), их преобразование в нужный формат (Transform) и загрузку в целевое хранилище (Load). . . .
Выполнение асинхронных задач в Python с asyncio
py-thonny 12.05.2025
Современный мир программирования похож на оживлённый мегаполис – тысячи процессов одновременно требуют внимания, ресурсов и времени. В этих джунглях операций возникают ситуации, когда программа. . .
Работа с gRPC сервисами на C#
UnmanagedCoder 12.05.2025
gRPC (Google Remote Procedure Call) — открытый высокопроизводительный RPC-фреймворк, изначально разработанный компанией Google. Он отличается от традиционых REST-сервисов как минимум тем, что. . .
CQRS (Command Query Responsibility Segregation) на Java
Javaican 12.05.2025
CQRS — Command Query Responsibility Segregation, или разделение ответственности команд и запросов. Суть этого архитектурного паттерна проста: операции чтения данных (запросы) отделяются от операций. . .
Шаблоны и приёмы реализации DDD на C#
stackOverflow 12.05.2025
Когда я впервые погрузился в мир Domain-Driven Design, мне показалось, что это очередная модная методология, которая скоро канет в лету. Однако годы практики убедили меня в обратном. DDD — не просто. . .
Исследование рантаймов контейнеров Docker, containerd и rkt
Mr. Docker 11.05.2025
Когда мы говорим о контейнерных рантаймах, мы обсуждаем программные компоненты, отвечающие за исполнение контейнеризованных приложений. Это тот слой, который берет образ контейнера и превращает его в. . .
Micronaut и GraalVM — будущее микросервисов на Java?
Javaican 11.05.2025
Облачные вычисления безжалостно обнажили ахиллесову пяту Java — прожорливость к ресурсам и медлительный старт приложений. Традиционные фреймворки, годами радовавшие корпоративных разработчиков своей. . .
- Home
- Barcode Fonts
- Font Encoders
- Resolved Questions
Resolved Questions
TheForumSurgeon |
Vb.net
I am trying to create barcodes within my VB.NET application. I have followed all your instructions and tutorial video. The following problems occur: When I execute the code, only the code, it does not display the barcode ( I have used Code 39 in this instance). Then, if I try to manually (in the VB.NET project) change the font of the label/text box to the font ‘IDAutomationSC39S’ (demo font) for example, it says «Only true type fonts are supported. This is not a True Type font» — even though I successfully installed the true type fonts. Can you please help?
Operating System:
Application: 05-18-15 9.8 year(s) ago Report Abuse |
Ben |
Best Answer Solution 1: After selecting the font in the properties window of the VS.NET IDE, the error message «Only TrueType fonts are supported and this is not a TrueType font» will be reported. Click OK, and then close VS.NET. Re-open VS.NET, followed by the project; select the font in the properties window and the error will no longer be generated. In the Visual Studio.NET application, reference and apply the fonts through the code window of the application. The following example assigns the evaluation version of IDAutomation’s Code 39 Font with the human-readable text displayed on a label in a form during the Form_Load event. For other barcode types such as Code 128, Interleaved 2 of 5, and Intelligent Mail, use the .NET Assembly Font Encoder with the barcode font. VB.NET: Private Sub Form1_Load(ByVal sender As System.Object, Label1.Font = New Font(«IDAutomationSHC39S», 12, FontStyle.Regular) End Sub C#: private void Form1_Load(object sender, System.EventArgs { label1.Font = new Font(«IDAutomationSHC39S», 12, FontStyle.Regular); } Posted 9.8 year(s) ago |
Find Interesting
Email to Others
Bookmark
Subscribe to Answer Alert
Email this question link to friends
Error:
Only TrueType fonts are supported. This is not a TrueType font.
ArgumentException was unhandled by user code
Solution:
Add these lines before FontDialog ShowDialog
fontDialog.AllowSimulations = false;
fontDialog.AllowScriptChange = false;