Re: gdtk_draw_text deprecated , what use instead of it ?



Havoc Pennington wrote:
On Tue, 2003-12-30 at 18:31, Paul Pogonyshev wrote:
I would like to see any comments from GTK+ developers on if there's any
hope of seeing gdk_draw_text() to be resurrected.

You're missing the fundamental point about pango vs. gdk_draw_text().
gdk_draw_text() uses an _entirely different_ backend, the old X core
fonts, vs. Pango which uses a modern system with Unicode, antialiasing,
a *different list of available fonts*, and so forth. So what's really
deprecated is the broken old backend.

Agreed.  I already wrote in reply to some other post (with similar comment),
that the point was not to return gdk_draw_text() (with its backend), but
rather to have a function with similar API.

We could introduce a pango_draw_text() with an API similar to
gdk_draw_text(), but it would have to create a PangoLayout internally so
there's no efficiency gain, other than hiding the inefficiency from the
programmer. An equivalent to gdk_text_width() would also create the same
PangoLayout, etc. Very slow very quickly.

I think you meant "i'd implement it with creating a PangoLayout internally"
rather than "it would have to ...".  PangoLayouts are handled somewhere
within the Pango library, not in the backend it uses (be that X or Win32).
So, you do not _have_ to create a PangoLayout internally, you can just use
a very reduced rendering/width determining algorithm that is used in
PangoLayouts, but without PangoLayout themselves.

I don't want to look into actual code, but let's say PangoLayout renders
text in this abstract way:

        while (paragraph = feed_me_paragraph(layout)) {
          while (line = feed_me_line(paragraph)) {
            while (character_span = feed_me_character_span(line))
              do_draw_character_span(character_span);
          }
        }

So, there would be two ways of implementing a gdk_draw_text()-like, but
with Pango backend, function.  Either (code is descriptive only)

        layout = pango_layout_new();
        pango_layout_set_text(layout, text);
        gdk_draw_layout(layout);

or simply

        do_draw_character_span(text);

... If you know your text is always just "a",
"b", "c" then yes you could avoid PangoLayout. However, if there were a
non-layout API people would use it in a lot of cases where it would be
broken, and the layout API should work fine for what you're doing.

Well, everything could be misused.  However, limiting is not a correct
way of preventing misuse, i'd say ;)  If nothing else, such a function
could probably stop the avalanche of questions about text drawing on
your mailing list.

And if you afraid of improper use of such a function, the first thing to
fix is your reference documentation.  It contains function descriptions,
but far too few descriptions of how to actually _do_ certain things.

Let's have a look at the comment about pango_draw_layout():

        Render a PangoLayout onto a GDK drawable

Yeah, i really feel enlightened now.  Seriously, this is just not enough.
Yes, i can find a bit more about layouts if i follow the link under the
"PangoLayout".  But that's not obvious, and nothing tells me _why_ i
should use this function (that is, unless i'm lucky enough to spot the
comment for gdk_draw_glyphs(), which has a tiny bit of ad for
gdk_draw_layout()).

Paul



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]