473,394 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

fonts in programs

How can I choose some fonts in programs so that they are always avalable for
the program at other computers, can I put them in some resources?
Thanks for any response
Sep 3 '08 #1
8 1348
Maybe more specific
I can choose in the properties for many controls font.
When the program run on a other computer where has not this font what
happens?
Can I put the font into the code in some of another way so that the font
is always avalable for the program?
Thanks for any response.
Sep 3 '08 #2
On Sep 3, 9:29 pm, andrews <andr...@pandora.bewrote:
Maybe more specific
I can choose in the properties for many controls font.
When the program run on a other computer where has not this font what
happens?
Can I put the font into the code in some of another way so that the font
is always avalable for the program?
Thanks for any response.
Usually, if the specified font cannot be found on target machine, your
application is supposed to run with a proper font that your system
supports, however you can check the intended font file's existence
using System.IO.File.Exists preferably on form's load event:

'-----Begin-------------
' It's unlikely that a Windows client doesn't have Arial
' But check it out for the scenario
If System.IO.File.Exists _
("c:\Windows\Fonts\arial.ttf")=True Then
MsgBox("Arial is found")

Else
'Implement new font instance
'Eg: Verdana, sized 20
Dim myfont As New Font("Verdana", 20)

'Associate new font with control's font
'Eg: Button's new font is verdana
Button1.Font = myfont
End If
'-------End----------

Hope this helps,

Onur Güzel
Sep 3 '08 #3
checking a hard path is never a good idee "c:\Windows\Fonts\arial.ttf"

better find Windows directory first and then check for the file
some people did not install in c:\windows

"kimiraikkonen" <ki*************@gmail.comwrote in message
news:98**********************************@b38g2000 prf.googlegroups.com...
On Sep 3, 9:29 pm, andrews <andr...@pandora.bewrote:
>Maybe more specific
I can choose in the properties for many controls font.
When the program run on a other computer where has not this font what
happens?
Can I put the font into the code in some of another way so that the font
is always avalable for the program?
Thanks for any response.

Usually, if the specified font cannot be found on target machine, your
application is supposed to run with a proper font that your system
supports, however you can check the intended font file's existence
using System.IO.File.Exists preferably on form's load event:

'-----Begin-------------
' It's unlikely that a Windows client doesn't have Arial
' But check it out for the scenario
If System.IO.File.Exists _
("c:\Windows\Fonts\arial.ttf")=True Then
MsgBox("Arial is found")

Else
'Implement new font instance
'Eg: Verdana, sized 20
Dim myfont As New Font("Verdana", 20)

'Associate new font with control's font
'Eg: Button's new font is verdana
Button1.Font = myfont
End If
'-------End----------

Hope this helps,

Onur Güzel
Sep 3 '08 #4
Checking a file is not an effective way to find out what fonts are installed
in a aystem. Use the InstalledFontCollection class to enumerate the
available fonts.

"kimiraikkonen" <ki*************@gmail.comwrote in message
news:98**********************************@b38g2000 prf.googlegroups.com...
On Sep 3, 9:29 pm, andrews <andr...@pandora.bewrote:
Maybe more specific
I can choose in the properties for many controls font.
When the program run on a other computer where has not this font what
happens?
Can I put the font into the code in some of another way so that the font
is always avalable for the program?
Thanks for any response.
Usually, if the specified font cannot be found on target machine, your
application is supposed to run with a proper font that your system
supports, however you can check the intended font file's existence
using System.IO.File.Exists preferably on form's load event:

'-----Begin-------------
' It's unlikely that a Windows client doesn't have Arial
' But check it out for the scenario
If System.IO.File.Exists _
("c:\Windows\Fonts\arial.ttf")=True Then
MsgBox("Arial is found")

Else
'Implement new font instance
'Eg: Verdana, sized 20
Dim myfont As New Font("Verdana", 20)

'Associate new font with control's font
'Eg: Button's new font is verdana
Button1.Font = myfont
End If
'-------End----------

Hope this helps,

Onur Güzel

Sep 3 '08 #5
On Sep 4, 1:04 am, "Gillard" <gillard_georges@@@@@@@@@hotmail.com>
wrote:
checking a hard path is never a good idee "c:\Windows\Fonts\arial.ttf"

better find Windows directory first and then check for the file
some people did not install in c:\windows

"kimiraikkonen" <kimiraikkone...@gmail.comwrote in message

news:98**********************************@b38g2000 prf.googlegroups.com...
On Sep 3, 9:29 pm, andrews <andr...@pandora.bewrote:
Maybe more specific
I can choose in the properties for many controls font.
When the program run on a other computer where has not this font what
happens?
Can I put the font into the code in some of another way so that the font
is always avalable for the program?
Thanks for any response.
Usually, if the specified font cannot be found on target machine, your
application is supposed to run with a proper font that your system
supports, however you can check the intended font file's existence
using System.IO.File.Exists preferably on form's load event:
'-----Begin-------------
' It's unlikely that a Windows client doesn't have Arial
' But check it out for the scenario
If System.IO.File.Exists _
("c:\Windows\Fonts\arial.ttf")=True Then
MsgBox("Arial is found")
Else
'Implement new font instance
'Eg: Verdana, sized 20
Dim myfont As New Font("Verdana", 20)
'Associate new font with control's font
'Eg: Button's new font is verdana
Button1.Font = myfont
End If
'-------End----------
Hope this helps,
Onur Güzel
Sure, but also your idea is based on file checking which is quite
effective in my idea, though user can install Windows to another
directory although c:\Windows is quite common, however you can use
that for determining Windows directory:

Dim WinDir As String = _
Environment.GetEnvironmentVariable("windir")
Dim fontsFolder As String = WinDir & "\Fonts"

