On 11/5/06, Nicolas Grilly <[EMAIL PROTECTED]> wrote:
> In module ft2font, the method FT2Font.get_charmap returns a dict that
> maps glyph indices to char codes.
>
> I don't understand the purpose of this mapping, and why the method
> doesn't return the reverse mapping, i.e. char codes mapped to glyph
> indices.

The ft2font module provides a Python interface to the FT2Font C API.
get_charmap is one of the methods in this API as is set_charmap.  A
font can have multiple character maps.  get_charmap() returns the
default one.  Others can be specified by providing an argument to
get_charmap(). To add a new charmap to the font, you must first find
out what charmaps it contains, so get_charmap is needed for this.

In addition, changing this method to return the reverse mapping would
violate the rule of least surprise. Note that creating the reverse
dict is easy in Python.

 -- Paul

> For example, in backend_ps.py, line 754, the charmap is immediately
> reversed, just after being loaded:
>
>         cmap = font.get_charmap()
>         glyphd = reverse_dict(cmap)
>
> Thanks,
>
> Nicolas Grilly
>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to