Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UI Text Not Showing Apostrophes and Quotes

Discussion in 'UGUI & TextMesh Pro' started by TheWanderingBen, Aug 2, 2016.

  1. TheWanderingBen

    TheWanderingBen

    Joined:
    Nov 3, 2015
    Posts:
    98
    I'm having a strange problem, and one that's only started occurring today, even though I've been using the same story system since October.

    I'm writing a string to a UI Text element through code, very simply, like so:
    Code (CSharp):
    1. storyText.text = storyString
    For some reason, though the string itself has the correct punctuation, my text in-game won't display apostrophes or quotes in the text. I've checked the string through debugging and console output, and even, when running the game, the Unity Inspector shows the correct string, but the Text element does not display properly it on the screen:
    upload_2016-8-2_12-25-7.png

    The very first apostrophe in the story actually shows, but once I update the text again, no apostrophe or quotation displays afterward. I'm typically a lurker on these forums, since most of my issues can be resolved by a simple search, but I can't find any post about this issue. Has anybody else run into the same problem?
     
  2. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Are you using a dynamic font or custom font?

    Just to make sure the Quote glyph (u+0022) as well as both left (u+201C) and right (u+201D) quotes are contained in Courier New Bold, I tested this in TextMesh Pro and it is working fine as you can see below.



    Did you upgrade to a new release of Unity? Perhaps this is a new issue with the UI.Text or Dynamic Font system.
     
  3. TheWanderingBen

    TheWanderingBen

    Joined:
    Nov 3, 2015
    Posts:
    98
    Yep, I'm using the same Courier New Bold font, nothing special here.

    I should have mentioned, apostrophes and quotations do display in other UI Text elements perfectly fine, just not in that particular one. So I don't think it's actually the font itself, but something with the UI element.

    I'm on Unity 5.3.5f1 right now, which released back in May. Not sure why I'm getting this strange behaviour now.
     
  4. Stephan-B

    Stephan-B

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Is this the only object which you are setting the text using a script and .text property?

    Here is how I set the text using TextMesh Pro which is the same for UI.Text.

    Code (csharp):
    1. m_TextComponent.text = "I stretched and said, mid - yawn, \"Not very nice to sneak into a sleeping woman's apartment\".But his stare just continued.";
    The quote character has to be escaped which I presume you are doing as this would result in compiler errors.
     
  5. TheWanderingBen

    TheWanderingBen

    Joined:
    Nov 3, 2015
    Posts:
    98
    No there are many Text elements in which I'm setting the strings in the exact same way (in fact, the code is inside a class that I'm constantly reusing, so there shouldn't be a difference between what I'm doing with this specific Text element and other Text elements). And yes, my characters are properly escaped.

    It could be something specific to my case? Though I can't see what right now. My next step tomorrow will be to re-make that section of my scene entirely and see if I can't discover a problem by de-then-re-assembling it. But hoping somebody's seen something similar before I need to go through the trouble. It's very strange.

    Thanks for the help so far Stephan-B. At least it's helped rule out certain causes!
     
  6. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    Make a copy of you project / a backup and try out unity 5.4. With the System standard font COURBD.TTF (Courier New and the BD should mean bold) its working fine with standard text object.
     
  7. TheWanderingBen

    TheWanderingBen

    Joined:
    Nov 3, 2015
    Posts:
    98
    I'm embarrassed, but I'll shamefully write my response here in hopes that others don't make the same simple mistake.

    It was, in fact, the font itself. That part of my text I had copied from a Google Doc, whereas the rest I had written in a separate text-editor. Google Docs, like many WYSIWYG editors, had replaced my Straight Quote glyph with the Left and Right Quote glyphs. I didn't realize this, nor did I notice I was only loading the ASCII default set of my Courier New Bold font (a setting in the Import Settings of the Font).

    Since it was just that block of text, I had assumed it was something with the UI Text element itself. Apparently, it was just something with me :)

    Thanks for all your help guys. I appreciate the leads - they helped my find my mistake!
     
    Reyan62 and Multithreaded_Games like this.
  8. Multithreaded_Games

    Multithreaded_Games

    Joined:
    Jul 6, 2015
    Posts:
    122
    Holy hell, thanks for figuring this out! We just ran across this ourselves and without you having that bit of insight, I don't think we would have figured it out anytime soon. What a strange and annoying little problem.
     
    TheWanderingBen likes this.
  9. Reyan62

    Reyan62

    Joined:
    Aug 23, 2015
    Posts:
    7
    Had the same issue, thanks!
     
    TheWanderingBen likes this.
  10. artemio_morales

    artemio_morales

    Joined:
    Nov 29, 2015
    Posts:
    19
    Hey there, just ran into a similar issue on my end. Smart quotes and apostrophes were not showing correctly. My issue was that the TextMeshPro's submeshes had gotten corrupted. Not exactly sure how this happened, but I believe it was because I updated the underlying prefab to use a different font asset, which caused the TextMeshPro object to generate a new submesh, resulting in some kind of conflict.

    In any case, to solve my particular issue, all I needed to do was delete the submeshes (visible as child objects) on the TextMeshPro object, then repopulate the object with the source text.

    Hope this helps anyone who runs into a similar issue.
     
  11. Acreates

    Acreates

    Joined:
    Dec 12, 2016
    Posts:
    41
    From the Future here...just started happening to us.....