Comments (6)
Reproduction project
local richtext = require("richtext.richtext")
function init(self)
local text = "This is a test <br/>"
local settings = {
parent = gui.get_node("root"),
}
local words, metrics = richtext.create(text, "font", settings)
local last_word = richtext.truncate(words, 1, {words = false})
pprint(last_word)
end
DEBUG:SCRIPT:
{ --[[0000029E3235E980]]
outline = vmath.vector4(0, 0, 0, 0),
size = 1,
color = vmath.vector4(1, 1, 1, 1),
metrics = { --[[0000029E32361010]]
width = 9,
max_descent = 4,
max_ascent = 13,
height = 17,
total_width = 17
},
text = "This ",
tags = { --[[0000029E3235E610]]
br = true
},
node = T@(0, 0, 0),
font = "font",
shadow = vmath.vector4(0, 0, 0, 0)
}
from defold-richtext.
It's not actually a problem with truncate, the words themselves are getting the wrong tags with richtext.create() when there are is_empty tags present before the words.
from defold-richtext.
The issue appeared within the release https://github.com/britzl/defold-richtext/releases/tag/5.8.0 previous versions to that do not appear to incorrectly add is_empty tags to words where they do not belong.
from defold-richtext.
If there are any other open/close tags like "Hello <b>this</b> is<br/>"
the words before and including the <b></b>
do not improperly get the <br/>
tag in their list of tags, but in this case the "is" would get the improper tag.
from defold-richtext.
I think the problem line is
dst.tags[tag] = (params == "") and true or params
but at the moment I don't understand why.
from defold-richtext.
The settings in split_text needs to be deep copied I think?
This seems to fix it to avoid adding is_empty tags improperly on a simple test.
But I don't know if you rely on this behavior for the nested tags to work right.
I also still don't fully understand why it was breaking in the first place.
local function split_text(text, settings, words)
assert(text)
assert(settings)
assert(words)
settings = deepcopy(settings)
from defold-richtext.
Related Issues (20)
- Add options to make images conform in scale to fit line height of previous or next char HOT 3
- Macro tag to apply multiple sets of commonly used tags at once HOT 4
- Unnecessary spaces between nodes of different colors. HOT 8
- Long Text HOT 1
- ALIGN_JUSTIFY last line bug HOT 3
- add ability to automatically scale text to fit in the bounds supplied HOT 1
- Spacing between words/nodes HOT 1
- Text alignment like pivot in text node HOT 4
- Multiple repeat tags causes Lua memory allocation error. HOT 1
- Cleaner unicode character insert method HOT 1
- Color tag shouldn't cause words to be "broken up"? HOT 7
- Add function to get plain text of text with tags in it HOT 1
- add ability to get the size needed for a richtext node before setting the text
- <a=msg_id>link</a> scales too much with size tag when size ~= 1.
- combine_words seems to be broken HOT 1
- When using <a> tag along with combine_words on_click throws an error HOT 1
- Color tag is adding extra white space between words HOT 1
- valign doesn't seem to be doing anything HOT 2
- Example Project Error HOT 1
- Add a richtext.remove equivalent for characters HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from defold-richtext.