britzl / defold-richtext

Defold-RichText is a system to create styled text based on an HTML inspired markup language
MIT License
75 stars 12 forks source link

Adding extra waiting time for create_truncate_example() #39

Closed subsoap closed 5 years ago

subsoap commented 5 years ago

It would be useful if it were somehow possible to add tags like to be able to skip timer.delay repeats based on those kinds of tags. Maybe being able to check the next word/tag see if it's a wait tag and live edit it so it's at or below 0?

This would be useful to add a little time between line breaks / add suspense in text.

britzl commented 5 years ago

You could add zero-width space characters to your text to add a delay:

\226\128\139
subsoap commented 5 years ago

Good idea!

subsoap commented 5 years ago

Although it ends up looking like this

1

2

subsoap commented 5 years ago

Maybe runtime solution would be to swap a special tag with the marked number of zero-width chars.

britzl commented 5 years ago

Maybe add a new tag <zwsp repeat=5/> to insert repeat number of zero-width space characters?

Or maybe add a generic custom tag handler where you could register a handler for a tag and when it is encountered you get any enclosed text as an argument your tag handler function.

I'll think a bit on this and see what can be done. This week is a bit crazy but on Friday we have an exploration day in the team. I'll do some work on Defold-RichText then.

subsoap commented 5 years ago

<zwsp repeat=5/> would be good enough for my use case.

subsoap commented 5 years ago

Was <zwsp repeat=5/> added or &zwsp; by itself?

britzl commented 5 years ago

Only &zwsp; for now

subsoap commented 5 years ago

For future searching reference, if something is zwsp it gets a zwsp tag. So you can skip zwsp characters for effects.

if last_word.tags and not last_word.tags.zwsp then

britzl commented 5 years ago

Yes, good point. Each &zwsp; will be converted into a tag with inner content set to \226\128\139. This allows for searching of the tags etc

subsoap commented 5 years ago

text_particles2