User Tools

Site Tools


fonts_characters

Fonts and Unicode characters

List all characters in font

ttx

$ sudo apt install fonttools
$ ttx -t cmap -o - /usr/share/fonts/truetype/Arial/arial.ttf
Dumping "/usr/share/fonts/truetype/Arial/arial.ttf" to "-"...
Dumping 'cmap' table...
<?xml version="1.0" encoding="UTF-8"?>
<ttFont sfntVersion="\x00\x01\x00\x00" ttLibVersion="4.5">

  <cmap>
    <tableVersion version="0"/>
    <cmap_format_4 platformID="0" platEncID="3" language="0">
      <map code="0x20" name="space"/><!-- SPACE -->
      <map code="0x21" name="exclam"/><!-- EXCLAMATION MARK -->
      <map code="0x22" name="quotedbl"/><!-- QUOTATION MARK -->
      <map code="0x23" name="numbersign"/><!-- NUMBER SIGN -->
      ...
      <map code="0xfef8" name="afii62837"/><!-- ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM -->
      <map code="0xfef9" name="afii62838"/><!-- ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM -->
      <map code="0xfefa" name="afii62839"/><!-- ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW FINAL FORM -->
      <map code="0xfefb" name="afii62840"/><!-- ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM -->
      <map code="0xfefc" name="afii62841"/><!-- ARABIC LIGATURE LAM WITH ALEF FINAL FORM -->
      <map code="0xfffc" name="uniFFFC"/><!-- OBJECT REPLACEMENT CHARACTER -->
    </cmap_format_4>
  </cmap>
</ttFont>
$ ttx -t cmap -o - /usr/share/fonts/truetype/Arial/arial.ttf \
  | perl -C -ne '/ code="0x(.*?)"/ && printf "%04s %s\n", $1, chr(hex $1)'
Dumping "/usr/share/fonts/truetype/Arial/arial.ttf" to "-"...
Dumping 'cmap' table...
0020  
0021 !
0022 "
0023 #
0024 $
0025 %
0026 &
0027 '
0028 (
0029 )
...
fef4 ﻴ
fef5 ﻵ
fef6 ﻶ
fef7 ﻷ
fef8 ﻸ
fef9 ﻹ
fefa ﻺ
fefb ﻻ
fefc ﻼ
fffc 

otfinfo

# sudo apt install lcdf-typetools
# or on Mac
# brew install lcdf-typetools
$ otfinfo -u /usr/share/fonts/truetype/Arial/arial.ttf | head
uni0020 3 space
uni0021 4 exclam
uni0022 5 quotedbl
uni0023 6 numbersign
uni0024 7 dollar
...
uniFEF9 1017 afii62838
uniFEFA 1018 afii62839
uniFEFB 1019 afii62840
uniFEFC 1020 afii62841
uniFFFC 863 uniFFFC
uniFFFF 0 .notdef

Perl Font::FreeType

$ sudo apt install libfont-freetype-perl
$ perl -C -MFont::FreeType -e 'Font::FreeType->new->face(shift)->foreach_char( sub {
          $c=$_->char_code();  printf "%04X %s\n", $c, chr($c);
        } );'  /usr/share/fonts/truetype/Arial/arial.ttf
0020  
0021 !
0022 "
0023 #
0024 $
0025 %
0026 &
0027 '
...
FEFA ﻺ
FEFB ﻻ
FEFC ﻼ
FFFC 

List characters in file

View unicode codepoints for all letters in file on bash

file="some-file.txt"
perl -C -ne 'for (split //) {printf "U+%04X %s\n", ord, $_}' "$file" | sort -u
iconv -f utf8 -t utf32le "$file" | hexdump -v -e '"U+%04X\n"'        | sort -u
while IFS= read -d $'\000' -n 1 x; do printf 'U+%04X %s\n' "'$x" "$x"; done < "$file" | sort -u

List installed fonts having specific character

/docs/dokuwiki/data/pages/fonts_characters.txt · Last modified: 2022-09-27 17:09:36 by mi