java - 如何计算 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);
解决方案
推荐阅读
- apama - 从 Apama EPL 中的“任何”类型投射时,空格是否相关?
- angular - 如何使 Accordion 动态化 - 使用 Angular 6
- excel - MS Excel 查找以匹配范围
- angular - Angular 7 中的 Charts.js - 使用时间序列的导入时间
- c++ - 如何使用 sprintf 将 uint_64 类型的数组附加到 char 数组?
- docusignapi - 如何通过 Docusign REST API 提取所有用户发送/接收的所有信封的列表(例如在报告选项卡中)?
- intellij-idea - INTELLIJ IDEA 如何在目标下设置与战争相同的工件
- maven - Apache NIFI - 1.7.1 从源代码构建
- react-native - 无法从“世博”导入世博。在本机反应
- ios - 快速过滤json数组