在vba中如何获取所有字体!
<p>怎样才能在窗体的复合框中显示系统和CAD中所有的字体啊??</p><p></p><p dir="ltr" style="MARGIN-RIGHT: 0px;">谢谢各位!!!!</p> <p>怎么没有人回答我呢??</p><p></p><p>真是伤心啊</p><p></p><p>难道就没有一位高手愿意帮忙吗?</p> 需要得到字体所在的目录,读取所有文件名并进行判断。 <p>具体怎么操作啊?</p><p>如何读取字体文体啊?</p> <p>能不能给一段示例代码啊?</p> <p>在autocad vba 二次开发教程第五章有一个类似的例子:(下面是部分)</p><p>Option Explicit</p><p>' 获得SHX字体<br/>Public Function GetShxFont(ByVal bBigFont As Boolean) As Variant<br/> Dim strFontFileName() As String ' 所有字体名称的数组<br/> Dim strFontPath() As String ' AutoCAD的字体文件路径<br/> <br/> ' 获得所有的支持文件路径<br/> strFontPath = Split(ThisDrawing.Application.Preferences.Files, ";")<br/> <br/> ' 遍历所有的支持文件路径<br/> Dim i As Integer<br/> Dim bFirst As Boolean ' 是否是第一次查找该文件夹<br/> Dim strFont As String ' 字体文件名称<br/> Dim strTemp As String ' 读取到的字体文件的一行<br/> Dim intCount As Integer ' 字体数组的维数<br/> Dim strFontFile As String ' 字体文件的位置<br/> intCount = -1<br/> For i = 0 To UBound(strFontPath)<br/> bFirst = True<br/> ' 确保最后一个字符是"\"<br/> strFontPath(i) = IIf(Right(strFontPath(i), 1) = "\", strFontPath(i), strFontPath(i) & "\")<br/> <br/> Do<br/> If bFirst Then<br/> strFont = Dir(strFontPath(i) & "*.shx")<br/> bFirst = False<br/> Else<br/> strFont = Dir<br/> End If<br/> <br/> If Len(strFont) <> 0 Then<br/> ' 打开字体文件<br/> strFontFile = strFontPath(i) & strFont<br/> Open strFontFile For Input As #1<br/> Line Input #1, strTemp<br/> Close #1<br/> <br/> ' 判断字体的类型<br/> If bBigFont Then<br/> If Mid(strTemp, 12, 7) = "bigfont" Then<br/> intCount = intCount + 1<br/> ReDim Preserve strFontFileName(intCount)<br/> strFontFileName(intCount) = strFont<br/> End If<br/> Else<br/> If Mid(strTemp, 12, 7) = "unifont" Or Mid(strTemp, 12, 6) = "shapes" Then<br/> intCount = intCount + 1<br/> ReDim Preserve strFontFileName(intCount)<br/> strFontFileName(intCount) = strFont<br/> End If<br/> End If<br/> Else<br/> Exit Do<br/> End If<br/> Loop<br/> Next i<br/> <br/> GetShxFont = strFontFileName<br/>End Function<br/></p> <p>多谢楼上的大侠!!!</p><p>不过有个新的问题</p><p>我获取了字体文件之后只能得到字体文件的名称,而无法得到字体的名称</p><p>请大侠再指点迷津</p><p>感激不尽</p>
页:
[1]