Java Code Examples for android.graphics.Canvas#drawTextRun()

The following examples show how to use android.graphics.Canvas#drawTextRun() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextLine.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * 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) {

    if (mCharsValid) {
        int count = end - start;
        int contextCount = contextEnd - contextStart;
        c.drawTextRun(mChars, start, count, contextStart, contextCount,
                x, y, runIsRtl, wp);
    } else {
        int delta = mStart;
        c.drawTextRun(mText, delta + start, delta + end,
                delta + contextStart, delta + contextEnd, x, y, runIsRtl, wp);
    }
}
 
Example 2
Source File: TextLineImpl23.java    From FastTextView with Apache License 2.0 3 votes vote down vote up
/**
 * 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) {
  if (mCharsValid) {
    int count = end - start;
    int contextCount = contextEnd - contextStart;
    c.drawTextRun(mChars, start, count, contextStart, contextCount, x, y, runIsRtl, wp);
  } else {
    int delta = mStart;
    c.drawTextRun(mText, delta + start, delta + end, delta + contextStart, delta + contextEnd, x, y, runIsRtl, wp);
  }
}