Generation of OpenType fonts for Ancient Egyptian hieroglyphic text
Use of the code here is appropriate under the following circumstances:
There is a relatively stable set of documents with (Unicode) encoding of Ancient Egyptian hieroglyphic text.
The documents explicitly activate a named OpenType font for the occurrences of fragments of Ancient Egyptian.
The reason why a stable set of documents is a requirement is that the font will not be able to handle anything that does not occur in the given documents. For every added fragment, the font needs to be recreated.
Different kinds of use
Use on the web
One can create one or more webpages that include fragments of Ancient Egyptian, using CSS to select a font for these fragments. By running a script on these webpages, the required font is created.
At this time, not all browsers may realize the kinds of OpenType liga features that the created fonts use.
LibreOffice and Word
This is left for future development. This should work in principle, as long as one can obtain a text file that has fragments of hieroglyphic as substrings. The most suitable format seems "Flat XML ODF".
These instructions assume Linux.
FontForge is used to create composite glyphs. On Debian-based Linux it is installed by:
apt-get install fontforge apt-get install python-fontforge
On Fedora, it would reportedly just be:
yum install fontforge
Python and AFDKO
It should be possible to run this code with just Python3.
On some distributions however, FontForge is not yet available for Python3, in
which case Python2 should be used to run
The Python scripts call
makeotf from the command-line, which is part of AFDKO.
Assuming Python and pip are already installed, then commands to install the necessary Python packages would typically be:
pip install -U ply pip install -U Pillow pip install -U afdko
On your platform, python2 and python3 may be called differently. If so, edit
the first line of
Adding a new font
One TTF font,
NewGardinerSMP.ttf, is available in the directory:
This is the default font.
To add another TTF font, say
MyFont.ttf, put it in the same directory,
analyze_font -f MyFont
This analyzes the font, and puts the result of this analysis in a
in the same directory.
A suitable font should have the following requirements:
It should contain glyphs for all hieroglyphs from
0x1342eand for the control characters from
The glyphs should rest on the baseline.
Creating a font for a number of documents
To create a font for a collection of files
file2, ..., containing fragments of
hieroglyphic encoding, which would typically be .html or .txt files, do:
create_font -o OutFont file1 file2 ...
OutFont.otf will be put in the directory from where
To use a custom font, say
MyFont.ttf, rather than the default font, do:
create_font -f MyFont -o OutFont file1 file2 ...
By adding the
-c flag, one ensures that the created font includes every
hieroglyph. In this way, each fragment of hieroglyphic encoding in every document
is visible if viewed with that font, even though some groups may not be properly formatted.
create_font -o OutFont -c file1 file2 ...
An image can be created from a fragment by:
create_image -f MyFont -s fontsize -o MyImage MyHieroglyphicEncoding
If omitted, the default font is
If omitted, the default fontsize is 20.
The hieroglyphic encoding may contain HTML entities for hieroglyphs and
control characters, which are replaced by characters.
A number of example input files are provided in directory:
This includes an OpenType font that was generated with the tools presented here. Two HTML files can be viewed with a browser.
The following are examples of what can be run from the command-line with the provided files:
analyze_font analyze_font -f NewGardinerSMP create_font -o tests/new tests/hieropage.html tests/hierotestsuite.html create_font -f NewGardinerSMP -o tests/new -c tests/hierotestsuite.html create_image -o myimage.jpg "𓐍𓐱𓐍𓐰𓐍"
One can call
create_font from another directory, e.g.:
cd tests ../create_font -o new hieropage.html hierotestsuite.html
../create_font -f NewGardinerSMP -o new hieropage.html hierotestsuite.html
This creates a font
new.otf in the