Skip to content

Commit bec2cc0

Browse files
authored
Merge pull request #44 from mzelzoghbi/hotfix/arabic_characters
[Fix] fixing arabic splitted characters
2 parents 84cca76 + b4079b3 commit bec2cc0

File tree

1 file changed

+6
-10
lines changed
  • androidtagview/src/main/java/co/lujun/androidtagview

1 file changed

+6
-10
lines changed

androidtagview/src/main/java/co/lujun/androidtagview/TagView.java

+6-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import android.view.View;
1717

1818
import static co.lujun.androidtagview.Utils.dp2px;
19-
import static co.lujun.androidtagview.Utils.sp2px;
2019

2120
/**
2221
* Author: lujun(http://blog.lujun.co)
@@ -83,7 +82,7 @@ public class TagView extends View {
8382
private int mLastX, mLastY;
8483

8584
private float fontH, fontW;
86-
85+
8786
private float mTouchX, mTouchY;
8887

8988
/** The ripple effect duration(default 1000ms)*/
@@ -197,14 +196,11 @@ protected void onDraw(Canvas canvas) {
197196
mPaint.setStyle(Paint.Style.FILL);
198197
mPaint.setColor(mTextColor);
199198

200-
if (mTextDirection == View.TEXT_DIRECTION_RTL){
201-
float tmpX = (isEnableCross() ? getWidth() + getHeight() : getWidth()) / 2 + fontW / 2;
202-
for (char c : mAbstractText.toCharArray()) {
203-
String sc = String.valueOf(c);
204-
tmpX -= mPaint.measureText(sc);
205-
canvas.drawText(sc, tmpX, getHeight() / 2 + fontH / 2 - bdDistance, mPaint);
206-
}
207-
}else {
199+
if (mTextDirection == View.TEXT_DIRECTION_RTL) {
200+
canvas.drawText(mAbstractText,
201+
(isEnableCross() ? getWidth() + fontW : getWidth()) / 2 - fontW / 2,
202+
getHeight() / 2 + fontH / 2 - bdDistance, mPaint);
203+
} else {
208204
canvas.drawText(mAbstractText,
209205
(isEnableCross() ? getWidth() - getHeight() : getWidth()) / 2 - fontW / 2,
210206
getHeight() / 2 + fontH / 2 - bdDistance, mPaint);

0 commit comments

Comments
 (0)