org.lwjgl.nanovg.NanoVG.nnvgTextGlyphPositions()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.lwjgl.nanovg.NanoVG.nnvgTextGlyphPositions()方法的一些代码示例,展示了NanoVG.nnvgTextGlyphPositions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NanoVG.nnvgTextGlyphPositions()方法的具体详情如下:
包路径:org.lwjgl.nanovg.NanoVG
类名称:NanoVG
方法名:nnvgTextGlyphPositions

NanoVG.nnvgTextGlyphPositions介绍

[英]Unsafe version of: #nvgTextGlyphPositions
[中]不安全版本:#nvgtextglyph

代码示例

代码示例来源:origin: SpinyOwl/legui

int ng = nnvgTextGlyphPositions(context, caretLineBounds[4], 0, memAddress(caretLineBytes), 0, memAddress(glyphs), maxGlyphCount);
caretx = calculateCaretPos(caretPosInText, caretLineBounds, ng, glyphs);

代码示例来源:origin: org.lwjgl/lwjgl-nanovg

/**
 * Calculates the glyph x positions of the specified text. If {@code end} is specified only the sub-string will be used.
 * 
 * <p>Measured values are returned in local coordinate space.</p>
 *
 * @param ctx       the NanoVG context
 * @param x         the text X axis coordinate
 * @param y         the text Y axis coordinate
 * @param string    the text string to measure
 * @param positions returns the glyph x positions
 */
public static int nvgTextGlyphPositions(@NativeType("NVGcontext *") long ctx, float x, float y, @NativeType("char const *") ByteBuffer string, @NativeType("NVGglyphPosition *") NVGGlyphPosition.Buffer positions) {
  if (CHECKS) {
    check(ctx);
  }
  return nnvgTextGlyphPositions(ctx, x, y, memAddress(string), memAddress(string) + string.remaining(), positions.address(), positions.remaining());
}

代码示例来源:origin: SpinyOwl/legui

/**
 * Used to get space width.
 *
 * @param context nanovg context.
 *
 * @return space width.
 */
private float getSpaceWidth(long context) {
  String s = SPACES + SPACES;
  ByteBuffer spaceBytes = null;
  try (NVGGlyphPosition.Buffer glyphs = NVGGlyphPosition.calloc(maxGlyphCount)) {
    spaceBytes = memUTF8(s);
    alignTextInBox(context, HorizontalAlign.LEFT, VerticalAlign.MIDDLE);
    nnvgTextGlyphPositions(context, 10, 0, memAddress(spaceBytes), 0, memAddress(glyphs), maxGlyphCount);
    float x1 = glyphs.get(1).x();
    float x0 = glyphs.get(0).x();
    return x1 - x0;
  } finally {
    if (spaceBytes != null) {
      memFree(spaceBytes);
    }
  }
}

代码示例来源:origin: SpinyOwl/legui

int ng = nnvgTextGlyphPositions(context, bounds[i][4], 0, memAddress(lineBytes), 0, memAddress(glyphs), maxGlyphCount);

代码示例来源:origin: org.lwjgl/lwjgl-nanovg

/**
 * Calculates the glyph x positions of the specified text. If {@code end} is specified only the sub-string will be used.
 * 
 * <p>Measured values are returned in local coordinate space.</p>
 *
 * @param ctx       the NanoVG context
 * @param x         the text X axis coordinate
 * @param y         the text Y axis coordinate
 * @param string    the text string to measure
 * @param positions returns the glyph x positions
 */
public static int nvgTextGlyphPositions(@NativeType("NVGcontext *") long ctx, float x, float y, @NativeType("char const *") CharSequence string, @NativeType("NVGglyphPosition *") NVGGlyphPosition.Buffer positions) {
  if (CHECKS) {
    check(ctx);
  }
  MemoryStack stack = stackGet(); int stackPointer = stack.getPointer();
  try {
    int stringEncodedLength = stack.nUTF8(string, false);
    long stringEncoded = stack.getPointerAddress();
    return nnvgTextGlyphPositions(ctx, x, y, stringEncoded, stringEncoded + stringEncodedLength, positions.address(), positions.remaining());
  } finally {
    stack.setPointer(stackPointer);
  }
}

代码示例来源:origin: SpinyOwl/legui

int ng = nnvgTextGlyphPositions(context, textBounds[4], 0, memAddress(textBytes), 0, memAddress(glyphs), maxGlyphCount);

代码示例来源:origin: SpinyOwl/legui

int ng = nnvgTextGlyphPositions(context, textBounds[4], 0, memAddress(textBytes), 0, memAddress(glyphs), maxGlyphCount);

相关文章