Glyphviewer Documentation

What is Glyphviewer?

Glyphviewer is a web application that analyses web font files.

  • It lists the characters supported by a font using its glyphs. This is the raison d'être for the application.
  • It displays information present in the font's header, such as developer and license details.
  • It provides a test bed for users to enter their own message, and see it displayed using the font.

For those unsure about the meaning of "glyph", "font", and "web font", a small glossary is provided at the end.

Glyphviewer Usage

Glyphviewer analyses font files, not fonts per se. Computer fonts often consist of multiple files. There are several formats supported:

  • TrueType (.ttf)
  • OpenType (.otf)
  • Web Open Font Format (.woff). This is a font format designed for the web, as font data is compressed by default. Since this results in smaller font sizes, fonts are quicker to download.
  • Web Open Font Format 2 (.woff2), which manages even better compression (and thus even quicker download times). This has been available since 2018.

There are two places where font files can be hosted for analysis.

  • The default behavior for Glyphviewer is to analyse font files stored on the Local server hosting this application. When a user first encounters this page, the application randomly selects one from a particular directory on its file system, (specified below in "Installation and Dependencies"). Glyphviewer will analyse it and display resulting information to the user. Users can choose other font files stored locally, as long as Local is checked; they just select an item from the File drop down list. All fonts are listed by file name, so File will display (say) "DejaVuSans.woff" rather than "DejaVu Sans".
  • More adventurous users can choose a font somewhere else on the Internet by checking Remote instead. They write the full URL for the font file (including the extension) in the URL control.

Other controls present are:

  • Shows characters in font: If checked, all characters in the font are presented as a table to the user (with the exception of any line breaks and control characters present inside). The advantage is that users can discover which characters and languages are supported by the font. Moreover, people can inspect individual glyphs for legibility and appearance. The disadvantage is that the resulting page can be quite large.
  • Arrange characters as Unicode blocks: If checked, Glyphviewer splits characters into different tables according to their Unicode blocks. If not checked, all characters are displayed in one gigantic table. If Shows characters in font is not selected, this checkbox is ignored altogether.

To finish, users hit the Submit button.

On Success

If Glyphviewer succeeds, it will generate a page with the following sections.

  • General information: This data is taken from the font's header; it generally includes details such as name, designer, and copyright information. The last piece of data is extremely useful to know, as it may indicate whether the font is legally free to use or not.
  • Testbed: This provides an area where users can play around with the font. Fields of interest are:
    • Enter some text to try out the font: This is a multi-line field for changing the message (because "Hello World!" gets boring quickly).
    • Font size (in pixels): This sets the size of the message text in pixels. But to actually resize the text, one has to click...
    • Try it: This rewrites and redisplays the message.
    • Reset: This resets the message to the default text and size.
  • Supported characters: if Shows characters in font is selected, Glyphviewer will generate a table (or tables) of the characters provided by the font. For maximum utility, characters will be displayed using the actual glyphs in the font, and each character is displayed with its Unicode code point underneath. However, some fonts include characters such as the humble "NULL" (U+0000) which were never intended for display. Rather than writing them to the screen, Glyphviewer lists them instead.

On Failure

Glyphviewer will display an error message when it fails. There are several reasons for failure.

  • The URL cannot be resolved to some resource on the Internet.
  • The URL points to an actual resource on the Interwebs, but it's not a font file.
  • The URL points to a font file, but it is too "big". This limitation is deliberate. Imagine if some smartarse puts all 22MB of Arial Unicode MS on their web server, and directs Glyphviewer to analyse it. This would slow down this server. That's why the application refuses to read very large files.
  • The font is genuine, but essential information such as the header is missing. (This shouldn't happen, as it's against the specification).
  • The font is a symbol font, a relic from the days before Unicode. Glyphviewer will refuse to analyse it out of disgust.

Limitations

There are several limitations built into Glyphviewer.

  • Glyphviewer can only analyse OpenType, TrueType and Web Open Font Format 1 and 2 font files. Other font files such as Embedded OpenType (.eot) and Scalable Vector Graphics (.svg) cannot be handled by this application.
  • The application has a font size limitation built in of 3 MB.
  • The application will time out after 120 seconds when loading a font.
  • The application may be slow when analyzing a remote font, as the server has to access it to create a temporary copy.

Versions 0.3 and below of Glyphviewer could only show glyphs for characters from the Basic Multilingual Plane (U+0000 to U+FFFF). Characters out of this range were not displayed. Fortunately, this limitation has been removed from Glyphviewer as of version 0.4 (2016).

Earlier versions of Glyphviewer - 0.8 and below - had issues if the user attempted to analyse a font from a remote server whose Cross-origin Resource Sharing (CORS) policy refused resources to be served by third-party sites. Glyphviewer was able to analyse the font's header for information such as designer and copyright information. CORS didn't prevent a resource being accessed by its lonesome. The problem was when Glyphviewer - located on a particular server - tried to display the characters in the font when accessing it from a secondary, remote server. Many browsers - such as Chrome and Firefox - refused to display the characters using the font, and thus used some "fallback" font for that browser. Since this may have misled users as to the appearance of the font, Glyphviewer warned them about this situation. Fortunately, this limitation has been removed from Glyphviewer as of version 0.9 (2026).

