Generating a Unicode Chart per Font

ishamid's picture

Dear typophiles,

Does there exist any available application or tool for generating a pdf (or jpg or png or...) unicode code chart? For example, input a range (say, start=0600,stop=06FF) and a font name: Then the resultant pdf gives you a unicode code chart covering that range (as supported by the named font), with the code point as caption per each cell...

Anything like that available? Perhaps an online utility? Seems like a common enough task that a utility may be floating out there somewhere...

Thanks in advance!

Michel Boyer's picture

The AFDKO command tx gives you charts and if you use the -g option with a list of characters, you can get the chart for those glyphs. However tx does not appear to accept a unicode range. On the Mac or on Linux you can however easily generate the list of character names if you have the FontForge python class installed. Here is a script that does that. Let us call it listcharnames

---- cut line
#!/usr/bin/env python

import fontforge,sys
fnt=fontforge.open(sys.argv[1],1)

start = int(sys.argv[2],16)
end=int(sys.argv[3],16)

unilist=[g.unicode for g in fnt.glyphs() \
    if ((g.unicode <= end) and (g.unicode >= start))]
unilist.sort()
print ','.join(fnt[u].glyphname for u in unilist)
---

Then you can also give yourself the command mkchart

--- cut line
#!/bin/sh
tx -pdf -g `listcharnames $1 $2 $3` $1
---

and to get your chart say for Arno Pro for the hex values between 0x0060 and 0xFFFF, you need only type

mkchart ArnoPro-Regular.otf 0060 FFFF > ~/sheet.pdf

and you get your sheet (to get it on the desktop on the mac, you rather redirect to ~/Desktop/sheet.pdf)

Here the sheet I get with

mkchart ArnoPro-Regular.otf 0060 00AF > ~/sheet.pdf

Karl Stange's picture

FontExplorer X Pro has a nice feature that allows you to create font books in this way. You can specify the Unicode table(s), the number of characters per row, whether to include HTML and Keystroke info, text previews and a variety of metadata information.

Michel Boyer's picture

[deleted]

ishamid's picture

Hi Michel, Karl,
Thanks for the tips; *much* appreciated!

I downloaded the latest AFDKO, but it seems broken:

http://www.typophile.com/node/116997

Once I get it working I'll try to build a chart (not sure if I can get the FF python class working on Win though).

As for FontExplorer X Pro, I can view the character info under "Characters" in the Information dialog, but there is no way to export that to a file with or without the specifications you mentioned (yes, most of those specs are available for preview). The only one seems to be able to export is the basic preview on the main page. Any advice would be appreciated...

Thanks!

Michel Boyer's picture

I can't help with AFDKO on Windows. I am on Macs.

On the other hand, if you have problems with FontForge, here is some replacement code for listcharnames written in Lua for LuaTeX. That avoids having to install the Fontforge python module but I think LuaTeX uses some Fontforge code anyway. If you have tex live installed, this should run.

--- cut here
#!/usr/bin/env luatex --luaonly

local f = fontloader.open(arg[1])
local startcode=tonumber(arg[2])
local endcode = tonumber(arg[3])
local listcodes={}
local i = 0
while (i < f.glyphmax) do
  local g = f.glyphs[i]
  if g then
    if ((g.unicode >= startcode) and (g.unicode <= endcode)) then
      listcodes[g.unicode] = g.name
    end
  end
  i = i + 1
end
local keys={}
for n in pairs(listcodes) do table.insert(keys,n) end
table.sort(keys)
local names={}
for i,n in ipairs(keys) do table.insert(names,listcodes[n]) end
print(table.concat(names,","))
fontloader.close(f)
---

Here is a trace of execution on my mac: the hex interval needs to by written with 0x...

% listcharnames texgyrecursor-bold.otf 0x050 0x060
P,Q,R,S,T,U,V,W,X,Y,Z,bracketleft,backslash,bracketright,asciicircum,underscore,grave
% 

On windows, unless you are running cygwin, my scripts would not work as is and the previous call would become

luatex  --luaonly listcharnames texgyrecursor-bold.otf 0x050 0x060

That gives as output the list to be used with tx -g

I dont' find that Lua code very elegant compared to the Python script but I am not experienced enough in Lua to improve.

Incidently, should it not be possible to generate the desired chart directly with LuaTeX or LuaLaTeX?

Michel

Karl Stange's picture

Idris, you need to choose the font or fonts and then go to Print them. That brings up the dialogue box I described.

ishamid's picture

Ah, thanks so much for the lua script, Michel!

Just tested it and it does indeed work, so as soon as we can figure out what's wrong with AFDKO I should be back in business.

In ConTeXt (based on luaTeX) there is a command \showfont[fontname][all] that prints out charts, but it currently skips some characters in the font I'm working on (no idea why). I could probably design my own, but I don't have the skill to design a chart macro quickly and no longer have the time these days to spend hours working on TeX macro-programming. In ConTeXt, it would probably be more efficient to write a fontchart module in lua anyway, and that's definitely beyond my skill set.

Thanks again!

ishamid's picture

Hi Karl,

http://www.fontexplorerx.com/macfeatures/
http://www.fontexplorerx.com/winfeatures/

I just checked, the "Create Fontbooks by template" functionality seems to be Mac-only; I can find no "Print" function in the Windows version.

If I sent you the font privately, could you try it?

Thanks again!

Karl Stange's picture

Idris, I have sent you an email through the site, respond to that and I will send you some samples.

ishamid's picture

Thanks, Khaled! I'll check that out as well, although it seems to be Linux-only...

ishamid's picture

Almost by accident I came across a wonderful utility for Windows -- by the Unicode Consortium itself! - that handles the task of generating Unicode code-point charts: UniBook:

http://www.unicode.org/unibook/

http://unicode.org/unibook/help/unibook.htm

It creates charts using the same template as the standard unicode charts, choose your font, and has lots of options and features, including printing to pdf if you have a pdf printer or Adobe Acrobat installed. Still exploring its possibilities.

Surprised this one isn't better known. Thank you all for your responses, and especially Karl Strange for all of his help!

Syndicate content Syndicate content