Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

multi-colored text
Started by Nerox Aug 25 2018 03:53 AM

2 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Nerox

[GLOBAL: userInfoPane.html]
Nerox
  • Enthusiast

  • 94 posts
  • Corona SDK

I want to create a text object with more than 1 color, 

for example "(This part is red) (This part is green)" maybe defining the text could be like this "#ff0000(This part is red) ##00ff00(This part is green)"

can this be achieved through corona ? and if not can it be achieved at all ?

I thought about creating a custom text creation function where it splits the text wherever a hex code is found and then place the text objects with different colors beside each other, is there an easier way ?



[TOPIC: post.html]
#2

horacebury

[GLOBAL: userInfoPane.html]
horacebury
  • Corona Geek

  • 2,975 posts
  • Corona SDK

I'd go with your suggestion. There is no built in way to specify manipulations of text objects, so writing your own is the way to go.



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,535 posts
  • Corona Staff

There is a technical reason as to why this isn't supported. Corona lives in an OpenGL graphics texture world. We want the GPU doing as much work as possible. Text is converted to an image mask using the device's native font rendering features and that mask is applied to a colored rectangle and produces a texture that can be sent to the GPU via OpenGL and operate at the high speeds that the GPU gives us. We don't support rich text, not because we don't want to, but because the technology used to get from a font + text string to the GPU goes through a B&W mask.

 

Rob




[topic_controls]
[/topic_controls]