Hi,
anyone have any code to display text in a nice font along an arc or a spiral? _,,,^..^,,,_ best, Eliot |
> On 2018-12-29, at 5:06 PM, Eliot Miranda <[hidden email]> wrote: > > anyone have any code to display text in a nice font along an arc or a spiral? Any help from the truetype example stuff - TTCFont etc? I swear there used to be an example morph that was a large TTCfont saying something like 'Truetype fonts are beautiful' tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Oxymorons: Passive aggression |
In reply to this post by Eliot Miranda-2
Hi, You can pull out a Line from the Graphics category in the ObjectsTool. Then enable 'drop in' in the Lines menu. Then pull out Text from the Basic category. In Texts menu you can then select 'follow owner's curve' Unfortunately it it broken. I think because NewParagraph uses another notion of container than what is expected. Best, Karl On Sun, Dec 30, 2018 at 2:06 AM Eliot Miranda <[hidden email]> wrote:
|
I just tested this in a 2.5 image and it worked :-) I'm not sure when it broke... Best, Karl On Sun, Dec 30, 2018 at 9:36 AM karl ramberg <[hidden email]> wrote:
|
Broke between #16520 and update: #18028 Best, Karl On Sun, Dec 30, 2018 at 3:20 PM karl ramberg <[hidden email]> wrote:
|
TextMorph>>createParagraph is the method that broke the TextOnCurve functionality. It need a guard against applying wrapFlag. There is also some bug with the bounds so the text will not redraw properly. Something like this under will prevent the DNU but it will not fix the issue with the text bounds. TextMorph>>createParagraph self setProperty: #CreatingParagraph toValue: true. [ self setDefaultContentsIfNil. "...Code here to recreate the paragraph..." paragraph := (self paragraphClass new textOwner: self owner). paragraph wantsColumnBreaks: successor notNil. paragraph compose: text style: textStyle copy from: self startingIndex in: self container. (paragraph isKindOf: TextOnCurve) ifTrue:[ self removeProperty: #CreatingParagraph. ^ paragraph]. wrapFlag ifFalse: ["Was given huge container at first... now adjust" paragraph adjustRightX]. paragraph focused: (self currentHand keyboardFocus == self). self fit. ] ensure: [self removeProperty: #CreatingParagraph]. ^ paragraph Cheers, Karl On Sun, Dec 30, 2018 at 3:56 PM karl ramberg <[hidden email]> wrote:
|
With this change it works. Text segments will be added along the curve. Unless the text overflow the line, then it will only show the first text segment. Just make the line longer to make it show again, TextMorph>>createParagraph self setProperty: #CreatingParagraph toValue: true. [ self setDefaultContentsIfNil. "...Code here to recreate the paragraph..." paragraph := (self paragraphClass new textOwner: self owner). paragraph wantsColumnBreaks: successor notNil. paragraph compose: text style: textStyle copy from: self startingIndex in: self container. (paragraph isKindOf: TextOnCurve) ifTrue:[ paragraph focused: (self currentHand keyboardFocus == self). self fit. self removeProperty: #CreatingParagraph. ^ paragraph]. wrapFlag ifFalse: ["Was given huge container at first... now adjust" paragraph adjustRightX]. paragraph focused: (self currentHand keyboardFocus == self). self fit. ] ensure: [self removeProperty: #CreatingParagraph]. ^ paragraph On Sun, Dec 30, 2018 at 11:06 PM karl ramberg <[hidden email]> wrote:
textOnCurve.png (35K) Download Attachment |
This part of code in TextOnCurve>>composeLinesFrom: startingIndex withLines: startingLines atY: startingY ... lines last last < text size ifTrue: [ [lines size > 1 and: [(text at: (i := lines last last) + 1) ~= Character space]] whileTrue: [i = lines last first ifTrue: [lines removeLast. textSegments removeLast] ifFalse: [lines last stop: i - 1]]]. If the text overflow the end of the curve only the first segment of the text will be shown. I think this will make sense when the text overflow into a predecessor or successor. See TextMorph. But there are no hooks back to the text morph so there is no way to know if there is a predecessor or successor. So if the curve is to short it will be kind of buggy... Cheers, Karl |
In reply to this post by Karl Ramberg
Neat stuff, but I do so hate to see #isKindOf:.
> On 2018-12-31, at 3:29 AM, karl ramberg <[hidden email]> wrote: > > TextMorph>>createParagraph > > self setProperty: #CreatingParagraph toValue: true. > > [ > self setDefaultContentsIfNil. > > "...Code here to recreate the paragraph..." > paragraph := (self paragraphClass new textOwner: self owner). > paragraph wantsColumnBreaks: successor notNil. > paragraph > compose: text > style: textStyle copy > from: self startingIndex > in: self container. > (paragraph isKindOf: TextOnCurve) > ifTrue:[ > paragraph focused: (self currentHand keyboardFocus == self). > self fit. > self removeProperty: #CreatingParagraph. > ^ paragraph]. > wrapFlag ifFalse: > ["Was given huge container at first... now adjust" > paragraph adjustRightX]. > paragraph focused: (self currentHand keyboardFocus == self). > > self fit. > ] ensure: [self removeProperty: #CreatingParagraph]. > > ^ paragraph That 'isKindOf: TextOnCurve' seems like it ought to be redundant. Both branches send #fit, focused; & removeProperty (in fact the ensure will make sure it happens twice for TextOnCurve instances) so it's hard to see what the intent is here. tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Did you hear about Christopher Robin Hood? He stole from the rich to give to the Pooh |
On Mon, Dec 31, 2018, 10:56 tim Rowledge <[hidden email] wrote: Neat stuff, but I do so hate to see #isKindOf:. What the intent looks like is to avoid the #adjustRightX if the wrapFlag is not set - which is causing the error(s), at least when I tried it. Another alternative might be to implement TextOnCurve>>adjustRightX to be a no-op (with a suitable comment) so that it didn't do anything in this case. Then the isKindOf: could go away. And, Karl, thank you for tracking this down! -cbc what is |
> On 2018-12-31, at 11:20 AM, Chris Cunningham <[hidden email]> wrote: > > > What the intent looks like is to avoid the #adjustRightX if the wrapFlag is not set - which is causing the error(s), at least when I tried it. Yup, that's the only visible difference - unless of course it turned out that the *order* of sending messages was important here. Occasionally that justifies special cases, but even then, an #isKindOf: is justification for a slapped wrist at the least. > > Another alternative might be to implement TextOnCurve>>adjustRightX to be a no-op (with a suitable comment) so that it didn't do anything in this case. Then the isKindOf: could go away. Yup. tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim Cap'n! The spellchecker kinna take this abuse! |
Hi, I made adjustRightX a no-op. Fix in trunk. Cheers, Karl On Mon, Dec 31, 2018 at 8:29 PM tim Rowledge <[hidden email]> wrote:
|
In reply to this post by Karl Ramberg
Hi Karl, thanks very much. With your fixes I can indeed get a text to follow an arc. Now how do I create a text (TextMorph) with a good quality bold+italic font? I';m using a standard trunk image. Can anyone pots a doit to create a TextMorph for e.g. 'The quick brown fox jumped over the lazy dog' which is in a nice large smooth non -bitmap font? On Sun, Dec 30, 2018 at 12:36 AM karl ramberg <[hidden email]> wrote:
_,,,^..^,,,_ best, Eliot |
> On 2018-12-31, at 4:39 PM, Eliot Miranda <[hidden email]> wrote: > > Hi Karl, > > thanks very much. With your fixes I can indeed get a text to follow an arc. Amongst all the 'fun' of fixing bugs in things like ServerDirectory it's so easy to forget how mind-crogglingly cool some of the things we can do are. Looking at the code of TextOnCurve I'd say that the dependence upon using Warpblt would require using bitmap characters, though it *should* be practical to use a TTFont to render a suitable font glyph. Not quite what you were asking for but maybe close enough? tim -- tim Rowledge; [hidden email]; http://www.rowledge.org/tim ..... REALITY.SYS Corrupted - Unable to recover Universe |
If you have true type fonts installed it should be possible to set the TextMorph to that font. The rendering is probably some bitmap warp method though. Cheers, Karl On Tue, Jan 1, 2019 at 2:59 AM tim Rowledge <[hidden email]> wrote:
|
In reply to this post by Karl Ramberg
On Mon, Dec 31, 2018 at 3:30 AM karl ramberg <[hidden email]> wrote:
Yay Karl! Nice - this has been broken for too long. - Bert - |
Free forum by Nabble | Edit this page |