Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #551
| From | "Mike Williams" <Mike@WhiskyAndCoke.com> |
|---|---|
| Newsgroups | comp.lang.basic.visual.misc |
| Subject | Re: VB6 - use a custom, non-installed font? |
| Date | 2011-12-08 21:31 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <jbra9p$ro2$1@dont-email.me> (permalink) |
| References | <01c876ed-6902-4586-92a0-c98edf461cdc@c13g2000vbh.googlegroups.com> <01ccb5c0$1bdbf510$6d01a8c0@k8s8x> <7363a3b2-fe07-49b8-8ecc-7ecdc59217b6@c13g2000vbh.googlegroups.com> <27706558-976b-4301-b176-b2d9f1166973@q11g2000vbq.googlegroups.com> |
"Brigand" <markashall@hotmail.com> wrote in message
news:27706558-976b-4301-b176-b2d9f1166973@q11g2000vbq.googlegroups.com...
> [In response to code posted by Thorsten Albers] Actually, its missing
> something.
> something. The code just assigns the name of the font to a variable and
> does
> nothing with it.
You need to specify the filename of the font in the call to
AddFontResourceEx but you need to use the actual name of the font itself
when you assign it to your Form. The filename is often the same as the font
name, but this is not always the case. You clearly already know the filename
of the .ttf file and I assume that you also know the font name contained in
that file, so you just need to make sure you use the correct names in both
cases. For example, if the filename is "CustomFont.ttf" (and if it resides
in a folder called Resources within whatever folder your compiled exe lives
in, as would appear from your initial post) and if its actual font name is
"Boulders" then you would need something like the following:
Option Explicit
Private Declare Function AddFontResourceEx Lib "gdi32.dll" _
Alias "AddFontResourceExA" (ByVal lpcstr As String, _
ByVal dword As Long, ByRef DESIGNVECTOR) As Long
Private Const FR_PRIVATE As Long = &H10
Private Sub Form_Load()
AddFontResourceEx App.Path & "\Resources\CustomFont.ttf", FR_PRIVATE, 0&
End Sub
Private Sub Command1_Click()
Me.Font.Name = "Boulders"
Me.Font.Size = 36
Me.Print "This should be in Boulders font"
End Sub
I'm fairly sure that you actually do know the name of the font contained in
your CustomFont.ttf file, but if you don't then you can easily find it by
double clicking the file so that Windows opens it. Otherwise, you can if you
wish add code to extract the actual name from the .ttf file at run time for
you. It's highly uinlikely that you will need that, but post again if you
do.
Mike
Back to comp.lang.basic.visual.misc | Previous | Next — Previous in thread | Next in thread | Find similar
VB6 - use a custom, non-installed font? Brigand <markashall@hotmail.com> - 2011-12-08 06:53 -0800
Re: VB6 - use a custom, non-installed font? "Thorsten Albers" <gudea@gmx.de> - 2011-12-08 15:43 +0000
Re: VB6 - use a custom, non-installed font? Brigand <markashall@hotmail.com> - 2011-12-08 10:28 -0800
Re: VB6 - use a custom, non-installed font? Brigand <markashall@hotmail.com> - 2011-12-08 11:41 -0800
Re: VB6 - use a custom, non-installed font? "Mike Williams" <Mike@WhiskyAndCoke.com> - 2011-12-08 21:31 +0000
Re: VB6 - use a custom, non-installed font? Brigand <markashall@hotmail.com> - 2011-12-09 06:42 -0800
Re: VB6 - use a custom, non-installed font? Thorsten Albers <gudea@gmx.de> - 2011-12-09 23:08 +0100
Re: VB6 - use a custom, non-installed font? Jim Mack <no-uce-ube@mdxi.com> - 2011-12-09 20:14 -0500
Re: VB6 - use a custom, non-installed font? "Thorsten Albers" <gudea@gmx.de> - 2011-12-09 17:43 +0000
csiph-web