I need to draw text on a circular path. I have tried the method drawTextOnPath() . But for texts such as the "fertile window" in an image encrypted, the text rotates and cannot be read.


The code I used:
customPath2.addArc(mCircleRectF, 30F, 64.28F); customPaint2.setAntiAlias(true); customPaint2.setDither(true); customPaint2.setStrokeWidth(mCircleStrokeWidth); customPaint2.setColor(Color.parseColor("#93BE66")); customPaint2.setStyle(Paint.Style.STROKE); customPaint2.setStrokeCap(Paint.Cap.ROUND); canvas.drawPath(customPath2, customPaint2); titlePaint.setColor(Color.parseColor("#ffffff")); titlePaint.setAntiAlias(true); titlePaint.setTypeface(Typeface.MONOSPACE); titlePaint.setLetterSpacing(0.07F); titlePaint.setTextAlign(Paint.Align.CENTER); titlePaint.setTextSize(35f); canvas.drawTextOnPath("FERTILE WINDOW", customPath2, 0, 8, titlePaint); ; customPath2.addArc(mCircleRectF, 30F, 64.28F); customPaint2.setAntiAlias(true); customPaint2.setDither(true); customPaint2.setStrokeWidth(mCircleStrokeWidth); customPaint2.setColor(Color.parseColor("#93BE66")); customPaint2.setStyle(Paint.Style.STROKE); customPaint2.setStrokeCap(Paint.Cap.ROUND); canvas.drawPath(customPath2, customPaint2); titlePaint.setColor(Color.parseColor("#ffffff")); titlePaint.setAntiAlias(true); titlePaint.setTypeface(Typeface.MONOSPACE); titlePaint.setLetterSpacing(0.07F); titlePaint.setTextAlign(Paint.Align.CENTER); titlePaint.setTextSize(35f); canvas.drawTextOnPath("FERTILE WINDOW", customPath2, 0, 8, titlePaint); )); customPath2.addArc(mCircleRectF, 30F, 64.28F); customPaint2.setAntiAlias(true); customPaint2.setDither(true); customPaint2.setStrokeWidth(mCircleStrokeWidth); customPaint2.setColor(Color.parseColor("#93BE66")); customPaint2.setStyle(Paint.Style.STROKE); customPaint2.setStrokeCap(Paint.Cap.ROUND); canvas.drawPath(customPath2, customPaint2); titlePaint.setColor(Color.parseColor("#ffffff")); titlePaint.setAntiAlias(true); titlePaint.setTypeface(Typeface.MONOSPACE); titlePaint.setLetterSpacing(0.07F); titlePaint.setTextAlign(Paint.Align.CENTER); titlePaint.setTextSize(35f); canvas.drawTextOnPath("FERTILE WINDOW", customPath2, 0, 8, titlePaint); )); customPath2.addArc(mCircleRectF, 30F, 64.28F); customPaint2.setAntiAlias(true); customPaint2.setDither(true); customPaint2.setStrokeWidth(mCircleStrokeWidth); customPaint2.setColor(Color.parseColor("#93BE66")); customPaint2.setStyle(Paint.Style.STROKE); customPaint2.setStrokeCap(Paint.Cap.ROUND); canvas.drawPath(customPath2, customPaint2); titlePaint.setColor(Color.parseColor("#ffffff")); titlePaint.setAntiAlias(true); titlePaint.setTypeface(Typeface.MONOSPACE); titlePaint.setLetterSpacing(0.07F); titlePaint.setTextAlign(Paint.Align.CENTER); titlePaint.setTextSize(35f); canvas.drawTextOnPath("FERTILE WINDOW", customPath2, 0, 8, titlePaint);
source share