otrego / go-type1

LaTeX fonts for professional-quality diagrams for the board game Go (Baduk, WeiQi)
Apache License 2.0
37 stars 4 forks source link

Go-Type1: Go Postscript Type1 Fonts for LaTeX

Go Type1 Demo

Go-type1 contains vector-graphics fonts for creating professional-quality books for the board game <a href="https://en.wikipedia.org/wiki/Go_(game)">Go, also known as Igo (囲碁), Baduk (바둑), Weiqi (围棋), for use in LaTeX typesetting system. The fonts are all provided as PostScript Type1 fonts rather than rasterized (bitmap) fonts, and so provide high resolutions for e-books and print books.

Table of Contents

Overview

In summary, this repository contains TeX font information for four fonts:

Note: This repository, Go-Type1, was original created by Kashomon in 2014 but was moved to the Otrego Organization in 2020.

All of these fonts are available as Postscript Type 1 fonts, which is an old vector graphic font standard that can be used with LaTeX.

This work derives from Vit Brunner (tasuki) who created a series of tsumego books using the Type1 Gooe font. Later, this work was helped tremendously by the existence of Nyamcoder's instructions for installing the Type1 Igo font. Ultimately, these fonts exist to be used in GPub, a Javascript library I (Kashomon) created for generating Go books.

These packages are designed to work with LaTeX, but there's no reason it shouldn't work with a LaTeX compatible compiler like XeTeX.

Recommendations

If you're here trying to decide what fonts to use in generating Go books then here are my recommendations:

  1. If you are planning on creating or using scripts to generate your books:

    1. Gnos (Recommended): Fully featured; Looks great in print form.
    2. Gooe: Fully featured, has a less bold-look than Gnos.
  2. If you are manually creating diagrams yourself only using LaTeX:

    1. Igo: Igo is meant for users creating diagrams manually at LaTeX, and is much terser than Gnos or Gooe. However, it comes at the cost of having fewer glyphs, being slow to compile, and having incompatibilities with other LaTeX packages.

Installation

On OSX, and Linux the easiest way to install is to use the installer script:

# Install gooe, gnos, igo
go-type1/installer.sh install all

# Install just gnos
go-type1/installer.sh install gnos

Examples

You can findthese examples in examples/full_comparison.tex and the rendered examples/full_comparison.pdf

Gnos Examples

As mentioned above, Gnos is the recommend font. Here's a simple Tsumego problem using the Gnos font:

\begin{center}
{\gnos%
<((!((((((\\
!!!!@@++++\\
\char91\char64@@++++++\\
\char91\char43\char43\char42+++++*\\
\char91@++++++++\\
\char91+++++++++\\
}
A Simple Go Problem!
\end{center}

Gnos Example

Here's a demo of all the symbols supported by Gnos:

{
\gnosfontsize{14}
{
\gnos%
<!((((((@((!(((((!>\\
!+1Cc2Ss3Tt4Xx++++!\\
\char91+@+++++++++++++++]\\
\char91+@*+++++*+++++*++]\\}
{\gnosb\char1\char2\char3\char4\char5\char6\char7\char8\char9\char10\char11\char12\char13\char14\char15\char16\char17\char18}{\gnos]\\}
{\gnosw\char1\char2\char3\char4\char5\char6\char7\char8\char9\char10\char11\char12\char13\char14\char15\char16\char17\char18}{\gnos]\\
\char91+++++++++++++++++]\\
\char91+++++++++++++++++]\\
\char91+++++++++++++++++]\\
\char91++*+++++*+++++*++]\\
\char91+++++++++++++++++]\\
\char91+++++++++++++++++]\\
\char91+++++++++++++++++]\\
\char91+++++++++++++++++]\\
\char91+++++++++++++++++]\\
\char91++*{\gnoswi\char11}{\gnoswii\char11}{\gnoswiii\char11}{\gnosbi\char11}{\gnosbii\char11}{\gnosbiii\char11}+++++*++]\\
\char91++++{\gnoswl\char1}{\gnosbl\char1}++++++\gnosEmptyLbl{\sffamily{10}}\gnosOverlap{!}{Z}\gnosOverlap{+}{\gnos 2}\gnosOverlap{@}{\color{white}Z}+]\\
!++++++++\gnosOverlap{+}{\gnos 3}\gnosOverlap{+}{\gnos 4}\gnosOverlap{+}{\gnos 1}++++++!\\
,!))))@)!))))))))!.\\
}}
14pt: A board full of stuff!

Gnos Example: Full Symbol Set

For a full table of all the Gnos symbols, see examples/gnos_font_mapping.pdf

Gooe Examples

Here's an example of a simple problem using the Gooe font.

