[cairo] User fonts -> PDF questions

Ian Britten britten at caris.com
Mon Dec 15 11:29:11 PST 2008


Adrian Johnson wrote:

>> 1) When selecting the text, the highlight box isn't correct:

> Selecting the text in the PDF output from the user font tests
> in the cairo test suite works correctly for me. Try the user font tests 
> and see if that works for you. 

Yes, it does.

> If it does, creating a minimal test case 
> from your code and providing the PDF output would assist in debugging 
> the problem.

Creating a test case might be difficult, due to how "deep" I've had to
get with some of this.  I'll see what I can do though...
Meanwhile, I've attached a small PDF with a single word in it that
demonstrates the problem (In Acroread 8.1.2), in case it's enough.
[ Note that it also draws the extent box around each glyph ]

In the meantime, I've done some more testing, and might have a nugget
of info that can point to the cause of the problem:

As I've mentioned before, these particular fonts are old, custom, and
frankly pretty ugly.  One of the (many) difficulties is there's no
fixed rules for when the users create them.  As such, most of them
have the glyph origin at the *centre* of the glyph (I guess it seemed
like a good idea years ago...).
I've since found some fonts that have their origin at the lower-left
corner, and they seem to select more as expected.

So, given that when the origin is shifted by half the width of the
glyph (to the centre), the selection box is also shifted, I'm guessing
that it might be related.

Now, given that we've got our own FreeType driver for this font, and
I've also got a Cairo UserFont for it, I'm going to guess that one of
them needs something tweaked.  I'm just not sure which...


>> 2) When I copy+paste the text from the PDF, I don't get my text.
>>      - From AdobeReader, I get one 􀀀 character for each character.
>>      - From evince, I get one 0 character for each character.
> 
> The user font tests work fine for me with the exception of the first 
> glyph. I need to look into that but the rest of the characters are 
> extracted correctly.

Hmmm...  Given that we render text one glyph at a time, I wonder if
what I'm seeing is that same problem, but repeated for each character?

> Have a look at the the user font tests to see if 
> you are missing anything in your implementation.

The only thing I saw was the unicode_to_glyph_func stuff.  I'll
take a closer look at the font, but think it should fall into the
"identity mapping from Unicode code-points to glyph indices" that
is the default...

> Cairo does not provide any means to specify a name for a user font.

Ok, thanks.

>> 4) I've been asked by some people about being able to control some
>>      of the additional PDF attributes (eg: security->printing,
>>      layers, etc).
>>      (Either currently or planned)?
> 
> There is no support in cairo for these features. You can use pdftk to 
> apply these features to a PDF.

Bummer.  As a mapping company, being able to work with layers
would be of great interest to us (Someday - Gotta get the basics
finished first!)

Thanks for the pointer to pdftk though - I wasn't aware of it.
However, I'm hoping to find ways to do everything we need/want
within our code though, so end-users don't have to install+use
extra tools (for the typical workflows, at least).

Ian



More information about the cairo mailing list