Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec6198bc authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "RTL and Arabic reshaping support cherry-picked from FroYo" into gingerbread

parents 9f167db9 139d6e91
Loading
Loading
Loading
Loading
+39 −10
Original line number Diff line number Diff line
@@ -305,13 +305,13 @@ public abstract class Layout {
                    if (spans[n] instanceof LeadingMarginSpan) {
                        LeadingMarginSpan margin = (LeadingMarginSpan) spans[n];

                        if (dir == DIR_RIGHT_TO_LEFT) {
                            margin.drawLeadingMargin(c, paint, right, dir, ltop,
                                                     lbaseline, lbottom, buf,
                                                     start, end, isFirstParaLine, this);
                                
                            right -= margin.getLeadingMargin(isFirstParaLine);
                        } else {
                       // if (dir == DIR_RIGHT_TO_LEFT) {
                       //     margin.drawLeadingMargin(c, paint, right, dir, ltop,
                         //                            lbaseline, lbottom, buf,
                          //                           start, end, isFirstParaLine, this);
                          //      
                         //   right -= margin.getLeadingMargin(isFirstParaLine);
                        //} else {
                            margin.drawLeadingMargin(c, paint, left, dir, ltop,
                                                     lbaseline, lbottom, buf,
                                                     start, end, isFirstParaLine, this);
@@ -320,7 +320,7 @@ public abstract class Layout {
                            if (margin instanceof LeadingMarginSpan.LeadingMarginSpan2) {
                                int count = ((LeadingMarginSpan.LeadingMarginSpan2)margin).getLeadingMarginLineCount();
                                useMargin = count > i;
                            }
                          //  }
                            left += margin.getLeadingMargin(useMargin);
                        }
                    }
@@ -364,8 +364,7 @@ public abstract class Layout {
                    Assert.assertTrue(dir == DIR_LEFT_TO_RIGHT);
                    Assert.assertNotNull(c);
                }
                // XXX: assumes there's nothing additional to be done
                c.drawText(buf, start, end, x, lbaseline, paint);
                c.drawText(buf, start, end, x, lbaseline, paint,false);
            } else {
                drawText(c, buf, start, end, dir, directions,
                    x, ltop, lbaseline, lbottom, paint, mWorkPaint,
@@ -1827,6 +1826,36 @@ public abstract class Layout {
        /* package */ Directions(short[] dirs) {
            mDirections = dirs;
        }

        static int baseDirection(Directions dir,int length) {
            if (dir == DIRS_ALL_LEFT_TO_RIGHT) {
                return DIR_LEFT_TO_RIGHT;
            } else if (dir == DIRS_ALL_RIGHT_TO_LEFT) {
                return DIR_RIGHT_TO_LEFT;
            } 

            int sum=0;
            int lastSwitch=0;
            int i=0;
            while ((i+1) < dir.mDirections.length) {
                sum+=dir.mDirections[i];//-lastSwitch;
                sum-=dir.mDirections[i+1];//-dir.mDirections[i];
                lastSwitch=dir.mDirections[i+1];
                i+=2;
            }

            if ((i+1)==dir.mDirections.length) {
                sum+=dir.mDirections[i];//-lastSwitch);
            } else if (i==dir.mDirections.length) {
                sum-=length-lastSwitch;
            }

            if (sum>=0) {
                return DIR_LEFT_TO_RIGHT;
            } else {
                return DIR_RIGHT_TO_LEFT;
            }
        }
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -1042,14 +1042,14 @@ implements CharSequence, GetChars, Spannable, Editable, Appendable,
        checkRange("drawText", start, end);

        if (end <= mGapStart) {
            c.drawText(mText, start, end - start, x, y, p);
            c.drawText(mText, start, end - start, x, y, p,true);
        } else if (start >= mGapStart) {
            c.drawText(mText, start + mGapLength, end - start, x, y, p);
            c.drawText(mText, start + mGapLength, end - start, x, y, p,true);
        } else {
            char[] buf = TextUtils.obtain(end - start);

            getChars(start, end, buf, 0);
            c.drawText(buf, 0, end - start, x, y, p);
            c.drawText(buf, 0, end - start, x, y, p,true);
            TextUtils.recycle(buf);
        }
    }
+10 −6
Original line number Diff line number Diff line
@@ -693,6 +693,7 @@ extends Layout
                 if (cur ==
                    Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC)
                    chInfo[j] = Character.DIRECTIONALITY_ARABIC_NUMBER;
		else chInfo[j] = Character.DIRECTIONALITY_LEFT_TO_RIGHT;
            }
        }

@@ -781,7 +782,7 @@ extends Layout
                cur = d;

            if (d == Character.DIRECTIONALITY_EUROPEAN_NUMBER)
                chInfo[j] = cur;
                chInfo[j] = Character.DIRECTIONALITY_LEFT_TO_RIGHT;
        }

        // dump(chdirs, n, "W7");
