LuaTeX does not contain platform-specific code, and while often platform-specific problems can be handled purely in Lua, it sometimes happens that access to the native operating system API is required. For such tasks, Lua allows loading extension modules written in C (or other languages provided that they can produce a dynamic library that exports a certain C-style function). The lualatex-platform package aims to provide such an extension module that is usable from both Lua and LuaTeX and adds a small set of features not available otherwise. At the moment, it merely supports listing the fonts known to the operating system.
The lualatex-platform package is free software; it is made available under the conditions of the Expat (MIT) license, which is reprinted below:
Copyright © 2011, Philipp Stephani <st_philipp@yahoo.de>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The lualatex-platform package is hosted on GitHub; please report any errors at the issue tracker.
The whole bundle consists of a LaTeX package lualatex-platform.sty, a LuaLaTeX module lualatex-platform.lua, and the actual C extension module lltxplatform.(dll|so). The extension module should compile for recent versions of Windows (with MinGW), OS X, and Linux. The compilation process is based on the GNU build system, so you should be able to compile the module with the commands:
./configure && make
The standard C headers and the Lua headers (lua.h etc.) must be present in the include path. On Windows, the compiler needs to access the Lua import library (lua51.lib or liblua51.a), which must be located in the library search path. On Linux, the compiler needs to access the FontConfig header files (fontconfig/fontconfig.h) and library (libfontconfig.so), which must be present in the respective search paths. Run ./configure --help for more options.
After compiling, make sure that the files lualatex-platform.sty, lualatex-platform.lua, and lltxplatform.(dll|so) can be found by LuaLaTeX. On Windows, the native library must be able to find the Lua runtime library lua51.dll.
In a LaTeX document or package, load the lualatex-platform package with:
\usepackage{lualatex-platform}
(or \RequirePackage, of course). The document should be compiled with the LuaTeX engine, and the luatexbase module has to be installed.
You can also load the Lua module directly:
\RequireLuaModule{lualatex-platform}
or, from Lua:
luatexbase.require_module("lualatex-platform")
After the module has been loaded, the table lualatex.platform contains the functions described below.
Note that on OS X, loading extension modules currently requires a custom-build LuaTeX binary.
The module table lualatex.platform contains two parameterless functions related to operating system font listing:
get_installed_fonts() returns either nil (in the case of an error), or an array of tables each of which represents one font known to the operating system and contains an arbitrary combination of the following items:
The array is in arbitrary order, and duplicates are possible.
get_inactive_fonts() returns either nil (in the case of an error), or an array of strings each of which represents one font treated as inactive by the operating system. The concept of inactive fonts exists only on Windows 7 and upwards; the inactive fonts are still present and usable, but are hidden in standard UI elements. The array of inactive fonts is in arbitrary order and the font names are not necessarily unique. There is no guarantee that the names returned by get_inactive_fonts() correspond to actual fonts installed in the system, or to the font names returned by get_installed_fonts(). The font names are encoded in UTF-8.