Skip to content

Latest commit

 

History

History
174 lines (137 loc) · 7.29 KB

Fonts.md

File metadata and controls

174 lines (137 loc) · 7.29 KB

Fonts for Tesseract training

Tesseract training can use images made from text which was rendered with a list of fonts. Those fonts must be available on the host where the training process is running.

The fonts that were used to train 3.05's OCR engine and the legacy OCR engine in 4.0.0 are defined in training/language-specific.sh.

Many more fonts are listed in langdata/font_properties. If you add fonts to the first file (or specify them explicitly via command line parameter), you must add them to the second as well.

The fonts that were used to train the LSTM OCR engine in 4.0.0 are defined in <lang>/okfonts.txt files in the langdata_lstm repo.

Find Fonts

To find fonts already installed on your system which will render a given training text, you can use the following command (change the language code and directory locations to match your setup). fontslist.txt will provide text that can be used in training/language-specific.sh.

text2image --find_fonts \
--fonts_dir /usr/share/fonts \
--text ./langdata/eng/eng.training_text \
--min_coverage .9  \
--outputbase ./langdata/eng/eng \
|& grep raw \
 | sed -e 's/ :.*/@ \\/g' \
 | sed -e "s/^/  '/" \
 | sed -e "s/@/'/g" >./langdata/eng/fontslist.txt

The above will not work for Fraktur fonts, it will identify all Latin fonts also. Review the generated images and choose appropriate fonts.

Font installation

Debian

On Debian GNU Linux and similar distributions (Linux Mint, Ubuntu, ...), the required fonts can be installed like that:

# AMHARIC_FONTS (todo)
# ANCIENT_GREEK_FONTS (todo)
# ARABIC_FONTS (todo)
# ARMENIAN_FONTS (todo)
# BENGALI_FONTS (todo)
# BURMESE_FONTS (todo)
# CHI_SIM_FONTS (todo)
# CHI_TRA_FONTS (todo)

# DEVANAGARI_FONTS (see also external links below)
apt-get install fonts-deva

# EARLY_LATIN_FONTS (todo)
# FRAKTUR_FONTS (todo)
# GEORGIAN_FONTS (todo)
# GREEK_FONTS (todo)
# GUJARATI_FONTS (todo)
# HEBREW_FONTS (todo)

# JPN_FONTS (todo)
apt-get install fonts-noto-cjk fonts-japanese-mincho.ttf fonts-takao-gothic fonts-vlgothic

# KANNADA_FONTS (todo)
# KHMER_FONTS (todo)
# KOREAN_FONTS (todo)
# KURDISH_FONTS (todo)
# KYRGYZ_FONTS (todo)
# LAOTHIAN_FONTS (todo)

# LATIN_FONTS
apt-get install fonts-dejavu gsfonts ttf-mscorefonts-installer

# MALAYALAM_FONTS (todo)

# NEOLATIN_FONTS (still incomplete)
apt-get install fonts-ebgaramond fonts-gfs-didot fonts-gfs-didot-classic fonts-junicode

# NORTH_AMERICAN_ABORIGINAL_FONTS (todo)
# OLD_GEORGIAN_FONTS (todo)
# ORIYA_FONTS (todo)
# PERSIAN_FONTS (todo)
# PUNJABI_FONTS (todo)
# RUSSIAN_FONTS (todo)
# SINHALA_FONTS (todo)
# SYRIAC_FONTS (todo)
# TAMIL_FONTS (todo)
# TELUGU_FONTS (todo)
# THAANA_FONTS (todo)
# THAI_FONTS (todo)
# TIBETAN_FONTS (todo)
# VERTICAL_FONTS (todo)
# VIETNAMESE_FONTS (todo)

The installed fonts are shown by the command fc-list. See also the Debian wiki.

text2image --fonts_dir /usr/share/fonts --list_available_fonts will also show all fonts.

Links

Sources of (mostly free) fonts

Fonts which cover many scripts

Latin Fonts

Arabic Fonts

Devanagari Fonts

Fraktur Fonts

Hebrew Fonts

Collections of fonts

More information on fonts