Lukas Renggli wrote:
I don't think so. All subclasses of TextAttribute implement #emphasizeScanner:. There would be no point in having the TextAttribute class, if it does not implement #emphasizeScanner:. The #emphasizeScanner: method is like the #accept: method in the visitor pattern. If it is not there, the object is simply ignored.
Good point. I probably should have left it in for this reason. The origin of this change is that TextAttribute only modifies text and that the text must be drawn nonetheless. This makes it impossible to get the spacing "right" when you try to place small glyphs as inline graphics at relatively large font sizes (you really need an infinitely small empty glyph for that) which is what made me change this to a stop condition instead.
When I changed this I simply vectored the stop condition #embeddedObject into #placeEmbeddedObject: but as you say, this may be incorrect from a semantic perspective. It might be better to fix this by having the embeddedObject stop condition call into #skipForEmbeddedObject: with a comment explaining that we don't want to display anything here because there will be a text attribute containing some graphics which is supposed to define the width of the glyph.
Although ... I'm not certain this all worked correctly in the original version - I think there were issues with line breaks and selection of the graphics etc. Computing this as the width of that special character makes it pretty straightforward to deal with all that. Or whatever :-)
In any case, calling #placeEmbeddedObject: twice is very clearly wrong.
Cheers, - Andreas