Question Fonts...

ALX

Well-known member
Joined
Nov 16, 2005
Messages
253
Location
Columbia, SC
Programming Experience
10+
How can I save font information (already installed) to a file so that I can reconstruct the same font from that file at a later time..?
 
Last edited:
I'm guessing you mean how you can distribute a font you have installed in development machine to a client computer? You can for example distribute it as file or resource, and load it in project from file or memory with PrivateFontCollection class. You can also distribute and install it to client using a Setup Project by adding the font to Fonts folder in File System Editor. The installed font file can be copied from Windows Explorer (ex C:\Windows\Fonts or Control Panel>Fonts) in your computer.
 
I worded that question poorly and in the process got an answer to my follow up question. What I should have said was... In this app the user sets up font and color for a textbox via a font dialog box. I want to store the user's choices in a file so the user doesn't need to reset font preferences every time the app is restarted. I've tried to do it by writing strings and/or values that describe the font to a file, but get hung up on setting up the font from the file with FontStyle which won't take an enum (1, 2 ,3 or 4) and won't ctype(from a string). I vaguely remember reading something years ago about making objects <serializable> so that they can be written to a file, but can't seem to find any practical information on that. Looking it up at MSDN opens a can of worms and I leave there more confused than before.
 
Last edited:
You can store fonts in My.Settings. For each font you want to store, add an item on the Settings page of the project properties. You can then access each Font object from the appropriate properties of My.Settings. You can even bind the Font property of a control in the Properties window using the (ApplicationSettings) node, so they can be loaded and saved with no code at all.
 

Latest posts

Back
Top