@@ -794,9 +795,10 @@ extends Layout
            if (d == Character.DIRECTIONALITY_LEFT_TO_RIGHT ||
                d == Character.DIRECTIONALITY_RIGHT_TO_LEFT) {
                cur = d;
            } else if (d == Character.DIRECTIONALITY_EUROPEAN_NUMBER ||
                       d == Character.DIRECTIONALITY_ARABIC_NUMBER) {
            } else if (d == Character.DIRECTIONALITY_EUROPEAN_NUMBER) {
                cur = Character.DIRECTIONALITY_RIGHT_TO_LEFT;
            } else if (d == Character.DIRECTIONALITY_ARABIC_NUMBER) {
                cur = Character.DIRECTIONALITY_LEFT_TO_RIGHT;
            } else {
                byte dd = SOR;
                int k;
@@ -808,8 +810,10 @@ extends Layout
                        dd == Character.DIRECTIONALITY_RIGHT_TO_LEFT) {
                        break;
                    }
                    if (dd == Character.DIRECTIONALITY_EUROPEAN_NUMBER ||
                        dd == Character.DIRECTIONALITY_ARABIC_NUMBER) {
                    if (dd == Character.DIRECTIONALITY_EUROPEAN_NUMBER) {
                        dd = Character.DIRECTIONALITY_LEFT_TO_RIGHT;
                        break;
                    } else if (dd == Character.DIRECTIONALITY_ARABIC_NUMBER) {
                        dd = Character.DIRECTIONALITY_RIGHT_TO_LEFT;
                        break;
                    }
@@ -1264,7 +1268,7 @@ extends Layout
    }

    public int getParagraphDirection(int line) {
        return mLines[mColumns * line + DIR] >> DIR_SHIFT;
        return mLineDirections[line] == DIRS_ALL_LEFT_TO_RIGHT? DIR_LEFT_TO_RIGHT : DIR_RIGHT_TO_LEFT;
    }

    public boolean getLineContainsTab(int line) {
+4 −4
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public class Styled
                    }

                    canvas.drawText(tmp, tmpstart, tmpend,
                                    x - ret, y + workPaint.baselineShift, workPaint);
                                    x - ret, y + workPaint.baselineShift, workPaint,false);
                } else {
                    if (needWidth) {
                        if (!haveWidth) {
@@ -139,7 +139,7 @@ public class Styled
                    }

                    canvas.drawText(tmp, tmpstart, tmpend,
                                    x, y + workPaint.baselineShift, workPaint);
                                    x, y + workPaint.baselineShift, workPaint,false);
                }
            } else {
                if (needWidth && !haveWidth) {
@@ -263,13 +263,13 @@ public class Styled

                if (canvas != null)
                    canvas.drawText(tmp, 0, tmpend,
                                    x - ret, y, paint);
                                    x - ret, y, paint,false);
            } else {
                if (needWidth)
                    ret = paint.measureText(text, start, end);

                if (canvas != null)
                    canvas.drawText(text, start, end, x, y, paint);
                    canvas.drawText(text, start, end, x, y, paint,false);
            }

            if (fmi != null) {
+1 −1
Original line number Diff line number Diff line
@@ -2818,7 +2818,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener

        public void drawText(Canvas c, int start, int end,
                             float x, float y, Paint p) {
            c.drawText(mChars, start + mStart, end - start, x, y, p);
            c.drawText(mChars, start + mStart, end - start, x, y, p,false);
        }

        public float measureText(int start, int end, Paint p) {
Loading