|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Getting Info from a .TTF FileHi,
I have a VB6 program that needs to find the font name from the file that contains the font. For example, I would like my program to be able to access the font file TIMES.TTF and then from that file determine the name of the font eg, Times New Roman. Notice that the font may or may not actually be installed on the computer running the program. It may just be a file on, say, a CD. Nevertheless, coding to provide the above only for fonts actually installed on the computer would be a good start. Thank you. Doug vV The following is a C example, but if you can wade through it, it should let
you extract the name from a TTF file: http://www.codeguru.com/cpp/g-m/gdi/fonthandlinganddetection/article.php/c3659/#more. It's not exactly an easy undertaking, but it's certainly doable. For a more broad-based overview, have a look at this: http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=IWS-Chapter08#3054f18b. You'll want to focus mainly on the "name" section for your purposes. The one thing you need to be aware of is that not everything that looks like a .TTF file IS a .TTF file, at least not in the strictest sense. Take your TIMES.TTF file as an example...on Windows XP, it's actually an OpenType font, not a TrueType font. If the font ends in .TTF, though, it's supposed to follow a compatible standard, whether it's actually an OpenType or TrueType font. I've never actually tried to parse OpenType files, though, so I only know that they SHOULD behave the same, not whether or not they DO. Rob Show quoteHide quote "Doug van Vianen" <cour***@home.com> wrote in message news:u51m8xuWHHA.4384@TK2MSFTNGP02.phx.gbl... > Hi, > > I have a VB6 program that needs to find the font name from the file that > contains the font. For example, I would like my program to be able to > access the font file TIMES.TTF and then from that file determine the name > of the font eg, Times New Roman. > > Notice that the font may or may not actually be installed on the computer > running the program. It may just be a file on, say, a CD. Nevertheless, > coding to provide the above only for fonts actually installed on the > computer would be a good start. > > Thank you. > > Doug vV > Robert Morley <rmor***@magma.ca.N0.Freak1n.sparn> wrote:
> The one thing you need to be aware of is that not everything that looks like Yeah, it appears so. I just ran my FontPreview sample > a .TTF file IS a .TTF file, at least not in the strictest sense. Take your > TIMES.TTF file as an example...on Windows XP, it's actually an OpenType > font, not a TrueType font. If the font ends in .TTF, though, it's supposed > to follow a compatible standard, whether it's actually an OpenType or > TrueType font. I've never actually tried to parse OpenType files, though, > so I only know that they SHOULD behave the same, not whether or not they DO. (http://vb.mvps.org/samples/FontPre) against that file, and it seemed to have worked just perfectly. So it's definitely following the same structured layout as "regular" TTF files.
Show quote
Hide quote
"Doug van Vianen" <cour***@home.com> wrote in message Here's a fairly cool sample that shows all kinds of info about installed news:u51m8xuWHHA.4384@TK2MSFTNGP02.phx.gbl... > Hi, > > I have a VB6 program that needs to find the font name from the file that > contains the font. For example, I would like my program to be able to > access the font file TIMES.TTF and then from that file determine the name > of the font eg, Times New Roman. > > Notice that the font may or may not actually be installed on the computer > running the program. It may just be a file on, say, a CD. Nevertheless, > coding to provide the above only for fonts actually installed on the > computer would be a good start. > > Thank you. > > Doug vV fonts. Font Properties with AddressOf http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=38897&lngWId=1 Here's one that seems to do what you want... Fontname - Get the name of a font http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=4309&lngWId=1 It has a couple of minor "issues" (like naming a label "text1", but that's another story)... since the path to the fonts folder is hard coded, it would've been a good idea for the guy to use the same hard coded path everywhere <g>... but, "works fine here" with this slight mod. '====== Private Sub list1_Click() Dim TTFontFile As String TTFontFile$ = "C:\Windows\Fonts\" & List1 text1 = GetFontName(TTFontFile$) If Len(text1.Caption) > 0 Then Label2.Font = GetFontName(TTFontFile$) End If End Sub '====== -- Ken Halter - MS-MVP-VB - Please keep all discussions in the groups.. In Loving Memory - http://www.vbsight.com/Remembrance.htm The samples on Karl Peterson's site may be helpful:
http://www.vb.mvps.org/samples/project.asp?id=FontPre http://www.vb.mvps.org/samples/ Dan Show quoteHide quote "Doug van Vianen" <cour***@home.com> wrote in message news:u51m8xuWHHA.4384@TK2MSFTNGP02.phx.gbl... > Hi, > > I have a VB6 program that needs to find the font name from the file that > contains the font. For example, I would like my program to be able to > access the font file TIMES.TTF and then from that file determine the name > of the font eg, Times New Roman. > > Notice that the font may or may not actually be installed on the computer > running the program. It may just be a file on, say, a CD. Nevertheless, > coding to provide the above only for fonts actually installed on the > computer would be a good start. > > Thank you. > > Doug vV > Hi,
Thank you, everyone, for your responses to my original question about getting the font name and other information from an uninstalled font file. They are very helpful. However, I also need to work the other way. That is, I need to be able to determine the name of the font file given the font name. That is, given 'Times New Roman' determine that the file name is 'TIMES.TTF'. It can be assumed that the font is actually installed on the computer. Does anyone know how to do this? Thank you. Doug vV Doug van Vianen <cour***@shaw.ca> wrote:
> However, I also need to work the other way. That is, I need to be able to If you're restricted to installed fonts, take a look here:> determine the name of the font file given the font name. That is, given > 'Times New Roman' determine that the file name is 'TIMES.TTF'. It can be > assumed that the font is actually installed on the computer. HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts Of course, if we're talking uninstalled TTFs, there is no *one* correct answer guaranteed.
Function that returns an Array
Reason for 'Set' keyword SendKeys command fails on Vista Error in reading large csv file Sending email Should I or shouldn't I include excel.exe in my app distribution package? Run-time Error 430, WITH non-broken binary compatibility? TaskBar won't show when hidden. My DataReport Problem Problem with ASP instancing VB6 DLL under IIS6 - Windows 2003 (Microsoft VBScript runtime error '800 |
|||||||||||||||||||||||