Skip to content
This repository has been archived by the owner on Apr 27, 2019. It is now read-only.

Hyphenation #41

Closed
muriloandrade opened this issue Dec 21, 2014 · 8 comments
Closed

Hyphenation #41

muriloandrade opened this issue Dec 21, 2014 · 8 comments

Comments

@muriloandrade
Copy link
Contributor

Hi,
I saw you made some amazing improvements in the new version of TextJustify, including the hyphenation, congratulations.

Now I’m trying to implement this new version into my project but I’m facing an issue.

If I right understand, the new way to get texts hyphenatated is:

docView.getDocumentLayoutParams().setHyphenator(new Hyphenator(HyphenPattern.PT));
docView.getDocumentLayoutParams().setHyphenated(true);

This way, nothing happens, seems like LayoutParams.setHyphenator() method will always just return (without set).
So I made some changes in this method and have the hyphenator settled.

But now, I’m facing an Exception:

java.util.ConcurrentModificationException
at java.util.LinkedList$LinkIterator.next(LinkedList.java:124)
at com.bluejamesbond.text.DocumentLayout.measure(DocumentLayout.java:222)
at com.bluejamesbond.text.DocumentView.onMeasure(DocumentView.java:142) …

Let me know if you need more details. Thank you.

@mathew-kurian
Copy link
Owner

I'm sorry for late reply. Are you setting the text outside of the ui thread?

@muriloandrade
Copy link
Contributor Author

Hi.
No, I'm working only on the main thread. Seems like the iterator.add() at line 379 conflicts with unitIterator.next() at line 222.

@mathew-kurian
Copy link
Owner

Can you provide your code that loads the data into textview? Thanks. I'll look at this tonight.

@muriloandrade
Copy link
Contributor Author

Actually I made it very simple for testing purpose.

    documentView = (DocumentView) findViewById(R.id.documentView);
    documentView.getDocumentLayoutParams().setTextAlignment(TextAlignment.JUSTIFIED);
    documentView.getDocumentLayoutParams().setHyphenator(new Hyphenator(HyphenPattern.PT));
    documentView.getDocumentLayoutParams().setHyphenated(true);
    documentView.setText(getString(R.string.mancini), true);

And the string resource:
<string name="mancini">Vágner Mancini hoje é um sujeito tão angustiado quanto otimista, por mais que pareça uma contradição. O técnico do Botafogo tem a difícil missão de salvar o time do rebaixamento no Campeonato Brasileiro, apesar de todas as dificuldades que o próprio clube impõe a seu trabalho - salários atrasados, afastamento de jogadores importantes, dívidas que ameaçam até as poucas chances que ainda existem de permanência na Série A em 2015. Na manhã desta segunda-feira, Mancini falou ao blog.</string>

@mathew-kurian
Copy link
Owner

@muriloandrade Good find. I have fixed the bug in the latest push. I have added a test to the sample app as well.

EDIT. Bugs persist. Let me fix.

@mathew-kurian
Copy link
Owner

@muriloandrade Fixed

@muriloandrade
Copy link
Contributor Author

Thank you for the fix.
But now I'm getting the text justified but not hyphenated.
I may be missing a step, so, no rush, but can you provide me an example on how to use?
Thank you again.

@mathew-kurian
Copy link
Owner

@muriloandrade It does hyphenate. I have put your exact code into the the sample demo which you can download at https://play.google.com/store/apps/details?id=com.bluejamesbond.text.sample

Just click on the "Hyphenated Test"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants