|
-
Sep 15th, 2022, 12:41 PM
#1
Thread Starter
Hyperactive Member
Copying/Installing font used in WinForm project
Alright, here's the deal:
Consider you want to reduce app size therefore you are using a font which contains lots of pretty useful icons plus you are able to change all components color and accents to do cool graphical flexibilities, Like Microsoft "Segoe Fluent Icons". But how about a user with Windows 7 or earlier version of MS Windows operating system (Windows 10 have a similar alternative called "Segoe MDL2 Assets" but still not quite this one.) I looked up all over. What is the correct way to achieve such including-used-fonts-built-in thing in our vb.net winform projects?
What I've tried:
Code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
System.IO.File.WriteAllBytes("c:\windows\fonts\SegoeIcons.ttf", My.Resources.SegoeIcons)
Application.Restart()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Which results "Access to path "C:\Windows\Fonts\SegoeIcons.ttf" is denied" exception.
-
Sep 15th, 2022, 08:08 PM
#2
Re: Copying/Installing font used in WinForm project
I've never done it myself but I think that you need to use the PrivateFontCollection class. This allows your app to use fonts that it supplies rather than having them installed in Windows.
-
Sep 16th, 2022, 07:22 AM
#3
Re: Copying/Installing font used in WinForm project
We add a registry setting via start.
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "Iskoola Pota Bold" /t REG_SZ /d "%WINDIR%\Fonts\iskpotab.ttf" /f
Please remember next time...elections matter!
-
Sep 16th, 2022, 10:20 AM
#4
Thread Starter
Hyperactive Member
Re: Copying/Installing font used in WinForm project
(Reply to jmcilhinney)
It wouldn't create something graphical right? Cause I don't want to engage with these kind of things. I also browsed https://docs.microsoft.com/en-us/dot...orkdesktop-4.8 but nothing much i've learned from it. Can you describe a little more with an actual example?
-
Sep 16th, 2022, 11:09 AM
#5
Re: Copying/Installing font used in WinForm project
 Originally Posted by pourkascheff
It wouldn't create something graphical right? Cause I don't want to engage with these kind of things.
I have no idea what that means.
 Originally Posted by pourkascheff
The page you linked to provides an actual example. What don't you understand? You load fonts from files into the collection, you create a Font, you use it. What's the actual problem?
-
Sep 30th, 2022, 12:22 PM
#6
Thread Starter
Hyperactive Member
Re: Copying/Installing font used in WinForm project
 Originally Posted by jmcilhinney
I have no idea what that means.
Forgive me for my lack of English. What I tried to say is does it turn text to graphical items/shapes or not? Because if yes, I rather not to do such things and stick to code only.
 Originally Posted by jmcilhinney
The page you linked to provides an actual example. What don't you understand? You load fonts from files into the collection, you create a Font, you use it. What's the actual problem?
Don't get mad at me sir but I deeply have problem to understand Microsoft articles with a plenty amount of information in a language I don't speak.
I tried codes in it.
The remaining question is "How to use a font in a WinForm and run it in another console while it doesn't have the font?"
-
Oct 29th, 2022, 02:19 PM
#7
Thread Starter
Hyperactive Member
Re: Copying/Installing font used in WinForm project
How about add used font in fonts folder in deploy section to being installed for user?
-
Oct 30th, 2022, 12:18 AM
#8
Re: Copying/Installing font used in WinForm project
 Originally Posted by jmcilhinney
I've never done it myself but I think that you need to use the PrivateFontCollection class. This allows your app to use fonts that it supplies rather than having them installed in Windows.
 Originally Posted by jmcilhinney
I have no idea what that means.
The page you linked to provides an actual example. What don't you understand? You load fonts from files into the collection, you create a Font, you use it. What's the actual problem?
 Originally Posted by pourkascheff
The remaining question is "How to use a font in a WinForm and run it in another console while it doesn't have the font?"
You use the PrivateFontCollection that jmcilhinney suggested, and the page you posted a link to, that shows how to use it
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 30th, 2022, 12:20 AM
#9
Re: Copying/Installing font used in WinForm project
Originally Posted by pourkascheff
The remaining question is "How to use a font in a WinForm and run it in another console while it doesn't have the font?"
What do you mean by 'another console'?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 30th, 2022, 09:32 AM
#10
Thread Starter
Hyperactive Member
Re: Copying/Installing font used in WinForm project
 Originally Posted by .paul.
What do you mean by 'another console'?
I mean 'Use a sort of old LCD font on your WinForms application, Run it on another computer which does not have that font.'
That Learn.Microsoft article turns text strings to graphics. Am I right? I don't want to do so. I have lots of labels and textboxes which should represent the theme.
What I want to perform is more like what this nerd guy did in deploying app. Well, Instant plug-and-play apps are much better... Do you know an alternative?
-
Oct 30th, 2022, 10:26 AM
#11
Re: Copying/Installing font used in WinForm project
This thread was from just a couple days ago and may help:
https://www.vbforums.com/showthread....an-application
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|