% Manual for margazhi.sty.  Compile with pdflatex (margazhi.sty and
% kolam-tikz.sty next to this file or installed).
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[margin=2.5cm]{geometry}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{array}
\usepackage{margazhi}
\usepackage[hidelinks]{hyperref}
\newcommand\pkg[1]{\textsf{#1}}
\newcommand\cmd[1]{\texttt{\textbackslash #1}}
\newcommand\meta[1]{\ensuremath{\langle}\textit{#1}\ensuremath{\rangle}}
\newcommand\marg[1]{\texttt{\{}\meta{#1}\texttt{\}}}
\newcommand\oarg[1]{\texttt{[}\meta{#1}\texttt{]}}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.6em}
\title{\margazhi[height=2.2em]{MARGAZHI}\\[1em] The \pkg{margazhi} package}
\author{Aalok Thakkar}
\date{Version 2.000, 2026/11/30}
\begin{document}
\maketitle

\pkg{margazhi} draws the letters of Margazhi, a kolam typeface, with TikZ.
Each letter is a pulli kolam: a strand loops around a grid of dots (pulli),
and the enclosed channels of capital letters are filled. The package draws
the letters in any colours and at any height, with pdf\LaTeX, Lua\LaTeX\ and
Xe\LaTeX. It needs the \pkg{kolam-tikz} package
(\url{https://github.com/aalok-thakkar/kolam-tikz}).

The same glyphs are available as installable fonts (Margazhi, Margazhi Color
and Margazhi Color Light, in Regular and Bold) from
\url{https://github.com/aalok-thakkar/margazhi}; see
Section~\ref{sec:fonts}.

\section{Letters}

\begin{verbatim}
\usepackage{margazhi}
...
\margazhi{MARGAZHI margazhi}
\end{verbatim}

\margazhi[height=1.6em]{MARGAZHI margazhi}

\cmd{margazhi}\oarg{keys}\marg{text} draws \meta{text}. Capitals A--Z are
filled; lowercase a--z are outlines. A space leaves the width of four pulli.
Characters without a glyph are skipped with a warning. The letters sit on the
baseline, so \cmd{margazhi} can be used inside a paragraph:
the word \margazhi{KOLAM} at the default height of 1em.

\section{Designs}

Twelve geometric designs sit on the number row. The plain key gives the
outline and the same key with Shift (US layout) gives the filled design. In
\cmd{margazhi}, put a backslash before \verb|#|, \verb|$|, \verb|%|, \verb|&|
and \verb|_|, as in \verb|\margazhi{4\$}|.
\cmd{margazhidesign}\marg{n} draws design \meta{n} (1--12) as an outline and
\cmd{margazhidesign*}\marg{n} draws it filled.

\begin{center}
\renewcommand\arraystretch{1.25}
\begin{tabular}{>{\ttfamily}c >{\ttfamily}c c c l}
\toprule
\rmfamily Outline & \rmfamily Filled & & & \\
\midrule
1 & ! & \margazhidesign{1} & \margazhidesign*{1} & small square \\
2 & @ & \margazhidesign{2} & \margazhidesign*{2} & small diamond \\
3 & \# & \margazhidesign{3} & \margazhidesign*{3} & twin diamonds \\
4 & \$ & \margazhidesign{4} & \margazhidesign*{4} & flower of four diamonds \\
5 & \% & \margazhidesign{5} & \margazhidesign*{5} & triangle \\
6 & \textasciicircum & \margazhidesign{6} & \margazhidesign*{6} & flower with a filled centre \\
7 & \& & \margazhidesign{7} & \margazhidesign*{7} & star \\
8 & * & \margazhidesign{8} & \margazhidesign*{8} & diamond ring \\
9 & ( & \margazhidesign{9} & \margazhidesign*{9} & three diamonds \\
0 & ) & \margazhidesign{10} & \margazhidesign*{10} & diamond with four loose pulli \\
- & \_ & \margazhidesign{11} & \margazhidesign*{11} & square in a diamond ring \\
= & + & \margazhidesign{12} & \margazhidesign*{12} & two diamonds stacked \\
\bottomrule
\end{tabular}
\end{center}

\section{Keys}

Both commands take keys in their optional argument;
\cmd{margazhisetup}\marg{keys} sets them for the rest of the group.

\begin{center}
\begin{tabular}{l p{0.62\textwidth}}
\toprule
Key & Meaning \\
\midrule
\texttt{ink=}\meta{colour} & strands and pulli; default the current text colour \\
\texttt{face=}\meta{colour} & filled channels; default \texttt{margazhired} (\#A43C0E) \\
\texttt{height=}\meta{length} & height of a letter's box; default 1em \\
\texttt{regular} & strands 1.5pt wide, as in Margazhi Regular (default) \\
\texttt{bold} & strands 2.5pt wide, as in Margazhi Bold \\
\texttt{line width=}\meta{length} & any strand width, measured before scaling to \texttt{height} \\
\bottomrule
\end{tabular}
\end{center}

\begin{verbatim}
\margazhi[bold,height=2em]{MARGAZHI}
\margazhi[ink=blue!60!black,face=orange]{KOLAM}
\end{verbatim}

\margazhi[bold,height=2em]{MARGAZHI}\par
\margazhi[height=1.6em,ink=blue!60!black,face=orange]{KOLAM}

The ground is left transparent. For the white strands on earth brown of
Margazhi Color, put the letters in a coloured box:

\begin{verbatim}
\definecolor{margazhiground}{HTML}{3B2A20}
\colorbox{margazhiground}{\margazhi[ink=white,height=2em]{TIRUPPAVAI}}
\end{verbatim}

\definecolor{margazhiground}{HTML}{3B2A20}
\colorbox{margazhiground}{\margazhi[ink=white,height=2em]{TIRUPPAVAI}}

\section{Engines and memory}

Each letter is drawn once for every combination of ink, face and line width
and then reused as a PDF form object, so long texts compile quickly.
pdf\LaTeX\ and Lua\LaTeX\ handle any amount of text. Xe\LaTeX\ keeps every new
letter, colour and weight in memory until its page is shipped out, so a page
with more than about 25 of them stops with ``TeX capacity exceeded''. Run
Xe\LaTeX\ with more memory in that case:

\begin{verbatim}
extra_mem_bot=30000000 xelatex file.tex
\end{verbatim}

\section{The fonts}
\label{sec:fonts}

With Lua\LaTeX\ or Xe\LaTeX, the installed fonts can be used through
\pkg{fontspec}. \texttt{HyphenChar=None} stops \TeX\ from hyphenating words
set in Margazhi: the font has no hyphen, and the \texttt{-} key is a design.

\begin{verbatim}
\usepackage{fontspec}
\newfontfamily\margazhifont{Margazhi}[HyphenChar=None]
{\margazhifont MARGAZHI margazhi} {\margazhifont\bfseries MARGAZHI}
\end{verbatim}

Lua\LaTeX\ shows the colour fonts in colour when the \texttt{colr} feature is
turned on:

\begin{verbatim}
\newfontfamily\margazhicolor{Margazhi Color}[HyphenChar=None,RawFeature=+colr]
\end{verbatim}

\section{License}

\pkg{margazhi} is distributed under the MIT License. The Margazhi fonts are
under the SIL Open Font License 1.1. Copyright 2026 Aalok Thakkar.

\end{document}
