Package com.badlogic.gdx.graphics.g2d.BitmapFont

Examples of com.badlogic.gdx.graphics.g2d.BitmapFont.Glyph


    buf.append(xmlOpen).append("chars count=").append(quote(glyphs.size)).append(xmlClose).append("\n");

    // CHAR definitions
    for (int i = 0; i < glyphs.size; i++) {
      Glyph g = glyphs.get(i);
      buf.append(xmlTab).append(xmlOpen).append("char id=").append(quote(String.format("%-6s", g.id), true)).append("x=")
        .append(quote(String.format("%-5s", g.srcX), true)).append("y=").append(quote(String.format("%-5s", g.srcY), true))
        .append("width=").append(quote(String.format("%-5s", g.width), true)).append("height=")
        .append(quote(String.format("%-5s", g.height), true)).append("xoffset=")
        .append(quote(String.format("%-5s", g.xoffset), true)).append("yoffset=")
        .append(quote(String.format("%-5s", fontData.flipped ? g.yoffset : -(g.height + g.yoffset)), true))
        .append("xadvance=").append(quote(String.format("%-5s", g.xadvance), true)).append("page=")
        .append(quote(String.format("%-5s", g.page), true)).append("chnl=").append(quote(0, true)).append(xmlCloseSelf)
        .append("\n");
    }

    if (xml) buf.append("\t</chars>\n");

    // KERNINGS
    int kernCount = 0;
    StringBuilder kernBuf = new StringBuilder();
    for (int i = 0; i < glyphs.size; i++) {
      for (int j = 0; j < glyphs.size; j++) {
        Glyph first = glyphs.get(i);
        Glyph second = glyphs.get(j);
        int kern = first.getKerning((char)second.id);
        if (kern != 0) {
          kernCount++;
          kernBuf.append(xmlTab).append(xmlOpen).append("kerning first=").append(quote(first.id)).append(" second=")
            .append(quote(second.id)).append(" amount=").append(quote(kern, true)).append(xmlCloseSelf).append("\n");
View Full Code Here


      .append(xmlClose)
      .append("\n");
   
    //CHAR definitions
    for (int i=0; i<glyphs.size; i++) {
      Glyph g = glyphs.get(i);
      buf.append(xmlTab)
        .append(xmlOpen)
        .append("char id=")
        .append(quote( String.format("%-5s", g.id), true ))
        .append("x=").append(quote( String.format("%-5s", g.srcX), true ) )
        .append("y=").append(quote( String.format("%-5s", g.srcY), true ) )
        .append("width=").append(quote( String.format("%-5s", g.width), true ) )
        .append("height=").append(quote( String.format("%-5s", g.height), true ) )
        .append("xoffset=").append(quote( String.format("%-5s", g.xoffset), true ) )
        .append("yoffset=").append(quote( String.format("%-5s", fontData.flipped ? g.yoffset : -(g.height + g.yoffset) ), true ) )
        .append("xadvance=").append(quote( String.format("%-5s", g.xadvance), true ) )
        .append("page=").append(quote( String.format("%-5s", g.page), true ) )
        .append("chnl=").append(quote(0, true))
        .append(xmlCloseSelf)
        .append("\n");
    }
   
    if (xml)
      buf.append("\t</chars>\n");
   
    //KERNINGS
    int kernCount = 0;
    StringBuilder kernBuf = new StringBuilder();
    for (int i = 0; i < glyphs.size; i++) {
      for (int j = 0; j < glyphs.size; j++) {
        Glyph first = glyphs.get(i);
        Glyph second = glyphs.get(j);
        int kern = first.getKerning((char)second.id);
        if (kern!=0) {
          kernCount++;
          kernBuf.append(xmlTab)
              .append(xmlOpen)
View Full Code Here

            start++;
            continue;
          }
          start++;
        }
        Glyph g = font.data.getGlyph(ch);
        if (g == null) continue;
        tmpGlyphCount[g.page]++;
      }
      // require that many for each page
      for (int i = 0, n = tmpGlyphCount.length; i < n; i++)
View Full Code Here

  }

  private float addToCache (CharSequence str, float x, float y, int start, int end) {
    float startX = x;
    BitmapFont font = this.font;
    Glyph lastGlyph = null;
    BitmapFontData data = font.data;
    if (data.scaleX == 1 && data.scaleY == 1) {
      while (start < end) {
        char ch = str.charAt(start++);
        if (ch == '[' && font.markupEnabled) {
          if (!(start < end && str.charAt(start) == '[')) { // non escaped '['
            start += parseAndSetColor(str, start, end) + 1;
            continue;
          }
          start++;
        }
        lastGlyph = data.getGlyph(ch);
        if (lastGlyph != null) {
          addGlyph(lastGlyph, x + lastGlyph.xoffset, y + lastGlyph.yoffset, lastGlyph.width, lastGlyph.height);
          x += lastGlyph.xadvance;
          break;
        }
      }
      while (start < end) {
        char ch = str.charAt(start++);
        if (ch == '[' && font.markupEnabled) {
          if (!(start < end && str.charAt(start) == '[')) { // non escaped '['
            start += parseAndSetColor(str, start, end) + 1;
            continue;
          }
          start++;
        }
        Glyph g = data.getGlyph(ch);
        if (g != null) {
          x += lastGlyph.getKerning(ch);
          lastGlyph = g;
          addGlyph(lastGlyph, x + g.xoffset, y + g.yoffset, g.width, g.height);
          x += g.xadvance;
        }
      }
    } else {
      float scaleX = data.scaleX, scaleY = data.scaleY;
      while (start < end) {
        char ch = str.charAt(start++);
        if (ch == '[' && font.markupEnabled) {
          if (!(start < end && str.charAt(start) == '[')) { // non escaped '['
            start += parseAndSetColor(str, start, end) + 1;
            continue;
          }
          start++;
        }
        lastGlyph = data.getGlyph(ch);
        if (lastGlyph != null) {
          addGlyph(lastGlyph, //
            x + lastGlyph.xoffset * scaleX, //
            y + lastGlyph.yoffset * scaleY, //
            lastGlyph.width * scaleX, //
            lastGlyph.height * scaleY);
          x += lastGlyph.xadvance * scaleX;
          break;
        }
      }
      while (start < end) {
        char ch = str.charAt(start++);
        if (ch == '[' && font.markupEnabled) {
          if (!(start < end && str.charAt(start) == '[')) { // non escaped '['
            start += parseAndSetColor(str, start, end) + 1;
            continue;
          }
          start++;
        }
        Glyph g = data.getGlyph(ch);
        if (g != null) {
          x += lastGlyph.getKerning(ch) * scaleX;
          lastGlyph = g;
          addGlyph(lastGlyph, //
            x + g.xoffset * scaleX, //
View Full Code Here

  }

  private float addToCache (CharSequence str, float x, float y, int start, int end) {
    float startX = x;
    BitmapFont font = this.font;
    Glyph lastGlyph = null;
    if (font.data.scaleX == 1 && font.data.scaleY == 1) {
      while (start < end) {
        lastGlyph = font.data.getGlyph(str.charAt(start++));
        if (lastGlyph != null) {
          addGlyph(lastGlyph, x + lastGlyph.xoffset, y + lastGlyph.yoffset, lastGlyph.width, lastGlyph.height);
          x += lastGlyph.xadvance;
          break;
        }
      }
      while (start < end) {
        char ch = str.charAt(start++);
        Glyph g = font.data.getGlyph(ch);
        if (g != null) {
          x += lastGlyph.getKerning(ch);
          lastGlyph = g;
          addGlyph(lastGlyph, x + g.xoffset, y + g.yoffset, g.width, g.height);
          x += g.xadvance;
        }
      }
    } else {
      float scaleX = font.data.scaleX, scaleY = font.data.scaleY;
      while (start < end) {
        lastGlyph = font.data.getGlyph(str.charAt(start++));
        if (lastGlyph != null) {
          addGlyph(lastGlyph, //
            x + lastGlyph.xoffset * scaleX, //
            y + lastGlyph.yoffset * scaleY, //
            lastGlyph.width * scaleX, //
            lastGlyph.height * scaleY);
          x += lastGlyph.xadvance * scaleX;
          break;
        }
      }
      while (start < end) {
        char ch = str.charAt(start++);
        Glyph g = font.data.getGlyph(ch);
        if (g != null) {
          x += lastGlyph.getKerning(ch) * scaleX;
          lastGlyph = g;
          addGlyph(lastGlyph, //
            x + g.xoffset * scaleX, //
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.graphics.g2d.BitmapFont.Glyph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.