\begin{center}
{\goo
\0??<\0??(\0??(\- !(\0??(\0??(\0??(\0??(\0??(\0??(
\- ![\- !+\- !+\- !+\- @+\- @+\0??+\0??+\0??+\0??+
\0??[\- @+\- @+\- @+\0??+\0??+\0??+\0??+\0??+\0??+
\0??[\0??+\0??+\0??*\0??+\0??+\0??+\0??+\0??+\0??*
\0??[\- @+\0??+\0??+\0??+\0??+\0??+\0??+\0?l+\0??+
\0??[\0??+\0??+\0??+\0??+\0??+\0??+\0??+\0??+\0??+
}
A Simple Go Problem!
\end{center}

Gooe Example

Igo Examples

Here's the same problem with the Igo font.

\white{a18,b18,c18,d18,d19}
\black{b17,c17,d17,e18,f18,b15}
\begin{center}
\shortstack{\showgoban[a14,k19]\\ A Simple Go Problem}
\end{center}

Igo Example

Using Gnos in LaTeX

This section will walk you through how to get started with Gnos in LaTeX.

\usepackage[T1]{fontenc}

Then, LaTeX should be able use the new Type1 fonts.

See the example below for more information. Ther are also more exmaple TeX files in the examples/ directory.

The LaTeX structure

LaTeX starts with some header declarations, followed by begin document, content, and lastly, ending the document.

\documentclass{article}
\usepackage{gnos} % or igo, gooemacs
\usepackage[T1]{fontenc}

\begin{document}

% Content goes here

\end{document}

Gnos Tips

Gnos fonts suffer from wrapping problems: it's very easy to get the fonts misaligned and end up with bad-looking diagrams. The easiest solution is to wrap your diagrams in a LaTeX minipage, which is how the diagram at the top of the page was created:

\begin{center}
\section*{Go Type-1 Fonts}
\vspace{12pt}
\begin{minipage}[t]{240pt}
\gnosfontsize{12}
{\gnos%
<(((((((((((((((((>\\
\char91+++++++++++@\gnosOverlap{@}{\color{white}\footnotesize{45}}\gnosOverlap{@}{\color{white}\footnotesize{47}}+++]\\
\char91++!+@+++!@@!!\gnosOverlap{!}{\footnotesize{46}}!@+]\\
\char91++*!@+!+!@!++@*@+]\\
\char91+@+!@+@+@!!++++++]\\
\char91+++!!@@+@++++++++]\\
\char91+++++!+++++++++++]\\
\char91+@+++++++++++++++]\\
\char91+++++++++++++++!+]\\
\char91++*+++++*+++++*++]\\
\char91+++++++++++++++++]\\
\char91+++++++++++++++++]\\
\char91++++++++++++++!++]\\
\char91+!+++++++++++@!!+]\\
\char91++++++++++++++!@+]\\
\char91++*+++++*++++@*@+]\\
\char91++!+++++++++++@++]\\
\char91+++++++++++++++++]\\
,))))))))))))))))).\\
}
\centerline{\textit{\textbf{Diagram 23}}}
\subtext{(Moves: 45-47)}
\end{minipage}
\end{center}

Go Type1 Demo

Writing a Book

Making a professional-quality book with LaTeX takes quite a bit more work than just creating diagrams. In general, professional-grade books need to be PDF/X-1a:2001 compatible, which imposes several technical requirements on the construction of PDF documents. Additionally, you will want to refine the look and feel of the frontmatter, page layout, and page size.

I highly recommend taking a look at:

You can see a prototype used for Relentless in book-example/ that was created with GPub.

Font Deep Dive

If are interested in the nitty-gritty details of the fonts or you want to make your own modifications, this section should provide some helpful background.

What's here

There are four directories containing font files:

gnos-fonts/
gooe-fonts/
igo-fonts/
jigo-fonts/ (Experimental)

In each of these, there are 4 types of files of interest:

Tex and Tex Distributions

Installation of these fonts relies heavily on your particular distribution of TeX. You'll be installing the font files in TEXMFHOME location. Assuming you've installed TeX, you can find the location of your TEX directories with:

kpsewhich -expand-var "\$TEXMFHOME"

or

$(kpsewhich -var-value TEXMFHOME)

Long Installation Steps

This is not recommended for most users, but this is a record of what I did install the fonts by hand initially if you get stuck.

cd go-type1
texhome=$(kpsewhich -var-value TEXMFHOME)
echo $texhome   # Should be non empty
mkdir -p $texhome/tex/latex/gooe
mkdir -p $texhome/fonts/map/dvips/gooe
mkdir -p $texhome/fonts/type1/gooe
mkdir -p $texhome/fonts/tfm/gooe
cp gooe-fonts/gooemacs.sty $texhome/tex/latex/gooe
cp gooe-fonts/gooe.map $texhome/fonts/map/dvips/gooe
cp gooe-fonts/*.pfb $texhome/fonts/type1/gooe
cp gooe-fonts/*.tfm $texhome/fonts/tfm/gooe
texhash $texhome
updmap --enable Map=gooe.map

Converting METAFONT to Type1

Converting from METAFONT to Type1 fonts can be a challenge. Here's what I did, mostly a record for myself, but it might be useful for you too.

First, some setup:

To convert METAFONT to Type1, run:

mftrace --formats=PFB myfile.mf

To regenerate the TFM files, run:

mktextfm myfile.mf

Resources

For more details on all of this, see: