programingjd / justified

Android TextView or EditText with justified text.
Apache License 2.0
223 stars 48 forks source link

Rendering Problem with Android Studio #1

Closed lpellegr closed 10 years ago

lpellegr commented 10 years ago

Thank you for your great library! Although it works pretty well with deployed apps, when I use it on Android Studio, the Preview Windows indicates some rendering errors. It would be great if your library could be used with the preview mode of Android Studio. Below is the stacktrace:

java.awt.geom.NoninvertibleTransformException: Determinant is 0
    at java.awt.geom.AffineTransform.createInverse(AffineTransform.java:2714)
    at sun.font.GlyphLayout$SDCache.<init>(GlyphLayout.java:233)
    at sun.font.GlyphLayout$SDCache.get(GlyphLayout.java:336)
    at sun.font.GlyphLayout.layout(GlyphLayout.java:383)
    at java.awt.Font.layoutGlyphVector(Font.java:2637)
    at android.graphics.BidiRenderer.render(BidiRenderer.java:181)
    at android.graphics.BidiRenderer.renderScript(BidiRenderer.java:129)
    at android.graphics.BidiRenderer.renderText(BidiRenderer.java:107)
    at android.graphics.Paint_Delegate.native_getTextRunAdvances(Paint_Delegate.java:993)
    at android.graphics.Paint.native_getTextRunAdvances(Paint.java)
    at android.graphics.Paint.getTextRunAdvances(Paint.java:1841)
    at android.text.MeasuredText.addStyleRun(MeasuredText.java:164)
    at android.text.MeasuredText.addStyleRun(MeasuredText.java:204)
    at android.text.StaticLayout.generate(StaticLayout.java:280)
    at android.text.DynamicLayout.reflow(DynamicLayout.java:285)
    at android.text.DynamicLayout.access$000(DynamicLayout.java:36)
    at android.text.DynamicLayout$ChangeWatcher.reflow(DynamicLayout.java:639)
    at android.text.DynamicLayout$ChangeWatcher.onSpanAdded(DynamicLayout.java:658)
    at android.text.SpannableStringInternal.sendSpanAdded(SpannableStringInternal.java:314)
    at android.text.SpannableStringInternal.setSpan(SpannableStringInternal.java:138)
    at android.text.SpannableString.setSpan(SpannableString.java:46)
    at com.uncopt.android.widget.text.justify.Justify.setupScaleSpans(Justify.java:115)
    at com.uncopt.android.widget.text.justify.JustifiedTextView.onMeasure(JustifiedTextView.java:77)
    at android.view.View.measure(View.java:16987)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
    at android.view.View.measure(View.java:16987)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
    at android.view.View.measure(View.java:16987)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:314)
    at android.view.View.measure(View.java:16987)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:314)
    at android.view.View.measure(View.java:16987)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257)
    at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:447)
    at android.view.View.measure(View.java:16987)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
    at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1083)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:615)
    at android.view.View.measure(View.java:16987)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5257)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
    at android.view.View.measure(View.java:16987)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
    at android.view.View.measure(View.java:16987)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:621)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:521)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:331)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
    at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:575)
    at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:564)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
    at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:564)
    at com.android.tools.idea.rendering.RenderService.render(RenderService.java:691)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:586)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1900(AndroidLayoutPreviewToolWindowManager.java:80)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6$1.run(AndroidLayoutPreviewToolWindowManager.java:528)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
    at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6.run(AndroidLayoutPreviewToolWindowManager.java:523)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
programingjd commented 10 years ago

I found the root of the problem (ScaleSpan with multiplier value at 0f) and fixed it. The update has been pushed to maven central and should be synced soon. New version with the fix on maven is 1.3.

Ramkesh9 commented 3 years ago

Thank you for Awesome Library, i was stucked at somewhere, but your library solved my issue. Once Again Thanks!!