首页 > 解决方案 > 如何计算 NanoVG 中的插入符号位置?

问题描述

我想为我的 LWJGL 3 游戏创建一个文本区域,并使用 NanoVG.nvgTextBox() 渲染它,但我无法将输入字符串拆分为将显示在屏幕上的换行,然后计算插入符号的位置。

我的例子:如果屏幕显示这个: https ://i.stack.imgur.com/xeYcr.png

我希望得到这个字符串数组:[“1 2 3 4 5 6”,“7 8 9 10 11”,“12”](或类似的东西)

编辑:

代码:

NanoVG.nvgBeginFrame(ctx, window.getWidth(), window.getHeight(), 1);
NanoVG.nvgBeginPath(ctx);
NanoVG.nvgFontFaceId(ctx, font);
NanoVG.nvgFillColor(ctx, NanoVG.nvgRGBAf(1, 1, 1, 1, NVGColor.create()));
NanoVG.nvgTextBox(ctx, 100, 100, 100, string);
String[] lines = //?;
NanoVG.nvgEndFrame(ctx);

标签: javatextlwjgl

解决方案


推荐阅读