Re: embedding arbitrary graphics in text

On Sep 7, 2010, at 9:15 AM, Behdad Esfahbod wrote:

Also see pango/examples/cairoshape.c for an example.

OK, I followed it, thank you so much. The only thing that I had to look at 3 or so times, before I caught the importance of it, is the translate to the cr current point at the top of the render function. I'm trying to imagine when I wouldn't want to actually do that.

Question 1

What is the difference between the ink rect and the logical rect. I mean, I think I mostly get it. But I'm curious if there are cases where portions of the ink would ever lie outside the logical rect? Is the "origin (x,y) of the rects always at the baseline of the characters, I noticed that they all seem to have negative heights to go nominally "upwards". I was curious if there was an example or two in the docs somewhere, that showed something I was missing.

Question 2

The example demonstrates how to completely draw something other than the font's glyph in place of a character (or more). I'm curious if it's possible to still let it draw the character glyphs it was going to draw, but do some additional annotation. For example, I'd like to insert a stop sign graphic in front of the character run the attributes stand for, and nudge them to the right by that much. Or do I have to inject filler characters into my text to do that?

What My Binding Ended up Looking Like (for now)

With Behdad's and Tony's direction, I established a single shape renderer for any Context I create a binding for in Smalltalk. When I'm creating the attribute, I do it with the two rectangles, and with a Block Closure. Block Closures are Smalltalk arbitrary functions, that close over any current values needed for the function. So I get both data and behavior all in one, a lot, or a little. I keep a table on the Smalltalk side, which maps Smalltalk blocks, to an arbitrary incrementing counter. The index, is what I stuff in the data of the attribute. So when I get the callback, I fetch the Smalltalk block associated with the particular attribute's data key, execute the block with the mapped arguments. Works pretty well.

Travis Griggs
"The best way to know you have a mind is to change it" -Judge Pierre Leval

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