3

Is there an example of use of TikZ with very different fonts, like the ones available at https://tug.org/FontCatalogue/?

There seems to be very different type of fonts. I succeded in using "calligra" for example, but other ones seem to have a different structure, and I think there must be a simple way to use several of them in one document. For example, these seem to have very different usage (Cf. the "Usage" paragraphs):

How can I have a text with all of them?

\documentclass{article}
\usepackage{tikz}
\usepackage{calligra}
\begin{document}
\begin{tikzpicture}
\node[draw] at (5,5) {\Huge \calligra Some text};
\end{tikzpicture}
\end{document}
7
  • I am not entirely sure what you're looking for, but if you are able & willing to use LuaLaTeX (or XeLaTeX, for that matter) you can use any regular .ttf or .otf font.
    – Ingmar
    May 15, 2022 at 18:18
  • I am using LuaLaTeX. I succeeded (not easily) in using together 8 fonts mentioned on tug.org. See my answer in the same post, with some other fonts that I don't know how to use. I still have a superficial understanding of LaTeX, so the different ways different fonts are used is still cryptic for me. I love the following pdf document, but I don't have its source: overleaf.com/latex/templates/fontspec-all-the-fonts/…. I'd like to have/make something similar.
    – Michaël
    May 16, 2022 at 11:00
  • You should probably first make yourself familiar with how to use fonts with LaTeX in general. There are large differences between the traditional, package-based approach that is confined to fonts for which a packages exists (and which you probably refer to), and a newer open approach that allows you to use any font that is installed on your system. Oct 12, 2022 at 14:29
  • @მამუკა ჯიბლაძე (not sure if pinging works): Could you be more specific about what you want such a document to look like? It's straightforward to generate a list of fonts available to LuaTeX, for example. If you want to list fonts available for use with pdfTeX (or just standard TeX, even), that needs a different approach. But you probably don't want to compile a document containing a sample of every font on your system. (Or do you? Not all will support the languages you typeset and some won't support any! If you try to typeset a sample sentence in them, you'll generate nothing.)
    – cfr
    Apr 13 at 2:07
  • 1
    @cfr Thank you for thinking about it. Yes, ა ბ გ are the first three letters of the Georgian alphabet, they are by now standard in any Unicode font (U+10D0, U+10D1, U+10D2). The whole alphabet occupies the range from U+10D0 to U+10F0 (in the ranges from U+10A0 to U+10CF and from U+10F1 to U+10FF there are also some archaic letters that may well be absent in the font). Some well known fonts like Segoe UI have these, but I would like to have as much choice as possilbe. 2 days ago

2 Answers 2

2

I finally succeeded in creating the kind of sample document I had in mind. Here it is.

I don't really understand what I'm doing for now (for example : The T1, the B1, the differences between the fonts...), but that will come later, little by little. Any suggestion of improvement is welcome :-)

By the way, I found a pdf with what I expected (and much more), but the latex-source was not given: https://www.overleaf.com/latex/templates/fontspec-all-the-fonts/hjrpnxhrrtxc.

\documentclass{article}

\usepackage{fontspec}
\usepackage{calligra}
\usepackage{bbold}
\usepackage{pbsi}
\usepackage[T1]{fontenc}
\usepackage{cyklop}
\usepackage{DejaVuSans}
\usepackage{auncial}
\usepackage[B1]{fontenc}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}

\node[draw] at (5,15) {\Huge {\fontspec{cyklop} Sample text in cyklop}};
\node[draw] at (5,13) {\Huge {\fontspec{DejaVuSans} Sample text in DejaVuSans}};
\node[draw] at (5,11) {\Huge {\fontspec{QTArabian} Sample text in QTArabian}};
\node[draw] at (5,9) {\Huge \aunclfamily Sample text in aunclfamily};
\node[draw] at (5,7) {\Huge \calligra Sample text in calligra};
\node[draw] at (5,5) {\Huge {\fontspec{QTBoulevard} Sample text in QTBoulevard}};
\node[draw] at (5,3) {\Huge \bbfamily Sample text in bbold / bbfamily};
\node[draw] at (5,1) {\Huge \bsifamily Sample text in pbsi / bsifamily};

\end{tikzpicture}

\end{document}

enter image description here

EDIT : There are still many fonts that I don't know how to use together. For example:

2

Even if you're planning on using the fonts with TikZ, I see no reason why you would need to generate the font sampler/specimen document with it.

Here, I've used ConTeXt to list all the fonts on the system, check to see if they contain the character , and if so, output a page with all the characters in the Georgian Unicode block. To run it, save it as <filename>.cld, then run context <filename>.cld to process the file.

#!/usr/bin/env -S context --once --forcecld

---------------------
--- Configuration ---
---------------------

