How can I draw text on a circle?

Hello

I want to draw text around the circle. I used the VectorGraphicsPainter.drawStringOnCircle method in MicroeVG. After running, no error was reported and no text was drawn. The VectorFont I use is Arial.ttf. How can I solve it?

Thank you for your reply.

Hello sonInse,

you are using the correct API of MicroVG for this purpose (VectorGraphicsPainter.drawStringOnCircle).

Would you share the snippet of code that you are running?

In addition, could you provide more information on the issue, such as:

  • what version of the VG Pack is used in your VEE Port?
  • is the issue reproduced on simulator and/or device?

Note: the version of the VG Pack is defined in the module configuration file of the VEE Port, like shown here: MicroVG — MicroEJ Documentation

For reference, please find below the snippet that I tried on the VEE Port that we provide for the NXP I.MX RT595 EVK (Supported Hardware: NXP i.MX RT595 - MicroEJ Developer):

	public static void main(String[] args) {
		MicroUI.start();

		Display display = Display.getDisplay();
		GraphicsContext graphicsContext = display.getGraphicsContext();

		VectorFont font = VectorFont.loadFont("/fonts/arial.ttf"); //$NON-NLS-1$

		Matrix matrix = new Matrix();
		matrix.setTranslate(196, 196);
		graphicsContext.setColor(Colors.WHITE);
		VectorGraphicsPainter.drawStringOnCircle(graphicsContext, "Hello World", font, 30, matrix, 150,
				Direction.COUNTER_CLOCKWISE);
		VectorGraphicsPainter.drawStringOnCircle(graphicsContext, "Hello World", font, 30, matrix, 150,
				Direction.CLOCKWISE);
		display.flush();
	}

The result is:
image

Could you test the same on your side?

Notes:

  • in the snippet above, the arial.ttf file is declared in a *.resources.list file (see Vector Fonts — MicroEJ Documentation)
  • if the parameters size or radius of the method are set to 0, then nothing is drawn (see javadoc).

Kind regards,

Thomas