Display all font file characters

fonts, javascript, jquery, php

Solution

Fonts can map a wide range of Unicode characters, using codes from 0 to 0x10FFFF. Thus if you really want to see everything in any random font, doing it in a loop as has been suggested in other answers is really going to be problematic. Even for the "simple" example of Arial, the lowest mapped character is U+0020 and the highest is U+FB02. Not everything in that range is mapped, however, so if you did that in a loop you'd end up with a lot of empties. Not to mention it would likely be pretty slow.

To do what you want effectively, you're going to need something to crack open the font file, examine the cmap table, and get a list of mapped characters (not a range). I'm not sure what your setup is, but you could probably do this server-side with something like FreeType or some such.

Problem

I'm wondering if there is a way to display all font file characters using HTML/CSS/JS/PHP? Let's say I would like to display all possible "Arial" characters. Or characters from custom @font-face font.

Original source