That worked perfectly, thanks Wim, even a zero-width return from the delegate was enough to get the preceding space considered.
Very simple, great tip. On 10 Apr, 2013, at 10:39 AM, Roland King <[email protected]> wrote: > That looks like a good thing to try, thanks. I'm quite fortunate in that the > images I need to add are perfectly the size of an ideographic space (they are > fragments of Chinese characters which don't have real Unicode points) so CT > does a fine job with them. Sounds like I need one trailing character with the > CTRunDelegate set to return 0 or 1px wide nothing and that will force what I > need. > > I'll try that today. Thanks. > > On 10 Apr, 2013, at 6:22, Wim Lewis <[email protected]> wrote: > >> >> On 9 Apr 2013, at 7:04 PM, Roland King wrote: >>> I have an attributed string I'm laying out with a CTFrame. The string can >>> have a trailing space in it, possibly more than one, they are actually >>> \u3000, IDEOGRAPHIC SPACE. I need them to be treated like a real character >>> and laid out, even if that breaks onto a new line. Those 'spaces' are >>> placeholders for small images which can't be embedded in the string (iOS >>> doesn't allow images in attributed strings like it does on OSX) so I need >>> them laid out so I can find where they went and overlay the graphics. A >>> little messy, works better than I expected, apart from this. >> >> We do attachments using U+FFFC OBJECT REPLACEMENT CHARACTER (which Apple >> also names NSAttachmentCharacter on the desktop) and setting a custom >> CTRunDelegate to specify the metrics of the attachment image (width, ascent, >> descent). Then we run through the laid-out text to find the attachment runs >> and draw their images and so on. This is rather clumsy (why doesn't >> CTRunDelegate have a drawing callback?) but it gets the job done. >> >> I think you can actually use any character rather than U+FFFC there, and it >> probably affects the line breaking algorithm accordingly. >> >> >> >> _______________________________________________ >> >> Cocoa-dev mailing list ([email protected]) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org >> >> This email sent to [email protected] > > _______________________________________________ > > Cocoa-dev mailing list ([email protected]) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org > > This email sent to [email protected] _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
