How to avoid error cmap format 14 is not supported.

4,876 views
Skip to first unread message

Hiroyuki Sato

unread,
May 16, 2014, 9:29:25 AM5/16/14
to prawn...@googlegroups.com
Dear members.

This code worked properly ( ~> 0.14.0 ).
But >= 0.15.0,  get the following error.

/usr/local/lib/ruby/gems/2.0.0/gems/ttfunk-1.1.1/lib/ttfunk/table/cmap/subtable.rb:71:in `[]': cmap format 14 is not supported (NotImplementedError)

Does anyone knows how to avoid this error?
Should I implement format14.rb ?

code

#!/usr/bin/env ruby

require 'prawn'
require 'pp'

FONT_PATH = "/path/to/japanese_font.ttf"

contents = "こんにちは"

pdf = Prawn::Document.new
pdf.font FONT_PATH

pdf.text_box contents, :size => 18, :at => [50, 215],
                     :width => 170,
                     :align => :left
pdf.render_file "hoge.pdf"

Sincerely. 

--
Hiroyuki Sato




Gregory Brown

unread,
May 16, 2014, 9:46:53 AM5/16/14
to prawn...@googlegroups.com
Hello,

I may be wrong about this, but a quick look at the TTF[0] and
OpenType[1] specs makes me think that cmap type 14 is an opentype
extension to TTF, and not part of the original TTF spec.

Strictly speaking, TTFunk is not built to be compatible w. OpenType.
In practice, it may be easy/harmless to add support for this particular
cmap, but I really don't know whether it would be or not. I'd be
hesitant to merge a patch without additional research so we know
whether it'll cause other compatibility issues or not.

You can take a look at how the other cmap formats[2] are implemented in
TTFUnk to get an idea of what's involved.

A working implementation is certainly a good starting point for more
conversation on this, but we'll need the research as well before we
consider merging to be sure that we're not adding support for a feature
that isn't fully compatible w. what we have already.

There is also the question of whether we should try to start supporting
OpenType in general, which I'm interested in doing, but that effort
would need someone to lead it because my time is very limited right now.

-greg

[0]: https://developer.apple.com/fonts/TTRefMan/RM06/Chap6cmap.html
[1]: http://www.microsoft.com/typography/otspec/cmap.htm
[2]: https://github.com/prawnpdf/ttfunk/tree/master/lib/ttfunk/table/cmap
> --
> You received this message because you are subscribed to the Google
> Groups "Prawn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to prawn-ruby+...@googlegroups.com
> <mailto:prawn-ruby+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Hiroyuki Sato

unread,
May 16, 2014, 11:45:15 PM5/16/14
to prawn...@googlegroups.com
Hi Greg.

Thank you for your advice.

I've already tried to add format 14.
But I'm getting stuck in the following problems.

I would like to work format 14 properly.
but I don't have much about font data.

so could you please tell me advice?

1, What information should I get from OpenType data? 

  I extracted length and numVerSelectorRecord field.
  But I don't know What parameter should I get from that fields. 

2, How to know current position?

  It seems I need to calculate field posicion with current posision. 
  How to know current position?

    io.pos ?

Best regards.


2014年5月16日金曜日 22時46分53秒 UTC+9 Gregory Brown:

Gregory Brown

unread,
May 17, 2014, 8:58:38 AM5/17/14
to prawn...@googlegroups.com
This is an area of the spec I haven't worked with before, so I can't
give you much specific guidance. However, a quick look at the opentype
spec tells me that the structure is basically a header that tells you
the data is in format 14, the number of bytes in the subtable, and the
number of records (Variation Selector Records) to follow.
This information tells you how many records to read, and how much
space they take up in the file.

Variation Selector Records consists of three things:
a selector, an offset into a default UVS table, and an offset into
a non-default UVS table. So for each of these records, you should
unpack these three values.

Once you have unpacked all of them, you'll also need to process both
default and non-default UVS tables. It looks like former is a set of
ranges that are considered to be treated as "default" (i.e. not
manipualted) and the latter are "non-default" and so they map various
unicode values to non-default glyphs.

I don't really understand much of this, but hopefully knowing the
structure will help you. It looks like there is a Format 14 example at
the bottom of the page related to cmaps:

http://www.microsoft.com/typography/otspec/cmap.htm

More generally, you can learn a bit about binary file processing by
reading this article:

https://practicingruby.com/articles/binary-file-formats?u=dc2ab0f9bb

And for more specific learning, you may want to try looking at how some
of the other formats in TTFunk are implemented:

https://github.com/prawnpdf/ttfunk/tree/master/lib/ttfunk/table/cmap

That's as much as I can help for now... it's been years since I've been
working on this code so I don't have much specific memory of it. Still,
hope it was helpful!

-greg
> > an email to prawn-ruby+...@googlegroups.com <javascript:>
> > <mailto:prawn-ruby+...@googlegroups.com <javascript:>>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Prawn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to prawn-ruby+...@googlegroups.com
> <mailto:prawn-ruby+...@googlegroups.com>.

Hiroyuki Sato

unread,
May 18, 2014, 7:59:51 PM5/18/14
to prawn...@googlegroups.com
Hello Greg

Thank you for your information. 

I'll try to implement it.

--
Hiroyuki Sato

2014年5月17日土曜日 21時58分38秒 UTC+9 Gregory Brown:
>      > <mailto:prawn-ruby+unsub...@googlegroups.com <javascript:>>.
>      > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Prawn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to prawn-ruby+...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages