aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-07 19:05:05 +0100
committerSven Gothel <[email protected]>2023-03-07 19:05:05 +0100
commit3bad09f6b7c7f9c93a6cf385abb51a6563e8aec0 (patch)
tree456cf2320e4d8b6970bc401f25d68efa28ad2ae6 /src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
parent5e79fea8981a13d155e0b958aa3e20a546c533bb (diff)
Graph Perf: Add Region.countOutlineShape(), Font.processString(Visitor2,..), TextRegionUtil.countStringRegion() allowing to use Region.setBufferCapacity()
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
index 0547d994a..8d55c6136 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
@@ -115,6 +115,27 @@ public class TextRegionUtil {
}
/**
+ * Count required number of vertices and indices adding to given int[2] `vertIndexCount` array.
+ * <p>
+ * The region's buffer can be either set using {@link Region#setBufferCapacity(int, int)} or grown using {@link Region#growBuffer(int, int)}.
+ * </p>
+ * @param region the {@link GLRegion} sink
+ * @param font the target {@link Font}
+ * @param str string text
+ * @param vertIndexCount the int[2] storage where the counted vertices and indices are added, vertices at [0] and indices at [1]
+ * @see Region#setBufferCapacity(int, int)
+ * @see Region#growBuffer(int, int)
+ */
+ public static void countStringRegion(final Region region, final Font font, final CharSequence str, final int[/*2*/] vertIndexCount) {
+ final OutlineShape.Visitor2 visitor = new OutlineShape.Visitor2() {
+ @Override
+ public final void visit(final OutlineShape shape) {
+ region.countOutlineShape(shape, vertIndexCount);
+ } };
+ font.processString(visitor, str);
+ }
+
+ /**
* Render the string in 3D space w.r.t. the font int font em-size [0..1] at the end of an internally cached {@link GLRegion}.
* <p>
* The shapes added to the GLRegion are in font em-size [0..1].