Page 1 of 1

Simple expression for Font Change

Posted: Sun Feb 17, 2019 6:45 am
by 3dmus
Hey all - I was wondering something. The other day I needed to use an expression to change the font on-the-fly. I noticed that whilst you can right click the font drop down you can select "expression" . However, it doesn't show any box to enter the expression. I worked around this by copying the node to a text editor and to add the expression there. This works well, but I was wondering if there's any reason that it doesn't show the expression box? Is this a bug?

Re: Simple expression for Font Change

Posted: Sun Feb 17, 2019 7:36 am
by SirEdric
Looks like a bug to me, related to the FontEdit Control. Even when you try to add one of those via EditControls, it won't show up...

Re: Simple expression for Font Change

Posted: Sun Feb 17, 2019 7:43 am
by 3dmus
Thanks for confirming Eric :-)

Re: Simple expression for Font Change

Posted: Sun Feb 17, 2019 11:08 pm
by SecondMan
3dmus wrote:
Sun Feb 17, 2019 7:43 am
Thanks for confirming Eric :-)
Moving this to the Bug Tracker, thanks for reporting and confirming :)

Any chance you could post your setup with said expression to illustrate/reproduce?

Re: Simple expression for Font Change

Posted: Tue Feb 19, 2019 11:09 am
by 3dmus
Sure thing! So, for the below comp I right clicked to add an expression to the font field. This doesn't show up, but when you take it into a text editor you can see that a standard expression has been added (something like "Text(\"Open Sans"\)).

Functionality wise it works, when I add the below expression for both the Text box and the Font, it cycles through a few fonts and then displays the name of the font with the correct font (if that makes sense!). Now I have to say, that whilst it works, I've seen some erratic behaviour which sometimes disappears after re-starting Fusion. Maybe that's why they never enabled the field to appear? Not sure really.

Code: Select all

:myarray={"Arial","Century Gothic","Impact"}; index=(floor(time/24)%3)+1; return Text(myarray[index]);
Full node:

Code: Select all

{
	Tools = ordered() {
		Text1_1 = TextPlus {
			CtrlWZoom = false,
			Inputs = {
				Width = Input { Value = 1920, },
				Height = Input { Value = 1080, },
				["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
				Font = Input {
					Value = "Arial",
					Expression = ":myarray={\"Arial\",\"Century Gothic\",\"Impact\"}; index=(floor(time/24)%3)+1; return Text(myarray[index]);",
				},
				StyledText = Input {
					Value = "Arial",
					Expression = ":myarray={\"Arial\",\"Century Gothic\",\"Impact\"}; index=(floor(time/24)%3)+1; return Text(myarray[index]);",
				},
				Style = Input { Value = "Regular", },
				ManualFontKerningPlacement = Input {
					Value = StyledText {
						Array = {
						},
						Value = ""
					},
				},
			},
			ViewInfo = OperatorInfo { Pos = { 325, 138 } },
		}
	},
	ActiveTool = "Text1_1"
}