© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•15mo ago•
1 reply
::¿¿animal*crossingAdd[a]heading

Trying to embed custom font in WinForms project

I'm currently trying to embed the 'Rubik' font onto a WinForms project following the steps on the correct answer in this SO post: https://stackoverflow.com/questions/556147/how-do-i-embed-my-own-fonts-in-a-winforms-app

I include the font non the Resource Explorer of the project and then mark the generated .ttf on resource as an Embedded Resource but then the project doesn't build due to the error 'Could not find a part of the path
D:\Documents\Workspace - C#\FactuCrossing\FactuCrossing\Properties\Resources\Rubik-VariableFont_wght.ttf
D:\Documents\Workspace - C#\FactuCrossing\FactuCrossing\Properties\Resources\Rubik-VariableFont_wght.ttf
and
Invalid Resx file.
System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\Documents\Workspace - C#\FactuCrossing\FactuCrossing\Properties\Resources\Rubik-VariableFont_wght.ttf'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)
   at Microsoft.Build.Tasks.ResourceHandling.MSBuildResXReader.AddLinkedResource(String resxFilename, Boolean pathsRelativeToBasePath, List`1 resources, String name, String value)
   at Microsoft.Build.Tasks.ResourceHandling.MSBuildResXReader.ReadResources(Stream s, String filename, Boolean pathsRelativeToBasePath, TaskLoggingHelper log, Boolean logWarningForBinaryFormatter)
Invalid Resx file.
System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\Documents\Workspace - C#\FactuCrossing\FactuCrossing\Properties\Resources\Rubik-VariableFont_wght.ttf'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.File.InternalReadAllBytes(String path, Boolean checkHost)
   at Microsoft.Build.Tasks.ResourceHandling.MSBuildResXReader.AddLinkedResource(String resxFilename, Boolean pathsRelativeToBasePath, List`1 resources, String name, String value)
   at Microsoft.Build.Tasks.ResourceHandling.MSBuildResXReader.ReadResources(Stream s, String filename, Boolean pathsRelativeToBasePath, TaskLoggingHelper log, Boolean logWarningForBinaryFormatter)
why is this?
image.png
Stack Overflow
How do I embed my own fonts in a WinForms app?
I want to embed fonts in my WinForms application so that I don't have to worry about them being installed on the machine. I've searched a bit on the MSDN site and found a few hints about using native
How do I embed my own fonts in a WinForms app?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Add custom font in c# winforms
C#CC# / help
2y ago
Replacing font table in RichTextBox (WinForms)
C#CC# / help
4y ago
✅ WinForms Project Contribution
C#CC# / help
3y ago
✅ custom font
C#CC# / help
12mo ago