C
C#4w ago
skydrake

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 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?
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
No description
1 Reply
skydrake
skydrakeOP4w ago
I just moved the Resources folder onto Properties and it worked
Want results from more Discord servers?
Add your server