Is something like this possible?
local myText = display.newText("", 0, 0, native.systemFont, 25) myText:setTextColor(0, 0, 0, 255); myText.text = "This [b]word[/b] should appear bold!";
Thanks in advance!
Is something like this possible?
local myText = display.newText("", 0, 0, native.systemFont, 25) myText:setTextColor(0, 0, 0, 255); myText.text = "This [b]word[/b] should appear bold!";
Thanks in advance!
No
Was wondering myself. What’s more baffling is you can’t adjust leading or kerning in a text area. How would you go about bolding then? Have two separate text objects?
Yes. There is no bold or italic option. Your whole font must be bold or italic but no way to mix like in normal text editor.
You could try this … although there are better ways, this would be fairly simple. You can build on this to handle spacing better and line wrap, etc… but it covers what you were trying to do in your question.
local function textBuilder( textTable) local textGroup = display.newGroup() for i = 1, #textTable do if textTable[i].style == "BOLD" then textGroup:insert(display.newText(textTable[i].text, 0,0, native.systemFontBold, 10)) elseif textTable[i].style == "COLOR1" then textGroup:insert(display.newText(textTable[i].text, 0,0, "Optima-Italic", 10)) textGroup[textGroup.numChildren]:setTextColor(135,206,250) else textGroup:insert(display.newText(textTable[i].text, 0,0, native.systemFont, 10)) end textGroup[textGroup.numChildren]:setReferencePoint(display.TopLeftReferencePoint) if i \> 1 then textGroup[textGroup.numChildren].x = textGroup[textGroup.numChildren - 1].x + textGroup[textGroup.numChildren - 1].width end end return textGroup end local myString = textBuilder( { {text = "Find the best apps at ", style = "STD"} , {text = "Cyber Park Studios ", style = "COLOR1"}, {text = "where ", style = "STD"} , {text = "Apps R Fun ", style = "BOLD"} } ) myString.x = 20 myString.y = 50
hope this helps
Good workaround but still we are lacking real solution like
“This word should appear bold!”
or similar. Corona Labs - is it just impossible with Corona or can it be requested feature?
No
Was wondering myself. What’s more baffling is you can’t adjust leading or kerning in a text area. How would you go about bolding then? Have two separate text objects?
Yes. There is no bold or italic option. Your whole font must be bold or italic but no way to mix like in normal text editor.
You could try this … although there are better ways, this would be fairly simple. You can build on this to handle spacing better and line wrap, etc… but it covers what you were trying to do in your question.
local function textBuilder( textTable) local textGroup = display.newGroup() for i = 1, #textTable do if textTable[i].style == "BOLD" then textGroup:insert(display.newText(textTable[i].text, 0,0, native.systemFontBold, 10)) elseif textTable[i].style == "COLOR1" then textGroup:insert(display.newText(textTable[i].text, 0,0, "Optima-Italic", 10)) textGroup[textGroup.numChildren]:setTextColor(135,206,250) else textGroup:insert(display.newText(textTable[i].text, 0,0, native.systemFont, 10)) end textGroup[textGroup.numChildren]:setReferencePoint(display.TopLeftReferencePoint) if i \> 1 then textGroup[textGroup.numChildren].x = textGroup[textGroup.numChildren - 1].x + textGroup[textGroup.numChildren - 1].width end end return textGroup end local myString = textBuilder( { {text = "Find the best apps at ", style = "STD"} , {text = "Cyber Park Studios ", style = "COLOR1"}, {text = "where ", style = "STD"} , {text = "Apps R Fun ", style = "BOLD"} } ) myString.x = 20 myString.y = 50
hope this helps
Good workaround but still we are lacking real solution like
“This word should appear bold!”
or similar. Corona Labs - is it just impossible with Corona or can it be requested feature?