Search Unity

TextMesh Pro Indent Tag

Discussion in 'UGUI & TextMesh Pro' started by TonyLi, Dec 19, 2019.

  1. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,692
    @Stephan_B - To reproduce indented text like this:

    upload_2019-12-19_9-58-32.png

    a dev used the <indent> tag partially into the text, so the text looks like this:

    "CONCIERGE - <indent=10%>Guten Abend, werter Herr! Herlich Wilkommen..."

    However, it produces this output:



    If we change TMP_Text.cs's ValidateHtmlTag method case 1441524: // <INDENT> from this:

    Code (csharp):
    1. m_xAdvance = tag_Indent;
    to this:

    Code (csharp):
    1. if (m_xAdvance < tag_Indent) m_xAdvance = tag_Indent;
    then it appears to work the way the dev intends:



    If this is correct, is it something that could be incorporated into a future update of TMP?

    The dev also added: "I think 'from/until line' parameters would be helpful for the <indent> tag and could also make the current <line-indent> tag redundant."
     
  2. digitalbreed

    digitalbreed

    Joined:
    Oct 14, 2017
    Posts:
    10
    Thanks for posting this, TonyLi! I was the dev in question.

    I think it's important to add that the proposed quick fix only works as expected for left-to-right text and only for cases where the existing part on the left (here: CONCIERGE) is wider than the configured indentation. If it's more narrow, it wouldn't lead to a satisfying result either, creating a loo large space between the player name on the left and the dialogue text.

    From that perspective, it would really be helpful and probably the easiest solution to define from which line on the indent should be active; and if there's an until line parameter, you could reproduce the effect of the current line-indent tag and make this redundant.
     
    TonyLi likes this.
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The <indent=10%> means to indent the text 10% of the width of the text container. As such, if the first word is more than 10% of this width, you will have overlap. This is by design.

    Having said that, I am never opposed to exploring adding variants of tags or new tags to provide added functionality. But first I need to get a better understanding of the desired results.

    In this particular case, the first line is never indented but subsequent lines are. This is sort of the reverse of paragraph indentation which only indents the first line of a paragraph which is commonly used. In your example, it looks like CONCIERGE is kind of a bullet point / ordered list style.

    Basically, this style does not indent the first line and indents subsequent lines by x. This treatment would be applied to paragraphs until the tag is closed.

    The <indent> tag is pretty clear in terms of indenting everything enclosed in the tag by a certain value.

    I guess the <indent> tag could be revised to add a "from" and "until" attributes.

    Using <indent=10% from="1" until=1> would indent just the first line by 10%.
    Using <indent=10% from="2"> would indent the text by 10% starting on the second line. The indentation would go until the end of the paragraph.

    Is "from" and "until" or "to" the right / most intuitive names for these attributes?
     
    travlake and TonyLi like this.
  4. digitalbreed

    digitalbreed

    Joined:
    Oct 14, 2017
    Posts:
    10
    English isn't my first language so I'm probably not the best person to ask about the naming, but for me it sounds pretty good.

    Because you wrote "looks like kind of a bullet point / ordered list style", I wanted to mention that I originally came from trying to build a conversation UI like the one in Disco Elysium, see e.g. this link: https://www.indiegamewebsite.com/wp-content/uploads/2019/10/Disco-Elysium-tips-guide-07.jpg – I think these guys have done a beautiful job and you can see how "indent after line 1" semantics would look in practice here.

    Thank you for the quick reply and for taking time to consider the enhancement!
     
  5. justinmshi

    justinmshi

    Joined:
    Aug 1, 2018
    Posts:
    1
    Hey! Checking in here - was anything like this ever implemented? Would be super useful for what I'm trying to do.
     
    digitalbreed likes this.
  6. gewl

    gewl

    Joined:
    May 19, 2016
    Posts:
    95
    Hi, bumping this again—could really use this, was it ever implemented?
     
  7. Placeable

    Placeable

    Joined:
    Feb 6, 2014
    Posts:
    3
    Bumping this too, this is something I'd like to see with TextMeshPro, is there any updates on this?
     
  8. Switchu_

    Switchu_

    Joined:
    Apr 30, 2018
    Posts:
    1
    Bumping. Any news on this one?
     
  9. Cioty

    Cioty

    Joined:
    Mar 28, 2019
    Posts:
    1
    Bumping. Would love to know what happened here as this would be pretty much exactly what I need.
     
    jolix and travlake like this.
  10. vlastelin

    vlastelin

    Joined:
    Mar 17, 2013
    Posts:
    3
    How are things going with "from"?