Why does single line text have new line?

shunsuke_stackoverflow

I have been using attributed text for UILabel of UITableViewCell. Sometimes,even if text is single line but, text has new line.

My code is here

if notnullCheck(catchcopy){

                //行間
                let attributedText = NSMutableAttributedString(string: catchcopy!)
                let paragraphStyle = NSMutableParagraphStyle()
                paragraphStyle.lineSpacing = 5
                attributedText.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, attributedText.length))

                self.catchcopyLabel.attributedText = attributedText


            }
            self.catchcopyLabel.sizeToFit()

The text height is 33 when multi line text is. The text height is 14 when single line text is. But sometimes, the text height is 19 when single line text is. when line height is 19,the text has new line.

What is this problem?

The following text is debug log.

(98.0, 14.0)
勤務地表記確認

(230.0, 19.0)
ケイサイカキンなしんこうぃあ 02

Both texts are also single line.But height is not same. enter image description here

Satachito

Assuming you are using 'HiraKakuProN-W6' font and its size is 14.

It's not a matter of new line but of Japanese space character(全角スペース).

If you delete Japanese space character, you will get height of 14.

I have encountered this kind of strangeness since many years ago,

so I think it's BUG of HiraXXXXX-XX font.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

If a sentence does not fit in a single line, break into a new line where indicated

From Dev

Batch, if line does not have text, echo previous line

From Dev

Why is this text pushing the div onto a new line?

From Dev

Split rows that have multiline text and single line text

From Dev

Why does a percentage margin cause a new line?

From Dev

Why does PowerShell return a new line?

From Dev

Why does a percentage margin cause a new line?

From Dev

why does \n not go to a new line

From Dev

why does <span> opens a new line block?

From Dev

Why does the second text block have so much higher line height than the first despite NSAttributedString disagreeing?

From Dev

Why does this line not output my text file?

From Dev

Text blocks in a single line

From Dev

Single line delimited text

From Dev

How to have multiple CSS color transitions on a single text line?

From Dev

Does AWK have similar ability as SED to find line ranges based on text in line rather than line number?

From Dev

How to have HTML New Line Feature in Android Text View?

From Dev

Make HTML text have 2 colors without making new line

From Dev

How to have HTML New Line Feature in Android Text View?

From Dev

after <text>, in cshtml, single <br /> does not give line break

From Dev

Why does Javascript ignore single line HTML Comments?

From Dev

Does HTML comment <!-- act as a single-line comment in JavaScript, and why?

From Dev

Why does this single line of code cause Visual Studio to crash?

From Dev

Why does ls not recognize this declared single-line variable?

From Dev

Line Spacing for UILabel with a single line of text

From Dev

convert multiple line text to single line in R

From Dev

Why does my image have a thick black line around?

From Dev

Why does this canvas line have color in Chrome but not Firefox?

From Dev

Why does setup.py usually not have a shebang line?

From Dev

Why does this canvas line have color in Chrome but not Firefox?

Related Related

  1. 1

    If a sentence does not fit in a single line, break into a new line where indicated

  2. 2

    Batch, if line does not have text, echo previous line

  3. 3

    Why is this text pushing the div onto a new line?

  4. 4

    Split rows that have multiline text and single line text

  5. 5

    Why does a percentage margin cause a new line?

  6. 6

    Why does PowerShell return a new line?

  7. 7

    Why does a percentage margin cause a new line?

  8. 8

    why does \n not go to a new line

  9. 9

    why does <span> opens a new line block?

  10. 10

    Why does the second text block have so much higher line height than the first despite NSAttributedString disagreeing?

  11. 11

    Why does this line not output my text file?

  12. 12

    Text blocks in a single line

  13. 13

    Single line delimited text

  14. 14

    How to have multiple CSS color transitions on a single text line?

  15. 15

    Does AWK have similar ability as SED to find line ranges based on text in line rather than line number?

  16. 16

    How to have HTML New Line Feature in Android Text View?

  17. 17

    Make HTML text have 2 colors without making new line

  18. 18

    How to have HTML New Line Feature in Android Text View?

  19. 19

    after <text>, in cshtml, single <br /> does not give line break

  20. 20

    Why does Javascript ignore single line HTML Comments?

  21. 21

    Does HTML comment <!-- act as a single-line comment in JavaScript, and why?

  22. 22

    Why does this single line of code cause Visual Studio to crash?

  23. 23

    Why does ls not recognize this declared single-line variable?

  24. 24

    Line Spacing for UILabel with a single line of text

  25. 25

    convert multiple line text to single line in R

  26. 26

    Why does my image have a thick black line around?

  27. 27

    Why does this canvas line have color in Chrome but not Firefox?

  28. 28

    Why does setup.py usually not have a shebang line?

  29. 29

    Why does this canvas line have color in Chrome but not Firefox?

HotTag

Archive