Code Monkey home page Code Monkey logo

Comments (9)

britzl avatar britzl commented on July 18, 2024 1

Fixed in https://github.com/britzl/defold-richtext/releases/tag/5.10.2

from defold-richtext.

britzl avatar britzl commented on July 18, 2024

Hmm, good suggestion. Maybe add an option table as a third argument with an option to truncate full words/to word boundary:

richtext.truncate(words, length, { full_word = true }) -- option name?

from defold-richtext.

subsoap avatar subsoap commented on July 18, 2024

yes, settings table would work for this

from defold-richtext.

britzl avatar britzl commented on July 18, 2024

@subsoap I need to discuss the design a bit more:

  • If we add an option to truncate to full words, then if the result of a call to truncate() would result in
    a partial word, the function should remove that entire word right? Truncating "up" to include a full partial word is probably never something you'd like to do right?
         11111111112
12345678901234567890
Hi my name is Slim Shady

truncate(words, 16)

         11111111112
12345678901234567890
Hi my name is Sl

truncate(words, 16, { full_word = true })

         11111111112
12345678901234567890
Hi my name is

from defold-richtext.

britzl avatar britzl commented on July 18, 2024

PR #46

from defold-richtext.

subsoap avatar subsoap commented on July 18, 2024

Yes, you should "round down" the words"

Although when truncating full words the counter should probably be for the actual word count and not the character accounts, single words would be a single number in the total truncation value

from defold-richtext.

britzl avatar britzl commented on July 18, 2024

Good point. This has been implemented and released in 5.9.0

from defold-richtext.

subsoap avatar subsoap commented on July 18, 2024

Multiple &zwsp; with no spaces between are considered a single word. Probably want them each to be considered their own word no matter what because otherwise defeats their purpose as a timer buffer without modifying formatting.

from defold-richtext.

britzl avatar britzl commented on July 18, 2024

Good point. This is required when truncating per word.

from defold-richtext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.