....which solves default Windows Directory also combining Font folder.

Thanks,

Onur Güzel

Sep 4 '08 #6
andreas wrote:
How can I choose some fonts in programs so that they are always
avalable for the program at other computers, can I put them in some
resources?
Fonts are usually copyrighted, so: no.

Other posters have mentioned looking in the fonts folder. You should be able
to get the location of the fonts folder through this information from
ShlObj.h from the Windows SDK:

<snip>
//-------------------------------------------------------------------------
//
// SHGetSpecialFolderLocation
//
// Caller should use SHGetMalloc to obtain an allocator that can free the
pidl
//
//
//-------------------------------------------------------------------------
//
// registry entries for special paths are kept in :
#define REGSTR_PATH_SPECIAL_FOLDERS REGSTR_PATH_EXPLORER TEXT("\\Shell
Folders")
#define CSIDL_DESKTOP 0x0000 // <desktop>
#define CSIDL_INTERNET 0x0001 // Internet Explorer
(icon on desktop)
#define CSIDL_PROGRAMS 0x0002 // Start Menu\Programs
#define CSIDL_CONTROLS 0x0003 // My Computer\Control
Panel
#define CSIDL_PRINTERS 0x0004 // My
Computer\Printers
#define CSIDL_PERSONAL 0x0005 // My Documents
#define CSIDL_FAVORITES 0x0006 // <user
name>\Favorites
#define CSIDL_STARTUP 0x0007 // Start
Menu\Programs\Startup
#define CSIDL_RECENT 0x0008 // <user name>\Recent
#define CSIDL_SENDTO 0x0009 // <user name>\SendTo
#define CSIDL_BITBUCKET 0x000a // <desktop>\Recycle
Bin
#define CSIDL_STARTMENU 0x000b // <user name>\Start
Menu
#define CSIDL_MYDOCUMENTS 0x000c // logical "My
Documents" desktop icon
#define CSIDL_MYMUSIC 0x000d // "My Music" folder
#define CSIDL_MYVIDEO 0x000e // "My Videos" folder
#define CSIDL_DESKTOPDIRECTORY 0x0010 // <user name>\Desktop
#define CSIDL_DRIVES 0x0011 // My Computer
#define CSIDL_NETWORK 0x0012 // Network
Neighborhood (My Network Places)
#define CSIDL_NETHOOD 0x0013 // <user name>\nethood
#define CSIDL_FONTS 0x0014 // windows\fonts
#define CSIDL_TEMPLATES 0x0015
#define CSIDL_COMMON_STARTMENU 0x0016 // All Users\Start
Menu
#define CSIDL_COMMON_PROGRAMS 0X0017 // All Users\Start
Menu\Programs
#define CSIDL_COMMON_STARTUP 0x0018 // All Users\Startup
#define CSIDL_COMMON_DESKTOPDIRECTORY 0x0019 // All Users\Desktop
#define CSIDL_APPDATA 0x001a // <user
name>\Application Data
#define CSIDL_PRINTHOOD 0x001b // <user
name>\PrintHood
<snip>

(There are lots more defined.)

Andrew
Sep 4 '08 #7
Thanks for the information but I will repeat one of my questions
Can I put the font into the code in some of another (resources?)way so
that the font is always avalable for the program?
Sep 4 '08 #8
Your question was not answered directly because the answer is returned as an
immediate response from a Google search. Your responders will assume you
have already done this, and will only comment on things that are not covered
in those results.

See, for instance:
http://www.tek-tips.com/faqs.cfm?fid=4747
Embedding fonts into your application.

http://www.bobpowell.net/embedfonts.htm
How to embed a True Type font

There are many others.

"andrews" <an*****@pandora.bewrote in message
news:wH*********************@newsfe30.ams2...
Thanks for the information but I will repeat one of my questions
Can I put the font into the code in some of another (resources?)way so
that the font is always avalable for the program?
Sep 4 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jean Pion | last post by:
Dear readers, I use the following to create a collection of fonts to choose from: For I = 0 To Screen.FontCount - 1 'Zero based! CurFont.AddItem Screen.Fonts(I) Next i Then, later I would...
8
by: jcnews | last post by:
I am using Windows XP and am learning how to program in Java. Is there any way to get my fonts to be anti-aliased in both editors and in my programs? The non anti-aliased fonts don't look very...
7
by: Scott | last post by:
Sorry if this is a dumb question - bit of a newbie to Access: Just getting to grips with OfficeXP Developer, the intention being to be able to deploy a simple Access application to various...
4
by: L | last post by:
Hi there, Does C# support OpenType fonts? My c# application is not recognizing OpenType fonts. Thanks, Lalasa.
10
by: Kamilche | last post by:
I have a question for all you Pythoneers out there. I'm making a game with Python, and have a need for fonts. I am currently using a free TrueType font, but am considering switching to a bitmap...
1
by: Atul | last post by:
Hi, I have installed a truetype font (.ttf) on a linux machne (SUSE linux 10, KDE) by copying it to my .fonts folder. I can use the font in all applications like open-office and firefox browser....
3
by: John | last post by:
Hi I have a report for which I have set the Epson LQ-1050 (dot matrix) as the default printer. The problem is that I still can't see the printer's native (hardware) fonts in the font selection...
2
tpgames
by: tpgames | last post by:
Two days ago, MS office Word would type JP fonts, I thought. I didn't think I was using Works. Now, it won't type in JP. Jasc Paint shop pro 8, should type JP fonts because I am using XP, according...
10
by: =?Utf-8?B?UmljaA==?= | last post by:
A lot of users at my workplace use different screen resolutions, and I build apps to use 1680 x 1050 pixels res by default. But some users are using 800 x 600, and the apps are too large for their...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.