Example #1
0
  /**
   * Render a text run with the set-up paint.
   *
   * @param c the canvas
   * @param wp the paint used to render the text
   * @param start the start of the run
   * @param end the end of the run
   * @param contextStart the start of context for the run
   * @param contextEnd the end of the context for the run
   * @param runIsRtl true if the run is right-to-left
   * @param x the x position of the left edge of the run
   * @param y the baseline of the run
   */
  private void drawTextRun(
      Canvas c,
      TextPaint wp,
      int start,
      int end,
      int contextStart,
      int contextEnd,
      boolean runIsRtl,
      float x,
      int y) {

    int flags = runIsRtl ? Canvas.DIRECTION_RTL : Canvas.DIRECTION_LTR;
    if (mCharsValid) {
      int count = end - start;
      int contextCount = contextEnd - contextStart;
      c.drawTextRun(mChars, start, count, contextStart, contextCount, x, y, flags, wp);
    } else {
      int delta = mStart;
      c.drawTextRun(
          mText,
          delta + start,
          delta + end,
          delta + contextStart,
          delta + contextEnd,
          x,
          y,
          flags,
          wp);
    }
  }