乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 76|回复: 6

在vba中如何获取所有字体!

[复制链接]

4

主题

19

帖子

2

银币

初来乍到

Rank: 1

铜币
35
发表于 2006-12-21 20:34:00 | 显示全部楼层 |阅读模式
怎样才能在窗体的复合框中显示系统和CAD中所有的字体啊??
谢谢各位!!!!
回复

使用道具 举报

4

主题

19

帖子

2

银币

初来乍到

Rank: 1

铜币
35
发表于 2006-12-25 13:10:00 | 显示全部楼层
怎么没有人回答我呢??
真是伤心啊
难道就没有一位高手愿意帮忙吗?
回复

使用道具 举报

158

主题

2315

帖子

10

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2951
发表于 2006-12-25 13:40:00 | 显示全部楼层
需要得到字体所在的目录,读取所有文件名并进行判断。
回复

使用道具 举报

4

主题

19

帖子

2

银币

初来乍到

Rank: 1

铜币
35
发表于 2006-12-26 12:48:00 | 显示全部楼层
具体怎么操作啊?
如何读取字体文体啊?
回复

使用道具 举报

4

主题

19

帖子

2

银币

初来乍到

Rank: 1

铜币
35
发表于 2006-12-26 12:50:00 | 显示全部楼层
能不能给一段示例代码啊?
回复

使用道具 举报

5

主题

58

帖子

8

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
78
发表于 2006-12-26 14:11:00 | 显示全部楼层
在autocad vba 二次开发教程第五章有一个类似的例子下面是部分)
Option Explicit
' 获得SHX字体
Public Function GetShxFont(ByVal bBigFont As Boolean) As Variant
    Dim strFontFileName() As String     ' 所有字体名称的数组
    Dim strFontPath() As String     ' AutoCAD的字体文件路径
   
    ' 获得所有的支持文件路径
    strFontPath = Split(ThisDrawing.Application.Preferences.Files, ";")
   
    ' 遍历所有的支持文件路径
    Dim i As Integer
    Dim bFirst As Boolean       ' 是否是第一次查找该文件夹
    Dim strFont As String       ' 字体文件名称
    Dim strTemp As String       ' 读取到的字体文件的一行
    Dim intCount As Integer     ' 字体数组的维数
    Dim strFontFile As String   ' 字体文件的位置
    intCount = -1
    For i = 0 To UBound(strFontPath)
        bFirst = True
        ' 确保最后一个字符是"\"
        strFontPath(i) = IIf(Right(strFontPath(i), 1) = "\", strFontPath(i), strFontPath(i) & "\")
        
        Do
            If bFirst Then
                strFont = Dir(strFontPath(i) & "*.shx")
                bFirst = False
            Else
                strFont = Dir
            End If
            
            If Len(strFont)  0 Then
                ' 打开字体文件
                strFontFile = strFontPath(i) & strFont
                Open strFontFile For Input As #1
                Line Input #1, strTemp
                Close #1
               
                ' 判断字体的类型
                If bBigFont Then
                    If Mid(strTemp, 12, 7) = "bigfont" Then
                        intCount = intCount + 1
                        ReDim Preserve strFontFileName(intCount)
                        strFontFileName(intCount) = strFont
                    End If
                Else
                    If Mid(strTemp, 12, 7) = "unifont" Or Mid(strTemp, 12, 6) = "shapes" Then
                        intCount = intCount + 1
                        ReDim Preserve strFontFileName(intCount)
                        strFontFileName(intCount) = strFont
                    End If
                End If
            Else
                Exit Do
            End If
        Loop
    Next i
   
    GetShxFont = strFontFileName
End Function
回复

使用道具 举报

4

主题

19

帖子

2

银币

初来乍到

Rank: 1

铜币
35
发表于 2006-12-27 22:49:00 | 显示全部楼层
多谢楼上的大侠!!!
不过有个新的问题
我获取了字体文件之后只能得到字体文件的名称,而无法得到字体的名称
请大侠再指点迷津
感激不尽
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-7 04:34 , Processed in 1.528524 second(s), 66 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表