Convert text to vector code?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Post Reply
dkwroot
Posts: 660
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Convert text to vector code?

Post by dkwroot » Sun Apr 29, 2018 2:36 am

I can't find a function that allows us to convert a text layer into a regular vector. Does it exist or are there workarounds?
User avatar
synthsin75
Posts: 7156
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Convert text to vector code?

Post by synthsin75 » Sun Apr 29, 2018 4:43 am

Not that I can find, but you can set whether a text or vector layer is going to be created by the next use of the insert text tool or calling: moho:CreateTextObject()

local param = MOHO.MohoGlobals.InsertText
param.MakeLayer = false --false to create vector layer
dkwroot
Posts: 660
Joined: Thu May 02, 2013 6:56 am
Location: USA
Contact:

Re: Convert text to vector code?

Post by dkwroot » Sun Apr 29, 2018 5:15 am

I also noticed the function for creating text objects. I just didn't see any other functions for them. The more I look into this, the more it seems like the text layer was just hacked into the vector layer. It really should have its own class and functions, maybe a future Moho release.

Thanks Wes.
User avatar
synthsin75
Posts: 7156
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Convert text to vector code?

Post by synthsin75 » Sun Apr 29, 2018 6:56 am

Yeah, unless we ask for something specific, they only create new scripting access for stuff they need in stock scripts. It's pretty rare that we get other scripting additions that we haven't asked for.
User avatar
synthsin75
Posts: 7156
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Convert text to vector code?

Post by synthsin75 » Sun Feb 10, 2019 8:30 am

Code: Select all

	local layer = moho.layer --text layer
	moho:CreateNewLayer(MOHO.LT_VECTOR)
	local param = MOHO.MohoGlobals.InsertText
	param.Text:Set(layer:Name())
	moho:InsertText(param, 0)
	moho:DeleteLayer(layer)
But you lose any line breaks.

Well, you can maintain line breaks, by leaving off "param.Text:Set(layer:Name())", but only if you open the layer's layer settings first, so it registers that as the param text.

moho:EditLayerSettings() doesn't seem to do anything.
hayasidist
Posts: 2144
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Convert text to vector code?

Post by hayasidist » Wed Feb 13, 2019 3:19 pm

dunno if this is helpful or irrelevant as we're in the scripting area but … there is a right-click option on a Text layer to convert it to a vector layer
User avatar
synthsin75
Posts: 7156
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: Convert text to vector code?

Post by synthsin75 » Wed Feb 13, 2019 4:20 pm

Yeah, I assumed he wanted something scriptable.
Post Reply