mathew-kurian / TextJustify-Android

:page_facing_up: Android Text Full Jusiftication / Wrapping / Justify / Hyphenate - V2.0
https://github.com/bluejamesbond/TextJustify-Android/wiki
Apache License 2.0
1.86k stars 370 forks source link

Setting FORMATTED_TEXT will remove the period from text #92

Open ciscorucinski opened 9 years ago

ciscorucinski commented 9 years ago

There is an issue with Justified text that is set with FORMATTED_TEXT.

With Justification, if the last line ends with a period, then it will not be stretched out to fill the line. This period is removed with FORMATTED_TEXT.

If you change nothing but FORMATTED_TEXT to be PLAIN_TEXT then the justification works perfectly. So the issue is dealing with FORMATTED_TEXT

mathew-kurian commented 9 years ago

Screenshots?

ciscorucinski commented 9 years ago

screenshot_2015-08-10-07-46-42 screenshot_2015-08-10-07-49-43

ciscorucinski commented 9 years ago

John Hammond text.

1st - PLAIN_TEXT : (period, not stretched) 2nd - FORMATTED_TEXT : (no period, stretched)

mathew-kurian commented 9 years ago

The correct way to perform justification is the 1st way you mentioned. The 2nd way seems to be a bug (although the tests I have written seem to show otherwise). Can you provide some code?

ciscorucinski commented 9 years ago

Yes, I only noticed this when I was testing the issue on my last question. Without that, I would never have found this bug.

ViewHolder: https://gist.github.com/ciscorucinski/02b8ba7ca519cd894ed7

This code works; however change PLAIN_TEXT to FORMATTED_TEXT to see the issue.

ciscorucinski commented 9 years ago

I updated the gist because it was out-of-date from this issue I was having. Now it matches my code.

ciscorucinski commented 9 years ago

I have reduced this down to the combination of FORMATTED_TEXT and TextAlignment.JUSTIFIED.

Something with that will remove the period which causes the last-line-alignment issue

mathew-kurian commented 9 years ago

@ciscorucinski Try to set justification via. JustifySpan. Example: https://github.com/bluejamesbond/TextJustify-Android/blob/master/sample/src/main/java/com/bluejamesbond/text/sample/test/ChineseCharacterTest.java#L66

And let me know if that produces the same issue.

ciscorucinski commented 9 years ago

hmmm, that is a lot of extra and more complex code. Is that the simpliest way to add JustifiedSpan???

This issue is not how I am implementing my code, I just found it on accident when I forgot to change back to PLAIN_TEXT.

mathew-kurian commented 9 years ago

You can add JustifiedSpan as you would any Android span. I was just showing you an example where I used JustifiedSpan.

ciscorucinski commented 9 years ago

I never programmed with Spans before.

But to go back, using TextAlignment.JUSTIFIED with FORMATTED_TEXT works. it justifies the text, all that you have to do is figure out why the period was removed. Off-by-one error? something else?

mathew-kurian commented 9 years ago

I will mark this issue as a bug. I don't think I have time to fix it at the moment; possibly in the coming weeks. Thanks for catching it!

ciscorucinski commented 9 years ago

I understand the concept of Spans, just never programmed with them yet. Yeah, I understand that the FORMATTED_TEXT would allow you to justify a subset of the block, but it seems like this would be the defacto way of justifying the whole FORMATTED_TEXT block. I assume this would not stop you from add specific spans in addition.

Take your time. I am implementing my solution with PLAIN_TEXT anyway.