Installation and Dependencies

If you have Python, the quickest way to install Glyphviewer (and its dependencies) is via the following command:

pip install glyphviewer

Setting up

Once installed, add "glyphviewer" to your INSTALLED_APPS list in settings.py, and add the desired URL in one of the urls.py files.

# urls.py
from django.urls import include, path

urlpatterns = [
    path("this_is_the_path_to_glyphviewer/", include("glyphviewer.urls")),
]

This provides three routes:

Path Name Role
…/ (index) Form and analysis
…/doc/ In-app documentation
…/font/ glyphviewer:font-proxy Same-origin serve of remote fonts

The font/ route is explained more in Remote fonts, the same-origin policy, and CORS below.

Adding local fonts (including symbolic links)

Glyphviewer’s Local dropdown lists every *.ttf, *.otf, *.woff, and *.woff2 file it finds in the {STATIC_ROOT}/glyphviewer/fonts/ directory. You can:

  • Copy any font files into that directory; or,
  • Add symbolic links that point at fonts stored elsewhere on the same file system. Fonts from other directories are not normally accessible by Glyphviewer, but it will follow symbolic links created in {STATIC_ROOT}/glyphviewer/fonts/ that lead to font files elsewhere on your machine.

Either way, your browser will list these fonts as coming from the {STATIC_URL}/glyphviewer/fonts/ folder.

Glyphviewer already comes with its own set of fonts from the Free UCS Outline Fonts. Those bundled fonts remain under their own GPL terms; the Glyphviewer application code is BSD-3-Clause. In production, they can be moved into the correct directory via:

python manage.py collectstatic

Remote fonts, the same-origin policy and CORS

Glyphviewer’s Remote text field allows the user to provide a full URL of a remote font. For earlier versions of Glyphviewer - 0.8 and before - the application could download remote fonts. It could even analyse them for their header information and the characters they supported. The problem was that the browser could not generally download the font to display it as it was designed.

The reason for this is that web browsers enforce the Same-origin policy: resources from one website are generally restricted from being used in another website unless Cross-Origin Resource Sharing is enabled on the source website.

Some websites, such as Google Fonts, are happy to share their fonts directly with others. When these files are downloaded, they are downloaded with these HTTP response headers that say CORS is permitted.

access-control-allow-origin: *

The asterisk means that requesting code from any origin can access the resource. So this means that you can embed the font in your site, and everyone is happy.

Not everyone has the budget that Google does. Some websites may use their own proprietary font that they spent a lot of money on. So when your website (or Glyphviewer 0.8 or before) tries to access it in the site, it will almost certainly not be sent with those access-control-allow-origin headers. That means CORS is not enabled, and the browser will refuse to display it as it was designed. Instead, the browser will use a fallback font for the user's browser and operating system instead; you are expecting Roboto, but it is displayed as Arial or Helvetica. Since this may mislead users as to the appearance of the font, Glyphviewer would then warn them about the situation.

(The Same-origin policy was originally intended for JavaScript; enforcement would reduce the number of malicious scripts executed on a webpage. But when Web fonts were introduced, the Same-origin policy also applied to fonts accessed by CSS @font-face rules in your webpages.)

Version 0.9 of Glyphviewer overcomes this limitation: it introduces a proxy for web fonts. The web page creates a same-origin URL that goes through Glyphviewer’s font proxy; to the browser, it appears that the font is local, and so CORS permits the font to be loaded. To give more detail:

  1. The user submits a remote font URL, using either the HTTP or HTTPS schemes;
  2. The index view sets fontpath to /this_is_the_path_to_glyphviewer/font/?url=<urlencoded-remote-url>;
  3. The HTML template’s @font-face refers to that same-origin URL; and,
  4. The font-proxy view - glyphviewer:font-proxy - downloads the remote file with fetch_remote_font() in font_fetch.py, and with an appropriate Content-Type. This could be font/woff2, font/woff, font/otf, or font/ttf.

Safety limits

All font fetches are capped by size (3 MB) and timeout (120s).

The proxy is not an open relay. Before fetching, validate_remote_font_url() rejects:

  • Schemes other than http / https;
  • URLs with embedded credentials;
  • Hostnames such as localhost, *.local, *.internal; and,
  • Private, loopback, link-local, and other non-public addresses.

Glyphviewer (as of version 0.9 and beyond) depends on the following software:

  • Python 3.x
  • Django 5.2 or later
  • The FontTools package (4.x or later) for parsing TrueType, OpenType, and WOFF files.
  • Numerical Python (numpy) 2.x or later, which is used by FontTools.
  • Brotli 1.x or later, a package which handles the compression algorithm used by WOFF2.
  • Chardet 7.x or later, the universal character encoding detector. Font header information is often stored in binary form, and chardet assists in picking the 'best' decoding for representing this information as a string.

