### Build and Install Luaotfload Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Commands for installing the package into the texmf tree and updating the file name database. ```bash l3build install ``` ```bash mktexlsr ``` -------------------------------- ### Luaotfload Configuration File Example Source: https://context7.com/latex3/luaotfload/llms.txt An annotated example of the luaotfload.conf file, demonstrating various configuration options for font indexing, feature application, path settings, and runtime behavior. This file is read from standard locations. ```ini ;; luaotfload.conf — full annotated example [db] ;; Font formats to index (otf, ttf, ttc, afm, pfb) formats = otf, ttf, ttc ;; Prefer texmf fonts over system fonts when both exist location-precedence = texmf, system, local ;; Compress the names database with gzip compress = true ;; Automatically reload the database on unknown font lookup update-live = true ;; Include $PWD in font search (disables on-disk caching) scan-local = false ;; Maximum number of font files to process (useful for debugging) max-fonts = 500 [default-features] ;; Apply these features globally to all fonts global = mode=node ;; Apply extra features for the default (dflt) script dflt = liga, kern [misc] ;; Wrap terminal output at this width (nil = auto-detect) termwidth = 80 ;; Collect and append statistics to the index file statistics = false [paths] cache-dir = fonts names-dir = names index-file = luaotfload-names.lua lookups-file = luaotfload-lookup-cache.lua [run] ;; Verbosity: 0 = quiet, 5 = very noisy log-level = 0 ;; Cache successful name lookups for speed resolver = cached ;; Callback stage for per-font colorization color-callback = post_linebreak_filter ;; Font definition callback: "patch" (default) or "generic" definer = patch ;; Fontloader backend: "default", "reference", "unpackaged", "context" fontloader = default ``` -------------------------------- ### luaotfload-tool: List and Filter Fonts Source: https://context7.com/latex3/luaotfload/llms.txt Examples of listing fonts from the database with custom fields and filtering by name patterns. ```bash # List all indexed fonts sorted by format, showing file and version luaotfload-tool --list="format" --fields="file->base,version" # List fonts matching a specific family name luaotfload-tool --list="names->sanitized->english->family:Noto*" \ --fields="file->base,style->width" ``` -------------------------------- ### Example Luaotfload Configuration Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload.conf.rst A sample configuration file demonstrating customizations for font formats, index compression, terminal width, and logging level. Save this to ./luaotfload.conf to test. ```ini [db] formats = afm,ttf compress = false [misc] termwidth = 60 [run] log-level = 6 ``` -------------------------------- ### Luaotfload Configuration File Syntax: Section Declaration Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload.conf.rst Example of how to declare a new section in the luaotfload.conf file. Sections group related configuration variables. ```ini [some-section] ... section content ... ``` -------------------------------- ### Luaotfload Configuration File Syntax: Variable Assignment Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload.conf.rst Example of a variable assignment within a section in the luaotfload.conf file. Variables define specific settings for Luaotfload. ```ini [foo] bar = baz quux = xyzzy ``` -------------------------------- ### Generate man pages with rst2man.py Source: https://github.com/latex3/luaotfload/blob/main/todoinfos/scriptcall.txt Generates man pages from reStructuredText files. Requires docutils to be installed. ```bash rst2man.py luaotfload.conf.rst luaotfload.conf.5 ``` ```bash rst2man.py luaotfload-tool.rst luaotfload.tool.1 ``` -------------------------------- ### Import package with mkimport Source: https://github.com/latex3/luaotfload/blob/main/todoinfos/scriptcall.txt Imports package files. This command is merged with the call and sets USER and HOSTNAME to get a sensible header. ```bash texlua scripts/mkimport package ``` -------------------------------- ### Inspect currently loaded fonts Source: https://context7.com/latex3/luaotfload/llms.txt Gets a list of all fonts loaded in the current document, along with specified fields like fullname and filename. Useful for font management and debugging. ```lua -- Retrieve fullname and filename for every loaded font local loaded = luaotfload.aux.get_loaded_fonts({"fullname", "filename"}) for _, entry in ipairs(loaded) do local id = entry[1] local fields = entry[2] texio.write_nl("log", string.format( "Font ID %d: %s (%s)", id, tostring(fields[1]), tostring(fields[2]) )) end ``` -------------------------------- ### Register and Remove Callback for Font Patching Source: https://context7.com/latex3/luaotfload/llms.txt Register a custom patch function to be applied after each font is loaded using `luaotfload.patch_font`. This example demonstrates adding a custom field and logging the font name, as well as forcing a minimum x-height. Callbacks can be removed when no longer needed. ```lua -- Register a custom patch applied after every font is loaded. -- This example adds a custom field and logs the font name. luatexbase.add_to_callback( "luaotfload.patch_font", function(tfmdata, specification) local name = tfmdata.fullname or tfmdata.name or "unknown" texio.write_nl("log", "[my-package] Patching font: " .. name) -- Example: force a minimum x-height of 400sp for all fonts local parameters = tfmdata.parameters if parameters and (parameters.x_height or 0) < 400 then parameters.x_height = 400 end end, "my-package.patch_font_example" ) -- Remove the callback when no longer needed luatexbase.remove_from_callback( "luaotfload.patch_font", "my-package.patch_font_example" ) ``` -------------------------------- ### Bisection of Font Database Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload-tool.rst Utilize the --bisect directive for debugging the LuaTeX engine, particularly for memory leaks or buggy fonts. Directives include 'run', 'start', and 'stop'. ```bash --bisect=run ``` ```bash --bisect=start ``` ```bash --bisect=stop ``` -------------------------------- ### luaotfload-tool: Find and Inspect Fonts Source: https://context7.com/latex3/luaotfload/llms.txt Demonstrates how to find fonts by name, including fuzzy matching, and how to inspect detailed font information using the luaotfload-tool. ```bash # Find a font by name; print the resolved file path luaotfload-tool --find="Linux Libertine O" # Output: /usr/share/fonts/opentype/linux-libertine/LinLibertine_R.otf # Find with fuzzy matching (useful for misspellings) luaotfload-tool --find="Libertine" --fuzzy # Display detailed font info (loads the font — slow) luaotfload-tool --find="Linux Libertine O" --inspect ``` -------------------------------- ### luaotfload-tool: Diagnostics and Configuration Source: https://context7.com/latex3/luaotfload/llms.txt Commands for running diagnostic checks on the font loading system and dumping the current configuration. ```bash # Diagnostic checks luaotfload-tool --diagnose=files,permissions,environment,index # Dump the current active configuration to stdout luaotfload-tool --dumpconf ``` -------------------------------- ### Create glyphlist.txt with mkglyphlist Source: https://github.com/latex3/luaotfload/blob/main/todoinfos/scriptcall.txt Generates glyphlist.txt. This script may need to be called twice if glyphlist.txt does not exist. Files are created in src/auto. ```bash texlua scripts/mkglyphlist ``` -------------------------------- ### Luaotfload Tool Configuration Commands Source: https://context7.com/latex3/luaotfload/llms.txt Commands using the luaotfload-tool utility to dump the currently active configuration, either the default or a specific configuration file. ```bash # Dump currently active configuration (including all defaults) luaotfload-tool --dumpconf > ~/.config/luaotfload/luaotfload.conf # Load a specific configuration file and then dump it luaotfload-tool --conf=/path/to/my.conf --dumpconf ``` -------------------------------- ### Import files with mkimport (import) Source: https://github.com/latex3/luaotfload/blob/main/todoinfos/scriptcall.txt Imports files from context. This command also imports the merged original file and saves it as fontloader-reference.lua in src/fontloader/runtime. Requires CONTEXTPATH environment variable. ```bash texlua scripts/mkimport import "" %CONTEXTPATH% ``` -------------------------------- ### Luaotfload Font Request Syntax Source: https://context7.com/latex3/luaotfload/llms.txt Illustrates the general syntax for font requests in Luaotfload, covering anonymous, name, and file lookups with various OpenType features and special settings. ```latex % General form: % :/: % where is name: | file: | path: (or omitted for anonymous) % Anonymous lookup — tries tex, path, name in sequence (configurable) \font\A = {MyFont-Regular} at 12pt % Name lookup with multiple features \font\B = {name:TeX Gyre Pagella:+liga;+kern;+smcp;color=FF0000} at 11pt % File lookup with language/script selection \font\C = {file:arabtype.ttf:script=arab;language=ARA;mode=harf} at 14pt % Subfont selection (TTC collections, index 2) \font\D = {name:Source Han Serif:subfont=2} at 12pt % Embolden pseudo-feature (fake bold via outline expansion) \font\E = {name:Linux Libertine O:embolden=2} at 12pt % Letterspacing \font\F = {name:Linux Libertine O:letterspace=100} at 12pt ``` -------------------------------- ### Create luaotfload-character.lua with mkcharacters Source: https://github.com/latex3/luaotfload/blob/main/todoinfos/scriptcall.txt Generates a new luaotfload-character.lua file. Requires char-def.lua and char-ini.lua. The file is created in src/auto by default. Ensure CONTEXTPATH environment variable is set. ```bash texlua scripts/mkcharacters %CONTEXTPATH%/tex/context/base/mkiv/ ``` -------------------------------- ### luaotfload-tool: Bisect Font Database Source: https://context7.com/latex3/luaotfload/llms.txt Instructions for using the bisect command to isolate a problematic font in the database by iteratively narrowing down the search space. ```bash # Bisect font database to isolate a problematic font luaotfload-tool --bisect=start luaotfload-tool --update --bisect=run luaotfload-tool --bisect=bad # mark this half as containing the bug luaotfload-tool --update --bisect=run luaotfload-tool --bisect=good # ... repeat until a single font is isolated luaotfload-tool --bisect=stop ``` -------------------------------- ### Dump Current Luaotfload Configuration Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload.conf.rst Command to write the current Luaotfload configuration to a file. The output can be used as a new configuration file. ```bash luaotfload-tool --dumpconf > luaotfload.conf ``` -------------------------------- ### Import files with mkimport (news) Source: https://github.com/latex3/luaotfload/blob/main/todoinfos/scriptcall.txt Imports files from context, specifically for new changes. The first argument's purpose is unclear. Requires CONTEXTPATH environment variable. ```bash texlua scripts/mkimport news "" %CONTEXTPATH% ``` -------------------------------- ### Create CTAN Package Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Use l3build ctan to create the package for CTAN. This command handles the packaging process after all other build and documentation steps are completed. ```bash l3build ctan ``` -------------------------------- ### luaotfload.conf Configuration Source: https://context7.com/latex3/luaotfload/llms.txt This section details the configuration options available in the `luaotfload.conf` file, which is an INI-style file used to customize luaotfload's behavior. ```APIDOC ## Configuration File (`luaotfload.conf`) Luaotfload reads an INI-style configuration file from standard locations (`./luaotfload.conf`, `$XDG_CONFIG_HOME/luaotfload/luaotfload.conf`, `~/.luaotfloadrc`, or via kpathsea). ```ini ;; luaotfload.conf — full annotated example [db] ;; Font formats to index (otf, ttf, ttc, afm, pfb) formats = otf, ttf, ttc ;; Prefer texmf fonts over system fonts when both exist location-precedence = texmf, system, local ;; Compress the names database with gzip compress = true ;; Automatically reload the database on unknown font lookup update-live = true ;; Include $PWD in font search (disables on-disk caching) scan-local = false ;; Maximum number of font files to process (useful for debugging) max-fonts = 500 [default-features] ;; Apply these features globally to all fonts global = mode=node ;; Apply extra features for the default (dflt) script dflt = liga, kern [misc] ;; Wrap terminal output at this width (nil = auto-detect) termwidth = 80 ;; Collect and append statistics to the index file statistics = false [paths] cache-dir = fonts names-dir = names index-file = luaotfload-names.lua lookups-file = luaotfload-lookup-cache.lua [run] ;; Verbosity: 0 = quiet, 5 = very noisy log-level = 0 ;; Cache successful name lookups for speed resolver = cached ;; Callback stage for per-font colorization color-callback = post_linebreak_filter ;; Font definition callback: "patch" (default) or "generic" definer = patch ;; Fontloader backend: "default", "reference", "unpackaged", "context" fontloader = default ``` ```bash # Dump currently active configuration (including all defaults) luaotfload-tool --dumpconf > ~/.config/luaotfload/luaotfload.conf # Load a specific configuration file and then dump it luaotfload-tool --conf=/path/to/my.conf --dumpconf ``` ``` -------------------------------- ### Run Build Checks Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Execute the l3build check command to run tests in the default TeX Live and with a development version of luatex. ```bash l3build check ``` -------------------------------- ### Loading Fonts in LuaLaTeX Source: https://context7.com/latex3/luaotfload/llms.txt Demonstrates various methods for loading fonts in LuaLaTeX using Luaotfload's extended syntax, including by name, file, and with OpenType features. ```latex % --- LuaLaTeX: luaotfload is loaded automatically --- % Load by font name (from the luaotfload database) \font\myfont = {name:Linux Libertine O} at 12pt \myfont Hello, world! % Load by file name \font\mono = {file:InconsolataN-Regular.otf} at 10pt % Load with OpenType features (node mode, default) \font\smcp = {name:Linux Libertine O:+smcp;+onum} at 11pt % Load in HarfBuzz mode \font\harffont = {name:Noto Serif:mode=harf;script=latn;language=ENG} at 12pt % Load a variable font with axis settings \font\varfont = {name:Roboto Flex:wght=700;wdth=75} at 12pt % Path-based load (absolute path or relative) \font\custom = {[/usr/share/fonts/truetype/MyFont.ttf]} at 12pt ``` -------------------------------- ### luaotfload-tool: Cache Management Source: https://context7.com/latex3/luaotfload/llms.txt Commands for managing the Luaotfload cache, including showing statistics, purging Lua cache files, and erasing both Lua and bytecode caches. ```bash # Cache management luaotfload-tool --cache=show # print cache statistics luaotfload-tool --cache=purge # delete Lua cache files luaotfload-tool --cache=erase # delete Lua and bytecode cache files # Flush lookup cache only luaotfload-tool --flush-lookups ``` -------------------------------- ### Upload CTAN Package Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Upload the created CTAN package. This is the final step in releasing the package to CTAN. ```bash l3build upload ``` -------------------------------- ### Add Git Tag and Update Status Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Add a git tag for the release and then update the luaotfload-status file again to reflect the new tag. This ensures the status file contains correct hashes. ```bash git tag -a v2.98 -m 'my version 2.98' ``` ```bash texlua scripts/mkstatus --fontloader=./src/auto/fontloader-2019-07-04.lua ``` -------------------------------- ### Generate Man Pages and Documentation Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Commands to generate man pages and TeX documents from reStructuredText files using rst2man.py and rst2xetex.py. These are typically run from the luaotfload/doc directory. ```bash rst2man.py luaotfload.conf.rst luaotfload.conf.5 ``` ```bash rst2xetex.py luaotfload.conf.rst luaotfload-conf.tex ``` ```bash rst2man.py luaotfload-tool.rst luaotfload-tool.1 ``` ```bash rst2xetex.py luaotfload-tool.rst luaotfload-tool.tex ``` -------------------------------- ### Show Blacklisted Files Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload-tool.rst Display a list of blacklisted files. This option does not include directories. ```bash --show-blacklist ``` ```bash -b ``` -------------------------------- ### List Font Entries by Format Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload-tool.rst Use the --list and --fields options to display specific font information, sorted by a chosen criterion. Ensure arguments with special characters like '->' are quoted. ```bash ./luaotfload-tool.lua --list="format" --fields="file->base,version" ``` -------------------------------- ### Compile Documentation with LuaLaTeX Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Compile various TeX documents using lualatex. This step is part of the documentation generation process. ```bash lualatex luaotfload-tool.tex ``` ```bash lualatex luaotfload-conf.tex ``` ```bash lualatex filegraph ``` ```bash lualatex ``` -------------------------------- ### Load luaotfload Manually in Plain LuaTeX Source: https://context7.com/latex3/luaotfload/llms.txt In Plain LuaTeX, the `luaotfload.sty` package must be loaded explicitly using `\input`. After loading, fonts can be used with the extended syntax, and Lua code can access `luaotfload.version`. ```tex % Plain LuaTeX: load luaotfload manually \input luaotfload.sty % Now fonts can be loaded with the extended syntax \font\myfont = {name:Linux Libertine O:+liga;+kern} at 12pt \myfont Hello from Plain LuaTeX! % Check version from Lua \directlua{ texio.write_nl("log", "luaotfload version: " .. luaotfload.version) } \bye ``` -------------------------------- ### luaotfload-tool: Update Font Database Source: https://context7.com/latex3/luaotfload/llms.txt Commands for updating the Luaotfload font database, including options for incremental updates, full rebuilds, and local directory scanning. ```bash # Update (index new fonts only) luaotfload-tool --update # Force full rebuild luaotfload-tool --force --update # Include fonts in the current working directory luaotfload-tool --update --local # Limit scanned formats (e.g. only OTF and TTF, skip TTC) luaotfload-tool --update --formats=-ttc ``` -------------------------------- ### Update luaotfload-status with mkstatus Source: https://github.com/latex3/luaotfload/blob/main/todoinfos/scriptcall.txt Updates the luaotfload-status file. The date must be naturally correct. Requires a path to the fontloader status file. ```bash texlua scripts/mkstatus --fontloader=./src/auto/fontloader-2018-09-19.lua ``` -------------------------------- ### luaotfload.aux.provides_script Source: https://context7.com/latex3/luaotfload/llms.txt Determines if a font supports a given OpenType script tag. ```APIDOC ### `luaotfload.aux.provides_script` — Query script support Returns `true` if the font defines at least one OpenType feature for the given script tag. ```lua local font_id = font.id("\arabfont") if luaotfload.aux.provides_script(font_id, "arab") then texio.write_nl("log", "Font supports Arabic script.") end if luaotfload.aux.provides_script(font_id, "latn") then texio.write_nl("log", "Font supports Latin script.") end ``` ``` -------------------------------- ### Tag Build Version Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Tag the current build version using l3build tag. This command is used to update version information in build.lua and prepare for CTAN release. ```bash l3build tag 0 ``` -------------------------------- ### Generate TeX files with rst2xetex.py Source: https://github.com/latex3/luaotfload/blob/main/todoinfos/scriptcall.txt Converts reStructuredText files to TeX format, suitable for compilation with lualatex. ```bash rst2xetex.py luaotfload.conf.rst luaotfload.conf.tex ``` ```bash rst2xetex.py luaotfload-tool.rst luaotfload-tool.tex ``` -------------------------------- ### Read the font database index Source: https://context7.com/latex3/luaotfload/llms.txt Loads the raw font name index from disk without affecting the live resolver. Useful for inspecting the available font database. ```lua local index = luaotfload.aux.read_font_index() local count = 0 for _ in pairs(index) do count = count + 1 end texio.write_nl("log", "Database entries: " .. tostring(count)) ``` -------------------------------- ### Apply per-font color using hex string Source: https://context7.com/latex3/luaotfload/llms.txt Adds a tint to text by specifying a hex color string (e.g., RRGGBB or RRGGBBAA) via the `color` pseudo-feature. The color callback can be configured in luaotfload.conf. ```latex % Red text \font\redfont = {name:Linux Libertine O:color=FF0000} at 12pt {\redfont This text is red.} % Semi-transparent blue (RRGGBBAA) \font\bluefade = {name:Linux Libertine O:color=0000FF80} at 12pt {\bluefade This text is translucent blue.} % Color stage can be changed in luaotfload.conf: % [run] % color-callback = pre_linebreak_filter ; or post_linebreak_filter ``` -------------------------------- ### Disable Stripping of Database Information Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload-tool.rst Use the --no-strip option to prevent the removal of redundant information after building the database. This will significantly increase the index size. ```bash --no-strip ``` -------------------------------- ### Control Cache Operations Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload-tool.rst Manage the font and lookup caches using the --cache directive. Options include purging Lua files, erasing both Lua and Luc files, or showing cache statistics. ```bash --cache=purge ``` ```bash --cache=erase ``` ```bash --cache=show ``` -------------------------------- ### Update Font Index with Luaotfload Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload.conf.rst Command to update the Luaotfload font index, useful for observing changes after modifying the configuration file. Use --force to overwrite existing index. ```bash luaotfload-tool --update --force ``` -------------------------------- ### Resolve a font name to a file path Source: https://context7.com/latex3/luaotfload/llms.txt Looks up a font name in the database and returns its file path and optional subfont index. Essential for loading fonts by name. ```lua local path, subfont = luaotfload.aux.resolve_fontname("Linux Libertine O") if path then texio.write_nl("log", "Resolved to: " .. path) if subfont then texio.write_nl("log", "Subfont index: " .. tostring(subfont)) end else texio.write_nl("log", "Font not found in database.") end ``` -------------------------------- ### Query Font Script Support Source: https://context7.com/latex3/luaotfload/llms.txt Employs `luaotfload.aux.provides_script` to check if a font includes OpenType features for a specified script tag. This helps in determining if a font is suitable for rendering text in a particular language or writing system, such as Arabic ('arab') or Latin ('latn'). ```lua local font_id = font.id("\arabfont") if luaotfload.aux.provides_script(font_id, "arab") then texio.write_nl("log", "Font supports Arabic script.") end if luaotfload.aux.provides_script(font_id, "latn") then texio.write_nl("log", "Font supports Latin script.") end ``` -------------------------------- ### Compile TeX files with lualatex Source: https://github.com/latex3/luaotfload/blob/main/todoinfos/scriptcall.txt Compiles TeX files generated from reStructuredText into PDF documents. ```bash lualatex luaotfload.conf.tex ``` ```bash lualatex luaotfload-tool.tex ``` -------------------------------- ### luaotfload.aux.provides_language Source: https://context7.com/latex3/luaotfload/llms.txt Queries if a font supports a given language tag within a specific script. Returns true if supported, false otherwise. ```APIDOC ## luaotfload.aux.provides_language ### Description Returns `true` if the font supports the given language tag within the given script. ### Parameters - **font_id** (number) - The ID of the font to query. - **script** (string) - The script tag (e.g., "latn"). - **language** (string) - The language tag (e.g., "TRK", "dflt"). ### Request Example ```lua local font_id = font.id("\myfont") if luaotfload.aux.provides_language(font_id, "latn", "TRK") then texio.write_nl("log", "Font has Turkish-specific Latin features.") end ``` ``` -------------------------------- ### Read a math parameter from a font Source: https://context7.com/latex3/luaotfload/llms.txt Retrieves specific mathematical constants (e.g., rule thickness, scaling factors) from a font's math tables. Useful for precise mathematical typesetting. ```lua local font_id = font.id("\mathfont") local frac_rule_thickness = luaotfload.aux.get_math_dimension(font_id, "FractionRuleThickness") texio.write_nl("log", "FractionRuleThickness = " .. tostring(frac_rule_thickness) .. " sp") local script_scale = luaotfload.aux.get_math_dimension(font_id, "ScriptPercentScaleDown") ``` -------------------------------- ### Perform a Dry Run Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload-tool.rst Execute a dry run to debug file system issues. This option scans directories without loading fonts. ```bash --dry-run ``` ```bash -D ``` -------------------------------- ### luaotfload.aux.name_of_slot Source: https://context7.com/latex3/luaotfload/llms.txt Converts a Unicode codepoint to its Adobe Glyph List name. ```APIDOC ### `luaotfload.aux.name_of_slot` — Resolve Unicode codepoint to Adobe Glyph name Inverse of `slot_of_name`; looks up the AGL name for a given codepoint. ```lua local name = luaotfload.aux.name_of_slot(0x00E9) -- U+00E9 é -- name == "eacute" texio.write_nl("log", "Glyph name: " .. tostring(name)) local name2 = luaotfload.aux.name_of_slot(0x20AC) -- U+20AC € -- name2 == "Euro" ``` ``` -------------------------------- ### Update Context with Mkimport Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Use texlua scripts/mkimport to update the context. This command is used for both news and import operations. Ensure the CONTEXTPATH environment variable is correctly set. ```bash texlua scripts/mkimport news "" %CONTEXTPATH% ``` ```bash texlua scripts/mkimport news "" $CONTEXTPATH ``` ```bash texlua scripts/mkimport import "" %CONTEXTPATH% ``` ```bash texlua scripts/mkimport import "" $CONTEXTPATH ``` -------------------------------- ### Define fallback fonts for missing glyphs Source: https://context7.com/latex3/luaotfload/llms.txt Chains a list of fonts using the `fallback` pseudo-feature to provide missing glyphs. The specified font is tried first, then the fallback font. ```latex % Define a fallback chain: try main font first, then NotoSans for missing glyphs \font\mainfb = {name:Linux Libertine O:fallback=NotoSans} at 12pt {\mainfb Text with CJK characters 你好 will fall back to NotoSans.} ``` -------------------------------- ### Update Luaotfload Status Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Use texlua scripts/mkstatus to update the luaotfload status, referencing the default fontloader. Ensure the date is naturally correct. ```bash texlua scripts/mkstatus --fontloader=./src/auto/fontloader-2020-04-30.lua ``` -------------------------------- ### Generate Luaotfload Characters Source: https://github.com/latex3/luaotfload/blob/main/buildinfo.txt Run the mkcharacters script to generate the luaotfload-character.lua file. This script requires char-def.lua and char-ini.lua and creates the output in src/auto by default. Note: This file is no longer used in recent versions. ```bash texlua scripts/mkcharacters %CONTEXTPATH%/tex/context/base/mkiv/ ``` ```bash texlua scripts/mkcharacters $CONTEXTPATH/tex/context/base/mkiv/ ``` -------------------------------- ### Query language support in a script Source: https://context7.com/latex3/luaotfload/llms.txt Checks if a font supports a specific language tag within a given script. Useful for ensuring correct typographic features are available. ```lua local font_id = font.id("\myfont") -- Check for Turkish language support in Latin script if luaotfload.aux.provides_language(font_id, "latn", "TRK") then texio.write_nl("log", "Font has Turkish-specific Latin features.") end -- Check for default language if luaotfload.aux.provides_language(font_id, "latn", "dflt") then texio.write_nl("log", "Font has a default language system for Latin.") end ``` -------------------------------- ### Shaping Modes Source: https://context7.com/latex3/luaotfload/llms.txt Configures the OpenType shaping engine used by luaotfload. Available modes are 'node', 'harf', and 'base'. ```APIDOC ## Shaping Modes ### Description Three shaping modes are available via the `mode` pseudo-feature. ### Modes - **node**: Default mode. Utilizes ConTeXt's Lua fontloader with full OpenType feature support. - **harf**: Requires the luahbtex engine. Offers excellent script support. - **base**: Limited mode. Maps OpenType features to TeX ligatures and kerning; primarily for math fonts. ### Usage Example ```latex % Default: node mode \font\nodemode = {name:Noto Serif:mode=node;script=latn;language=ENG} at 12pt % HarfBuzz mode \font\harfmode = {name:Noto Serif Arabic:mode=harf;script=arab;language=ARA} at 12pt % Base mode \font\basemode = {name:Latin Modern Math:mode=base} at 12pt ``` ``` -------------------------------- ### luaotfload.aux.get_loaded_fonts Source: https://context7.com/latex3/luaotfload/llms.txt Returns a list of all fonts currently loaded in the document, along with specified fields for each font. ```APIDOC ## luaotfload.aux.get_loaded_fonts ### Description Returns a list of `{font_id, {field_value, ...}}` pairs for all fonts loaded in the current document. ### Parameters - **fields** (table of strings) - A list of font fields to retrieve (e.g., {"fullname", "filename"}). ### Request Example ```lua local loaded = luaotfload.aux.get_loaded_fonts({"fullname", "filename"}) for _, entry in ipairs(loaded) do local id = entry[1] local fields = entry[2] texio.write_nl("log", string.format("Font ID %d: %s (%s)", id, tostring(fields[1]), tostring(fields[2]))) end ``` ``` -------------------------------- ### luaotfload.aux.provides_feature Source: https://context7.com/latex3/luaotfload/llms.txt Checks if a font defines a specific OpenType feature for a given script and language combination. Returns true if the feature is defined, false otherwise. ```APIDOC ## luaotfload.aux.provides_feature ### Description Returns `true` if the font defines `asked_feature` for the given script and language combination. ### Parameters - **font_id** (number) - The ID of the font to query. - **script** (string) - The script tag (e.g., "latn"). - **language** (string) - The language tag (e.g., "dflt"). - **feature** (string) - The feature tag (e.g., "smcp", "onum"). ### Request Example ```lua local font_id = font.id("\myfont") if luaotfload.aux.provides_feature(font_id, "latn", "dflt", "smcp") then texio.write_nl("log", "Font has small capitals (smcp).") end ``` ``` -------------------------------- ### Generate figure with lualatex Source: https://github.com/latex3/luaotfload/blob/main/todoinfos/scriptcall.txt Compiles a LaTeX file named 'filegraph' to generate a figure. ```bash lualatex filegraph ``` -------------------------------- ### Fallback Fonts Source: https://context7.com/latex3/luaotfload/llms.txt Chains a list of fonts to provide missing glyphs using the `fallback` feature. ```APIDOC ## Fallback Fonts ### Description The `fallback` feature chains a list of fonts to fill in missing glyphs. ### Usage Example ```latex % Define a fallback chain: try main font first, then NotoSans for missing glyphs \font\mainfb = {name:Linux Libertine O:fallback=NotoSans} at 12pt {\mainfb Text with CJK characters 你好 will fall back to NotoSans.} ``` ``` -------------------------------- ### luaotfload.aux.read_font_index Source: https://context7.com/latex3/luaotfload/llms.txt Reads the raw font name index table from disk. This operation does not affect the live font resolver state. ```APIDOC ## luaotfload.aux.read_font_index ### Description Returns the raw font name index table as read from the database file. Does not affect the live resolver state. ### Request Example ```lua local index = luaotfload.aux.read_font_index() local count = 0 for _ in pairs(index) do count = count + 1 end texio.write_nl("log", "Database entries: " .. tostring(count)) ``` ``` -------------------------------- ### Flush Font Name Lookup Cache Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload-tool.rst Clear the font name lookup cache. This is an experimental feature. ```bash --flush-lookups ``` -------------------------------- ### luaotfload.aux.resolve_fontname Source: https://context7.com/latex3/luaotfload/llms.txt Resolves a given font name to its file path and an optional subfont index using the font database. ```APIDOC ## luaotfload.aux.resolve_fontname ### Description Runs a name-based lookup and returns the resolved file path and optional subfont index. ### Parameters - **font_name** (string) - The name of the font to resolve. ### Returns - **path** (string or nil) - The file path to the font, or nil if not found. - **subfont** (number or nil) - The subfont index, if applicable. ### Request Example ```lua local path, subfont = luaotfload.aux.resolve_fontname("Linux Libertine O") if path then texio.write_nl("log", "Resolved to: " .. path) if subfont then texio.write_nl("log", "Subfont index: " .. tostring(subfont)) end else texio.write_nl("log", "Font not found in database.") end ``` ``` -------------------------------- ### Per-Font Color Feature Source: https://context7.com/latex3/luaotfload/llms.txt Applies a tint to a font using a hexadecimal color string via the `color` pseudo-feature. ```APIDOC ## Per-Font Color Feature ### Description Fonts can be tinted using a hex color string via the `color` pseudo-feature. ### Usage Example ```latex % Red text \font\redfont = {name:Linux Libertine O:color=FF0000} at 12pt {\redfont This text is red.} % Semi-transparent blue (RRGGBBAA) \font\bluefade = {name:Linux Libertine O:color=0000FF80} at 12pt {\bluefade This text is translucent blue.} % Configuration note: % Color stage can be changed in luaotfload.conf: % [run] % color-callback = pre_linebreak_filter ; or post_linebreak_filter ``` ``` -------------------------------- ### Set shaping mode for fonts Source: https://context7.com/latex3/luaotfload/llms.txt Configures the text shaping engine for a font using the `mode` pseudo-feature. Supports 'node' (default), 'harf' (for luahbtex), and 'base' (limited, math only). ```latex % Default: node mode (ConTeXt Lua fontloader, full OpenType feature support) \font\nodemode = {name:Noto Serif:mode=node;script=latn;language=ENG} at 12pt % HarfBuzz mode (requires luahbtex engine; excellent script support) \font\harfmode = {name:Noto Serif Arabic:mode=harf;script=arab;language=ARA} at 12pt % Base mode (limited — maps OT features to TeX ligatures/kerning; math only) \font\basemode = {name:Latin Modern Math:mode=base} at 12pt ``` -------------------------------- ### luaotfload.aux.gid_of_name Source: https://context7.com/latex3/luaotfload/llms.txt Retrieves the internal Glyph ID (GID) for a glyph specified by its name within a font. ```APIDOC ### `luaotfload.aux.gid_of_name` — Resolve glyph name to GID Returns the internal Glyph ID (GID) for a named glyph in the given font. ```lua local font_id = font.id("\myfont") local gid = luaotfload.aux.gid_of_name(font_id, "A") texio.write_nl("log", "GID of 'A': " .. tostring(gid)) ``` ``` -------------------------------- ### luaotfload.aux.slot_of_name Source: https://context7.com/latex3/luaotfload/llms.txt Resolves an Adobe Glyph List name to its corresponding Unicode codepoint (slot) within a font. ```APIDOC ### `luaotfload.aux.slot_of_name` — Resolve Adobe Glyph name to Unicode slot Returns the Unicode codepoint (slot) for a glyph identified by its Adobe Glyph List name. ```lua local font_id = font.id("\myfont") local slot = luaotfload.aux.slot_of_name(font_id, "Euro") -- slot == 0x20AC (8364) for most fonts that contain the Euro glyph local slot2 = luaotfload.aux.slot_of_name(font_id, "fi") -- fi ligature if slot2 then texio.write_nl("log", string.format("fi ligature at U+%04X", slot2)) end ``` ``` -------------------------------- ### luaotfload.aux.provides_axis Source: https://context7.com/latex3/luaotfload/llms.txt Determines if a font is a variable font and exposes a requested variation axis. Returns true if the axis is available, false otherwise. ```APIDOC ## luaotfload.aux.provides_axis ### Description Returns `true` if the font is a variable font that exposes the requested variation axis. ### Parameters - **font_id** (number) - The ID of the font to query. - **axis** (string) - The variation axis tag (e.g., "wght", "wdth"). ### Request Example ```lua local font_id = font.id("\varfont") if luaotfload.aux.provides_axis(font_id, "wght") then texio.write_nl("log", "Font has a weight (wght) axis.") end ``` ``` -------------------------------- ### Limit Processed Fonts Source: https://github.com/latex3/luaotfload/blob/main/doc/luaotfload-tool.rst Control the maximum number of font files to process, including those already indexed, using the --max-fonts option. ```bash --max-fonts=N ``` -------------------------------- ### Resolve Unicode Codepoint to Adobe Glyph Name Source: https://context7.com/latex3/luaotfload/llms.txt Utilizes `luaotfload.aux.name_of_slot` as the inverse of `slot_of_name`, translating a Unicode codepoint into its Adobe Glyph List name. This is helpful for retrieving the standard name associated with a character, like 'eacute' for 'é' or 'Euro' for '€'. ```lua local name = luaotfload.aux.name_of_slot(0x00E9) -- U+00E9 é -- name == "eacute" texio.write_nl("log", "Glyph name: " .. tostring(name)) local name2 = luaotfload.aux.name_of_slot(0x20AC) -- U+20AC € -- name2 == "Euro" ```