Opentype glyphs, unicode and encoding

telex's picture

Hello everyone.

I'm making a PHP application to generate text labels. The PHP libraries seem to don't support OpenType features.
Now I have no problem working with unicode index to display the standard characters.
But, as far as I know, the OpenType features are name based.
For example: if I want to display a ligature «my» I have to replace «m» and «y» unicodes indexes by «my» unicode index.
The problem now is I don't have unicode indexes on this characters and I can't reffer to them by their names.

The questions are:

Is there any existing unicode for these glyphs and I am missing them?
Do I need to reencode all the glyphs?
Which is the best way to reencode a font and/or generate unicode names for this purposes?
Is there any standard?

I also noted, when I reencode an existing font with many glyphs and generate a new version the file size increases almost ten times.

Your help and contributions will be appreciated.

Thanks in advance.

oldnick's picture

OK, I'm going to go out on a limb, since no one else has bothered to answer.

AFIK, you can assign unicode numbers to your special characters in the Private Use area. However, you should be aware that some folks have already staked out niches in that territory...

but you ought to be able to find some unclaimed slots to code your characters so your script will work.

Frode Bo Helland's picture

If you generate images, Nick's suggestion is good. If you want to create selectable, searchable, degradeable text you might want to do some javascript thing similar to what I'm working on at the moment. PM me if you're interested.

telex's picture


Actually what i'm trying to do is to get the special characters unicode for any font. Because it depends on the encoding of the font I'm trying to figure out the more quick and simple method to do it.
For example, I want to use a font with ligatures and stylistic alternates for image generation. I'm not sure if there is a way to reffer to the unicode from scratch, i think it strictly depends on how the unicodes were asigned to this font. If there is no unicode for the special characters (ligatures, alternates, small caps, etc), how should I reencode / reassign the unicode numbers in Fontlab avoiding doing it one by one? Is there any way to assign them in one movement?

I tried to generate Unicode for a few fonts with many special characters. I realized if I use a standard table it seems to work, but many special characters are missing and it repeats one of the characters many times in a weird way.

Last week I could reencode one of this fonts and it worked ok, with unicodes for every glyph and it worked ok. For some reason I have no idea what I did then and I can't repeat the same process. I thought I generated unicode with a Standard Table, but now i'm trying to do it again and it doesn't work.

Also, and for now, i really don't care which unicodes I have in each special character, because it is for personal and private use and I don't need to distribute the font. I'm only worried to make it work in my image generator.


For now, what i'm trying to do is to generate images. Are you working on something similar to Cufon or SIFR?


telex's picture

I think the answer I need is:

How to assign Private User Area unicodes to all the swashes, alternates and ligatures?

oldnick's picture

How to assign Private User Area unicodes to all the swashes, alternates and ligatures?

Here's what I did; I'm not sure that it's the approved method, but it has worked for me so far.

In Program Files > Common Files > FontLab > Mapping, I opened the file standard.nam in NotePad+ and saved it as standard_old.nam. I then made a few changes to the file, following this format...

0xF### glyphname

then saved the file as standard.nam.

Then, in FontLab, I made sure that under Tools > Options > Unicode and OpenType > Default Unicode-Name mapping table, I selected Standard Table.

Finally, in order to generate my new "standard" Unicode, after I have composed all my glyphs and named them according to MY standard, I select Glyph > Glyph Names > Generate Unicode. Finally, just for good housekeeping, I select Index Mode, Select All glyphs, sort them by Unicode, then select Charmap View.

As I said, I don't know if this method is kosher/halal, but it works for me,

Frode Bo Helland's picture

No, @font-face.

telex's picture

I made an experiment:

I created a Robofab script that assign an unicode to every character without unicode index.
It checks every glyph, if it doesn't have unicode the script will assign a new PUA value, starting from E000 (57344) and increasing by one for every glyph.
I generated an Opentype/PS version and it works with my image generator.
I'm not sure if this is extremely unortodox or if it will take me to new problems.
I tried it and it works. I assume there is no problem with these unicodes until I try to use it in other systems.

Nick: Thank you for your solution for the Standard Table edition. I didn't try it yet.
Also, if you want the script I made, just let me know.

telex's picture

A different way to do it:

In font window select "Names mode" and "OpenType Standard"
Glyph > Glyph Names > Generate Unicode
And then "Standard Table" + "Try to keep Unicode indexes" + "Assign PUA indexes to unencoded Glyphs"

I was missing to change to «Names mode» in the Font Window. Once I do it it seems to work when I reencode and generate unicode, it adds PUA indexes.

oldnick's picture

One unmentioned advantage to the Standard Table workaround is that the PUA Unicode values for each special character or ligature will be consistent across the fonts you generate using it...

Syndicate content Syndicate content