Re: Commit: AbiMagick graphics class sort-of works

From: Andrew Dunbar (hippietrail@yahoo.com)
Date: Mon Aug 19 2002 - 01:45:52 EDT

  • Next message: Andrew Dunbar: "Re: Commit: AbiMagick graphics class sort-of works"

     --- Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
    wrote: > Andrew,
    >
    > Leonard Rosenthol forwarded your message to me
    > regarding Magick++'s
    > inability to specify that text is formatted as
    > UTF-8.
    >
    > I'd like to get this fixed right the first time
    > since I try to avoid changes to Magick++'s API. It
    > has got to be right the first time around.
    >
    > There are two options that I see for passing the
    > text encoding option:
    >
    > o Add a constructor to DrawableText that also
    > specifies the encoding:
    >
    > DrawableText ( const double x_, const double
    > y_,
    > const std::string &text_,
    > const std::string &encoding_);
    >
    > or
    >
    > o Create a new drawable object for specifying the
    > text encoding:
    >
    > DrawableTextEncoding ( const std::string
    > &encoding_ );
    >
    > which is used like
    >
    > list.push_back(DrawableTextEncoding("UTF-8"));
    > list.push_back(DrawableText(200,300,"stuff"));
    >
    > I currently have both schemes implemented, but
    > expect to delete one of them. I favor attaching the
    > encoding to the text since it is possible that an
    > application uses several encodings and this fully
    > specifies the meaning of the text. In addition,
    > adding the encoding to the text allows DrawableText
    > to be used without a list.
    >
    > Comments?

    Well I don't know anything else about ImageMagick
    since this is the first time I've looked at it at all.
    The constructor sounds like a good idea but I'm not
    sure that sometimes you might not know the encoding
    at construction time. For this reason I would think
    both APIs should go in but I'm sure I'm not in a
    position to decide.

    Here are some potential problems I can see. Again I
    may be missing something.

    magick/render.c/DrawImage looks for the "encoding"
    keyword but then only checks that the next token is
    "UTF-8" - I can't find code that takes into account
    any other encoding. Is this correct?

    magick/annotate.c/RenderFreetype line 1116
    Maybe it's not part of IM's coding style, but a
    comment that the switch default falls through to the
    following case would make the logic here a bit
    clearer.
    It seems there's two ways to specify that text is
    Unicode.

    The "encoding" field lives in the draw_info structure.
    I can't tell from what I know of the code whether
    there
    is one of these per image or per text string to add to
    the image. My guess is that it is per image.
    If this guess is correct then I don't think it's
    meaningful to call a DrawableTextEncoding member on
    a per string basis.
    I would probably regard this as a bit of a design flaw
    but if it's the case, definitely go with just the
    constructor for now.
    If I'm misreading the code and it is possible to
    have a meaningful encoding-per-string, then I'd
    recommend going with DrawableTextEncoding, possibly
    with the constructor version also.

    I hope this makes sense (: Apologies for not having
    spent more time understanding the ImageMagick code.

    Andrew Dunbar.

    > Bob
    > ======================================
    > Bob Friesenhahn
    > bfriesen@simple.dallas.tx.us
    > http://www.simplesystems.org/users/bfriesen
    >

    =====
    http://linguaphile.sourceforge.net/cgi-bin/translator.pl http://www.abisource.com

    __________________________________________________
    Do You Yahoo!?
    Everything you'll ever need on one web page
    from News and Sport to Email and Music Charts
    http://uk.my.yahoo.com



    This archive was generated by hypermail 2.1.4 : Mon Aug 19 2002 - 01:49:25 EDT