首页 >> 读书频道 >> 电脑 >> 取得各字型的信息
 
· 在IE右键菜单中添加菜单
· 雨滴式的显示图片
· 如何拦截键盘输入
· 求解数列和通用程序
· 彩色BMP档转成灰度
· 在IE右键菜单中添加菜单
· 读取文件的建立时间及存取
· 在IE右键菜单中添加菜单
· IE浏览器完全控制下
· RAS API上的其他F
· 程式自动呼叫拨号网络(R
· 判断程式是独立执行还是在
 
· 电视剧《刁蛮公主》下载和
· 美容养颜手册
· 加油金顺剧情分集介绍完整
· 红楼梦:120回全本[清
· 素质教育在美国
· 全唐诗卷四十六
· 韩剧《布拉格恋人》剧情介
· 夜航船[作者:明·张岱]
· 局外人[作者:韩·可爱淘
· 现场流行病学
· 源氏物语[日本:紫式部]
· 武林寓言故事
 
· (出租)中动商场部分及写
· (出租)中动动漫基地&#
· 喜剧学院
· 《善德女王》剧情介绍
· 魔女18号 剧情
· 丑女无敌剧情介绍
· 魔女幼熙剧情介绍
· 龙游天下剧情介绍
· 震撼世界的七日剧情介绍
· 静静的白桦林剧情介绍
· 心情日记—老公今天我想对
· 旗舰剧情介绍
欢迎来到月影社区!如果您觉得这里不错,请推荐给您的朋友们。月影社区:http://wf66.com/

取得各字型的信息


查看有无更新版本

关键字:VB 2006-9-18

 

这个例子取得系统中字型的TypeFace、FamilyName、字型种类、字型大小之信息

以前在bbs上曾见过有人问到系统的字型是Large Font或Small Font该如何判定,
其实Check一下System Font中,字型大小是12点者为Large Font, 10点为Small Font
所以在CallBack Function改成以下便可得知

Public Function FontFamily(ELGFont As ENUMLOGFONT, ByVal ntm As Long, ByVal fonttype As Long, ByVal lparam As Long) As LongDim str5 As String, ff As ByteDim hi As Long, ii As Longstr5 = StrConv(ELGFont.elfLogFont.lfFaceName, vbUnicode)str5 = Left(str5, InStr(1, str5, Chr(0)) - 1)ii = GetDeviceCaps(hdc, LOGPIXELSY)hi = MulDiv(ELGFont.elfLogFont.lfHeight, 72, ii) '字型大小更改成点数来看If str5 = "System" Then 'System字型 If hi = 12 Then Debug.Print "Large Font" Else If hi = 10 Then Debug.Print "Small Font" Else Debug.Print "User Defined" End If End If FontFamily = 0 '不再找了Else FontFamily = 1 '再找下去End IfEnd Functionfumi Write: 一般萤幕的驱动程式会预设两种字型大小:大字型为 120dpi,小字型为 96dpi,VB 有个很方便的方法使用 Screen.TwipsPerPixelX、Screen.TwipsPerPixelY(通常这两个值会相同)可以得知是大字型或是小字型,由於 1 in = 1440 twips, 所以,如果 Screen.TwipsPerPixelX 的值为 12 的话, 就是大字型, 如果其值为 15 就是小字型,如果为其他的数值则是自订字型大小' below is in .BasOption ExplicitPublic Const LF_FULLFACESIZE = 64Public Const LF_FACESIZE = 32Public Const DEVICE_FONTTYPE = &H1Public Const RASTER_FONTTYPE = &H2Public Const TRUETYPE_FONTTYPE = &H4Public Const FF_DECORATIVE = 80Public Const FF_DONTCARE = 0Public Const FF_MODERN = 48Public Const FF_ROMAN = 16Public Const FF_SCRIPT = 64Public Const FF_SWISS = 32Public Const LOGPIXELSY = 90Type NEWTEXTMETRIC tmHeight As Long tmAscent As Long tmDescent As Long tmInternalLeading As Long tmExternalLeading As Long tmAveCharWidth As Long tmMaxCharWidth As Long tmWeight As Long tmOverhang As Long tmDigitizedAspectX As Long tmDigitizedAspectY As Long tmFirstChar As Byte tmLastChar As Byte tmDefaultChar As Byte tmBreakChar As Byte tmItalic As Byte tmUnderlined As Byte tmStruckOut As Byte tmPitchAndFamily As Byte tmCharSet As Byte ntmFlags As Long ntmSizeEM As Long ntmCellHeight As Long ntmAveWidth As LongEnd TypeType LOGFONT lfHeight As Long lfWidth As Long lfEscapement As Long lfOrientation As Long lfWeight As Long lfItalic As Byte lfUnderline As Byte lfStrikeOut As Byte lfCharSet As Byte lfOutPrecision As Byte lfClipPrecision As Byte lfQuality As Byte lfPitchAndFamily As Byte lfFaceName(LF_FACESIZE) As ByteEnd TypeType TEXTMETRIC tmHeight As Long tmAscent As Long tmDescent As Long tmInternalLeading As Long tmExternalLeading As Long tmAveCharWidth As Long tmMaxCharWidth As Long tmWeight As Long tmOverhang As Long tmDigitizedAspectX As Long tmDigitizedAspectY As Long tmFirstChar As Byte tmLastChar As Byte tmDefaultChar As Byte tmBreakChar As Byte tmItalic As Byte tmUnderlined As Byte tmStruckOut As Byte tmPitchAndFamily As Byte tmCharSet As ByteEnd TypeDeclare Function EnumFontFamilies Lib "gdi32" Alias "EnumFontFamiliesA" (ByVal hdc As Long, ByVal lpszFamily As String, ByVal lpEnumFontFamProc As Long, ByVal lparam As Long) As LongType ENUMLOGFONT elfLogFont As LOGFONT elfFullName(LF_FULLFACESIZE) As Byte elfStyle(LF_FACESIZE) As ByteEnd TypeDeclare Function GetDC Lib "user32" (ByVal hwnd As Long) As LongDeclare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As LongDeclare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator As Long, ByVal nDenominator As Long) As LongDeclare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As LongDeclare Function ReleaseDC Lib "user32" Alias "ReleaseDC" (ByVal hwnd As Long, ByVal hdc As Long) As LongPrivate hdc As LongPublic Sub EnumFontInfo()Dim i As Longi = 1hdc = GetDC(0)Call EnumFontFamilies(hdc, vbNullString, AddressOf FontFamily, 0)Call ReleaseDC(0,hdc)End SubPublic Function FontFamily(ELGFont As ENUMLOGFONT, ByVal ntm As Long, ByVal fonttype As Long, ByVal lparam As Long) As LongDim str5 As String, ff As ByteDim hi As Long, ii As Longstr5 = StrConv(ELGFont.elfLogFont.lfFaceName, vbUnicode)str5 = Left(str5, InStr(1, str5, Chr(0)) - 1)ii = GetDeviceCaps(hdc, LOGPIXELSY)hi = MulDiv(ELGFont.elfLogFont.lfHeight, 72, ii)Debug.Print "FontFace = "; str5, " Height (point) = "; hiIf (fonttype And DEVICE_FONTTYPE) <> 0 Then Debug.Print " Type is Vector"End IfIf (fonttype And RASTER_FONTTYPE) <> 0 Then Debug.Print " Type is Raster"End IfIf (fonttype And TRUETYPE_FONTTYPE) <> 0 Then Debug.Print " Type is TrueType"End Ifff = ELGFont.elfLogFont.lfPitchAndFamily And &HF0If ff = FF_DECORATIVE Then Debug.Print " Family = Decorative"End IfIf ff = FF_DONTCARE Then Debug.Print " Family = Do Not Care"End IfIf ff = FF_MODERN Then Debug.Print " Family = Modern"End IfIf ff = FF_ROMAN Then Debug.Print " Family = Roman"End IfIf ff = FF_SCRIPT Then Debug.Print " Family = Script"End IfIf ff = FF_SWISS Then Debug.Print " Family = Swiss"End IfFontFamily = 1End Function'Below is in FormPrivate Sub Form_Load()Call EnumFontInfoEnd Sub

取得各字型的信息

[ 1 ]
取得各字型的信息 num

打印本页 关闭

关于我们版权声明本站导航友情连结作品演示 TOP↑