fontspec package

repository·develop·Indexed 43 days ago

https://github.com/latex3/fontspec

A unified interface for loading fonts in XeTeX and LuaTeX. It allows users to load fonts by name or filename and provides access to OpenType font features such as ligatures, swash letters, and proportional numbers. Key commands include \setmainfont, \setsansfont, \setmonofont, \newfontfamily, and \defaultfontfeatures.

Tokens
2.4K
Snippets
14
Records
19
Agent score
54%

What's inside fontspec

  1. Overview of the fontspec package

    develop

    The fontspec package provides a unified interface for loading fonts in LaTeX using XeTeX or LuaTeX. It allows you to load fonts directly by their name or filename without requiring manual font installation (LuaTeX requires the luaotfload package).

    Beyond simple loading, fontspec provides access to OpenType font features, such as:

    • Upper and lower case numbers
    • Proportional and monospaced numbers
    • Swash letters
    • Ligature control
  2. Identify fontspec package components and files

    develop

    The fontspec package consists of several file types depending on whether you are using the development repository or an installed distribution.

    • Core LaTeX files: fontspec.sty, fontspec.cfg, and fontspec.lua are the primary files used during typesetting.
    • Engine-specific files: The package provides fontspec-luatex.sty for LuaTeX and fontspec-xetex.sty for XeTeX.
    • Documentation: The primary documentation is available as fontspec.pdf and fontspec-code.pdf. Source files for documentation include fontspec-doc-intro.tex, fontspec-doc-opentype.tex, and others.
    • Examples: fontspec-example.tex is provided to demonstrate package functionality.
  3. Release the package to CTAN

    develop

    To release a new version of fontspec to CTAN, follow these steps:

    1. Update CHANGES.md: Finalize the record of changes. The topmost tag in this file is used to determine the version number.
    2. Prepare the branch: Ensure you are on the develop branch, it is fully up-to-date (pull), and all changes are committed.
    3. Execute the release script: Run lua autorelease.lua and follow the interactive prompts.

    The autorelease.lua script automates syncing the master and develop branches, tagging the repository, and using l3build ctan and l3build upload to distribute the package.

    lua autorelease.lua
  4. Install the fontspec package

    develop

    Depending on your TeX distribution and desired version, use one of the following methods to install fontspec:

    Via TeX Live

    Update to the latest version using tlmgr:

    tlmgr install fontspec

    Via Manual Download

    Download the pre-built TDS package from CTAN and extract it into your local texmf tree.

    Via GitHub (Development Version)

    Clone the repository and use l3build to install:

    git clone git://github.com/latex3/fontspec.git
    cd fontspec
    l3build install

    Note: You may need to run texhash after installation to update the filename database.

  5. Build the package documentation

    develop

    The package documentation is contained within fontspec-doc-*.tex files and is typeset using fontspec.ltx. You can generate the PDF documentation using the l3build build system with the doc command.

    l3build doc
  6. Install the latest development version from GitHub

    develop

    To use the latest development version, clone the repository from GitHub. Note that the develop branch contains unreleased changes and may not be fully functional.

    After cloning, use l3build install to compile the documentation and install the necessary files into your local texmf tree. Depending on your TeX distribution configuration, you may need to run texhash to update the filename database.

    git clone git://github.com/latex3/fontspec.git
    cd fontspec
    l3build install
    # If necessary:
    texhash
  7. Install test and documentation fonts

    develop

    The build system automatically pulls fonts from the fontspec-test-fonts repository. If you prefer to compile documentation manually, you should clone the repository and run the installation script locally.

    1. Clone the font repository: git clone https://github.com/wspr/fontspec-test-fonts.git
    2. Navigate to the directory: cd fontspec-test-fonts
    3. Run the installer: sh install.sh
    git clone https://github.com/wspr/fontspec-test-fonts.git
    cd fontspec-test-fonts
    sh install.sh
  8. Manually install fontspec from CTAN

    develop

    To manually install the package, download the pre-built TDS package from CTAN and extract its contents into your local texmf tree.

    Download URL: http://mirror.ctan.org/install/macros/latex/contrib/fontspec.tds.zip

  9. Run the fontspec test suite

    develop

    The fontspec package is tested across two engines: XeTeX and LuaTeX. Because these engines produce distinct log files, tests typically produce two output files.

    Use the following commands to manage tests:

    • Save test results:
      • Default: l3build save <test name>
      • For LuaTeX specifically: l3build save -e luatex <test name>
    • Check tests: l3build check <test name>
    • Run all tests with randomization: To run the full suite, you can use --shuffle to randomize test order and --halt to stop immediately upon the first failure.
    l3build check --shuffle --halt
  10. Manage default font features

    develop

    You can control which OpenType features are applied globally or to specific fonts using \defaultfontfeatures.

    Global features

    Set or append features to be used for every subsequently defined font:

    • \defaultfontfeatures{<default font options>}: Sets the default features.
    • \defaultfontfeatures+{<add to default font options>}: Appends features to the current defaults.

    Font-specific features

    Apply features to a specific font name or a previously defined font switch:

    • \defaultfontfeatures[<font name or switch>]{<default font options>}: Sets features for a specific font.
    • \defaultfontfeatures+[<font name or switch>]{<add to defaults>}: Appends features to a specific font's defaults.
    \defaultfontfeatures{Ligatures=TeX}
    \defaultfontfeatures[MyFont]{Numbers=OldStyle}