如何在 Lua/MacOS 中使用 io.open 访问 .suit 字体文件?.ttf/.otf 可以正常工作,suit 不行

我正在将 Lua 5.2 中的 .ttf/.otf 字体文件阅读器从 Windows 转换为 MacOS,并希望添加对包括 ttf 字体的 .suit 字体文件的支持。

现在,普通的 .ttf/.otf 文件可以正常工作,但是 .suit 文件的读取已经无法工作了。

有没有任何想法可以在 MacOS 上读取 .suit 字体文件的字节? 这是否与文件名别名有关?

local input = assert(io.open("/Library/Fonts/Tahoma.ttf", "rb"))
local data=input:read("*all")
print(string.byte(data,1)) --打印正确值 0
io.close(input)

local input = assert(io.open("/Library/Fonts/Maestro.suit", "rb"))
local data=input:read("*all")
print(string.byte(data,1))  --未打印任何内容
io.close(input)

上面的部分(Tahoma)打印出了正确的第一个字节值 0,而下面的部分没有打印任何内容,尽管我原本期望的值是 0。

当我使用 string.len(data) 时,对于 Tahoma,它显示了正确的值,但对于 Maestro,它却显示为 0,尽管应该是类似于 46k 的值。

点赞
用户10932942
用户10932942

参见https://apple.stackexchange.com/questions/8455.suit不是一个文件夹,但可以像文件夹一样访问。要打开.suit文件中的字体部分,请使用以下命令:

local file=io.open("/Library/Fonts/Maestro.suit/..namedfork/rsrc","rb")
2019-01-21 10:16:53