Note: earlier versions of Glyphviewer depended on WoffTools, a package (built on top of FontTools) for parsing WOFF files. However, FontTools has WOFF support, and WoffTools has not been worked on for several years, so this dependency has been removed. Earlier versions of Glyphviewer also required Numerical Python (numpy) to be installed "by hand", since there were problems installing it with "pip". Fortunately, "pip install glyphviewer" will now provide all dependencies automatically.

Why Glyphviewer?

I created Glyphviewer as a tool to examine the character repertoire of web fonts. It is easy to find fonts online; it is harder to find out exactly what characters they support. Almost all contain standard capital letters like "A", "B" and "C", and that's not hard to discover, because those are among the first characters to be advertised by the foundries. It's harder to find out how much support a font has for more unusual characters like (say) "ŋ". One could install individual fonts on the computer, and inspect each in a tool like "Character Map", but this is laborious and time-wasting.

So I created a tool that could analyse a font if it was located somewhere on the World Wide Web. Font makers often display their fonts using web pages, and even provide a place where people can type text and see it displayed using the typeface. All one has to do to analyse it is examine the attached cascading stylesheet for a link to the font file, and place its URL in Glyphviewer.

This application was designed in response to and in reaction to Google Fonts, which came out in 2011. The idea is wonderful: tens of web fonts available for access and download. A laudatory effort - except that it didn't often accurately show the full repertoire of characters for each font. Take Lato - a lovely font, and comes in 10 variants too. Now look at the character set Google Web Fonts displays for it. At the time, I was frustrated that "Ł" and "ł" were not displayed, even though the font supports them, and even though the creator goes by the name of Łukasz Dziedzic. Now Google Fonts displays them, but it took Google a couple of years to lift their game.

Acknowledgements

The primary inspiration for this is Mark Pilgrim, who wrote a blog post called Fuck the foundries in 2009 (before yanking it off the net two years later). His essay and/or rant got me interested in web fonts in the first place, as did his use of the utterly superb web font Essays 1743 in Dive into HTML5. Thanks to John Stracke for coming up with the "Essays" typeface in the first place.

I also have to acknowledge the developers of the libraries used in the making of Glyphviewer. A special shout out goes to the folk at TypeSupply who decided to open-source their code for WoffTools. The project wouldn't have been possible without them. I must also acknowledge the Free UCS Outline Fonts project for providing the default fonts used in this application.

History

  • 0.1 (June 11th 2011) - Initial release.
  • 0.2 (June 28th 2013) - Added setup script to create a PyPI package. Removed bugs.
  • 0.3 (February 15th 2014) - Made compatible with Mezzanine and Bootstrap, changed styles for errors, now handles empty local directories.
  • 0.4 (January 16th 2016) - Now handles cases where remote fonts are inaccessible using CORS; removed the limitation that restricted characters to the BMP; added documentation for above.
  • 0.5 (March 31st 2017) - Updated to be compatible with Django 1.10. Now automatically install dependencies using pip.
  • 0.6 (March 18th 2018) - Add WOFF2 compatibility.
  • 0.7 (December 6th 2020) - Updated for Python 3 compatibility.
  • 0.8 (December 10th 2020) - Better representation of font header information as text; better use of urllib for Python 3.
  • 0.9 (September 25th 2026) - Same-origin remote-font proxy for preview (CORS bypass); ship glyph table / preview styles as package static CSS; add tests; migrate README to Markdown; clarify app license as BSD-3-Clause (bundled FreeFonts remain GPL); align copyright years and changelogs.

Glossary

Font
A file, or a set of files, that is used to specify the appearance of computer text. Common Windows fonts are "Times New Roman", "Arial" and "Courier New"; Mac OS X and Linux have their own equivalents. The "Times New Roman" font consists of 4 files: one for representing regular text, one for Bold text, one for Italic text and one for Bold Italic text.
Web font
A font that is designed to be downloaded with a web page only for the purpose of viewing it, and then discarded afterwards. Historically, most web designers assumed that users had a limited repertoire of fonts already installed on their machine, and would style accordingly. For example, it would be a safe bet to have either Helvetica or Arial on the viewer's computer, and if not, there would be some sort of sans-serif equivalent available instead. One problem with this is that it gets boring to see the same fonts all the time. So the W3C had a sit down with industry folk from Microsoft and Adobe and Mozilla and other companies, and worked out their own technology for embedding fonts on the fly.
Glyph
Glyphs are the shapes used to represent characters in a font. For example, the character "I" is (more or less) shaped like a horizontal line - in contrast to an "o" character, which resembles (roughly) a hollow circle. Terms like "more or less" and "roughly" are used here, because the same character would be generally represented by different glyphs in different fonts, and even within them. Continuing the example above, an "I" in an italic version of a font would be inclined relative to a regular version of "I", while an "I" in a serif font would have serifs coming out at the front and the bottom. In short, there are many ways to create a glyph for the same character.

Copyright © Peter Murphy 2011-2026. Application code BSD-3-Clause; bundled FreeFonts remain GPL.