local target_characters = {
    "ა", "ბ", "გ", "დ", "ე", "ვ", "ზ", "თ", "ი", "კ", "ლ", "მ", "ნ",
    "ო", "პ", "ჟ", "რ", "ს", "ტ", "უ", "ფ", "ქ", "ღ", "ყ", "შ", "ჩ",
    "ც", "ძ", "წ", "ჭ", "ხ", "ჯ", "ჰ", "ჱ", "ჲ", "ჳ", "ჴ", "ჵ", "ჶ",
    "ჷ", "ჸ", "ჹ", "ჺ", "჻", "ჼ", "ჽ", "ჾ", "ჿ", "Ⴀ", "Ⴁ", "Ⴂ", "Ⴃ",
    "Ⴄ", "Ⴅ", "Ⴆ", "Ⴇ", "Ⴈ", "Ⴉ", "Ⴊ", "Ⴋ", "Ⴌ", "Ⴍ", "Ⴎ", "Ⴏ", "Ⴐ",
    "Ⴑ", "Ⴒ", "Ⴓ", "Ⴔ", "Ⴕ", "Ⴖ", "Ⴗ", "Ⴘ", "Ⴙ", "Ⴚ", "Ⴛ", "Ⴜ", "Ⴝ",
    "Ⴞ", "Ⴟ", "Ⴠ", "Ⴡ", "Ⴢ", "Ⴣ", "Ⴤ", "Ⴥ", "Ⴧ", "Ⴭ",
}
local size = tex.sp("1cm")


------------
--- Code ---
------------

-- Generic wrapper so that we can use `context.step()`
context.stepwise(function() print(xpcall(function()

-- The character that we'll test each font for
local target_character = utf8.codepoint(target_characters[1])

-- Reload the font names database
if not os.getenv("OSFONTDIR") then
    os.setenv(
        "OSFONTDIR",
        "/usr/share/fonts:" .. os.getenv("HOME") .. "/.local/share/fonts/"
    )
end
fonts.names.load(true, true)

-- Get a list of all fonts on the system
local all_fonts = fonts.names.list("", true, true)

-- Configure the page layout
context.setupbodyfont { (0.75 * size) .. "sp" }
context.setupTABLE( { frame = "off" })
context.setupTABLE(
    { "row" }, { "each" },
    { align = "low, center", style = "tt" }
)
context.setupTABLE( { "row" }, { "first" }, { style = "ttbf" })
context.setupTABLE( { "column" }, { "each" }, { width = (1.5 * size) .. "sp" })
context.setupalign { "lesshyphenation", "verytolerant" }

-- Iterate over all the fonts
context.starttext()
for _, font in table.sortedpairs(all_fonts) do
    -- Get the full path to the font file
    local path = resolvers.findfile(font.filename)
    local hashed_path = sha2.hash256(path)

    if path:match("Fontmap") then
        -- Skip the fontmap files (not actual fonts)
        goto continue
    end

    -- Load the font
    local _, data = fonts.definers.define {
        name = path,
        filename = path,
        cs = hashed_path,
        size = size,
    }

    -- Check if the font contains the target character
    if data and data.characters and data.characters[target_character] then
        -- Begin the page
        context.step()
        context.startTEXpage { offset = size .. "sp" }
        context.startTABLE()

        -- Print the font name
        context.NC { nc = tostring(math.min(10, #target_characters)) }
        context(file.basename(path))
        context.NC() context.NR()

        -- Print the target characters
        for i, character in ipairs(target_characters) do
            context.NC()
            context[hashed_path](character)

            if i % 10 == 0 then
                context.NC() context.NR()
            end
        end
        context.NC() context.NR()

        -- End the page
        context.stopTABLE()
        context.stopTEXpage()
    end
    ::continue::
end
context.stoptext()

-- Close the wrapper function
end, debug.traceback)) end)

The first run will take a really long time (5+ minutes) since ConTeXt needs to create a font cache, but subsequent runs should be much faster (30 seconds on my computer).

On my computer (Linux + TeX Live 2024), I get the following output:

output page 1 output page 2 output page 3

8
  • I get this error: /home/me/fongeo.cld:7: unexpected symbol near '<'. The whole output is here yesterday
  • In case this matters, it happens on Ubuntu 23.10 under WSL 2.1.5.0 (kernel 6.1.21.2-microsoft-standard-WSL2+) in Windows 11 build 22631.3447 yesterday
  • Also, here is the file fongeo-error.log yesterday
  • @მამუკაჯიბლაძე Ah, you're using an older version of ConTeXt. I've updated the code to work with that. The older version is unfortunately considerably less efficient, so the first run took 30 minutes and 10GiB of RAM to process on my computer. Subsequent runs only take 45 seconds though, but with similar RAM usage. yesterday
  • Thanks a lot for your efforts! Now it runs, finishing in about 5 seconds in fact. But there is no output, should it generate some pdf or something?? yesterday

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .