PDA

Click to See Complete Forum and Search --> : FONT API calls


StillAwake
Oct 20th, 2000, 12:17 AM
I'm using this in my app.
for those that want to try it, just paste in into a blank form with a command buttom.
you will have to name your form CfontForm1 or change the
code to Form1

Dim hFont As Long
Dim hOldFont As Long
Dim retval As Long

Const FW_DONTCARE = 0
Const FW_THIN = 100
Const FW_EXTRALIGHT = 200
Const FW_ULTRALIGHT = 200
Const FW_LIGHT = 300
Const FW_NORMAL = 400
Const FW_REGULAR = 400
Const FW_MEDIUM = 500
Const FW_SEMIBOLD = 600
Const FW_DEMIBOLD = 600
Const FW_BOLD = 700
Const FW_EXTRABOLD = 800
Const FW_ULTRABOLD = 800
Const FW_HEAVY = 900
Const FW_BLACK = 900
Const ANSI_CHARSET = 0
Const ARABIC_CHARSET = 178
Const BALTIC_CHARSET = 186
Const CHINESEBIG5_CHARSET = 136
Const DEFAULT_CHARSET = 1
Const EASTEUROPE_CHARSET = 238
Const GB2312_CHARSET = 134
Const GREEK_CHARSET = 161
Const HANGEUL_CHARSET = 129
Const HEBREW_CHARSET = 177
Const JOHAB_CHARSET = 130
Const MAC_CHARSET = 77
Const OEM_CHARSET = 255
Const RUSSIAN_CHARSET = 204
Const SHIFTJIS_CHARSET = 128
Const SYMBOL_CHARSET = 2
Const THAI_CHARSET = 222
Const TURKISH_CHARSET = 162
Const OUT_DEFAULT_PRECIS = 0
Const OUT_DEVICE_PRECIS = 5
Const OUT_OUTLINE_PRECIS = 8
Const OUT_RASTER_PRECIS = 6
Const OUT_STRING_PRECIS = 1
Const OUT_STROKE_PRECIS = 3
Const OUT_TT_ONLY_PRECIS = 7
Const OUT_TT_PRECIS = 4
Const CLIP_DEFAULT_PRECIS = 0
Const CLIP_EMBEDDED = 128
Const CLIP_LH_ANGLES = 16
Const CLIP_STROKE_PRECIS = 2
Const ANTIALIASED_QUALITY = 4
Const DEFAULT_QUALITY = 0
Const DRAFT_QUALITY = 1
Const NONANTIALIASED_QUALITY = 3
Const PROOF_QUALITY = 2
Const DEFAULT_PITCH = 0
Const FIXED_PITCH = 1
Const VARIABLE_PITCH = 2
Const FF_DECORATIVE = 80
Const FF_DONTCARE = 0
Const FF_ROMAN = 16
Const FF_SCRIPT = 64
Const FF_SWISS = 32

Private Declare Function CreateFont Lib "gdi32.dll" Alias "CreateFontA" (ByVal nHeight As Long, ByVal nWidth As Long, ByVal nEscapement As Long, ByVal nOrientation As Long, ByVal fnWeight As Long, ByVal fdwItalic As Long, ByVal fdwUnderline As Long, ByVal fdwStrikeOut As Long, ByVal fdwCharSet As Long, ByVal fdwOutputPrecision As Long, ByVal fdwClipPrecision As Long, ByVal fdwQuality As Long, ByVal fdwPitchAndFamily As Long, ByVal lpszFace As String) As Long

Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As Long

Private Declare Function TextOut Lib "gdi32.dll" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long


Private Sub Command1_Click()
CfontForm1.AutoRedraw = False
hFont = CreateFont(20, 0, 0, 0, FW_DONTCARE, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH Or FF_DONTCARE, "Arial")

hOldFont = SelectObject(CfontForm1.hdc, hFont)
retval = TextOut(CfontForm1.hdc, 10, 10, "abcdefghijklmnopqrstuvwxyz", 26)
retval = TextOut(CfontForm1.hdc, 10, 50, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 26)
retval = TextOut(CfontForm1.hdc, 10, 85, "`~!@#$%^&*()-_=+\|[]{};:,.<>/?'", 31)

End Sub

This works fine for all installed fonts, but it won't work
if I try to use "d:\fontlib\Candy Bits BT" or
"d:\fontlib\candybt" or
"d:\fontlib\candybt.ttf"
How can I print with a font not in c:\windows\font ?

Also, if I try to get the version of any font with
GetFileVersionInfoSize Lib "version.dll" I get an error because it's not an executable.

So I'm trying to find out where the version information is.
I studied a few documents about the header information.
Tag Name
cvt Control Value Table
fpgm Font program
glyf Glyph data
loca Index to location
maxp Maximum profile
prep CVT Program
cmap Character to glyph mapping
head Font header
hhea Horizontal header
hmtx Horizontal metrics
name Naming table
OS/2 OS/2 and Windows specific metrics
post PostScript information

None of these seem to point to the version info as far as I can tell.
Any one know how to pull in the header info, and find the right table pointer ?
Thanks to anyone that can help.

VB5pro sp3