类型 功能 库 native.* 返回值 数组 修订版本 发行版 2024.3703 关键字 字体,字体名称 另请参见 native.newFont() display.newText()
返回可用本机字体的数组。
Corona Simulator 中可用的字体可能与设备上的字体不同。通常,iOS 设备字体可以通过 macOS 的 Corona Simulator 访问,但是也会有 macOS 附加字体可用,但可能无法在设备上运行。如果你遇到在 Corona Simulator 中字体出现但在设备上不出现的问题,这可能是最可能的原因。如有疑问,请使用 native.getFontNames()
检查设备可用的字体名称。
如果你使用自定义字体,也使用 native.getFontNames()
。在 Android 上,字体名称必须完全正确拼写,但通常字体名称与字体文件名称不同;对于给定的字体文件,字体名称在 Android 上与在 iOS 上可能不同。
native.getFontNames()
local systemFonts = native.getFontNames() -- Set the string to query for (part of the font name to locate) local searchString = "pt" -- Display each font in the Terminal/console for i, fontName in ipairs( systemFonts ) do local j, k = string.find( string.lower(fontName), string.lower(searchString) ) if ( j ~= nil ) then print( "Font Name = " .. tostring( fontName ) ) end end