Beispiel #1
0
  protected StandardGlyphVector createGV() {
    FontRenderContext frc = source.getFRC();
    int flags = source.getLayoutFlags();
    char[] context = source.getChars();
    int start = source.getStart();
    int length = source.getLength();

    GlyphLayout gl = GlyphLayout.get(null); // !!! no custom layout engines
    gv = gl.layout(font, frc, context, start, length, flags, null); // ??? use textsource
    GlyphLayout.done(gl);

    return gv;
  }
Beispiel #2
0
 public void drawFont(String text, int x, int y, boolean center) {
   layout.setText(font, text);
   float w = layout.width;
   float h = layout.height;
   if (center) {
     font.draw(batch, text, x - w / 2, y - h / 2);
   } else font.draw(batch, text, x, y);
 }
  public void drawString(String s, float x, float y, float fontSize, boolean centered, Color col) {
    if (s == null) return;
    myTextureChecker.onString(myFont.getRegion().getTexture());
    myFont.setColor(col);
    myFont.getData().setScale(fontSize / myOrigFontHeight);
    if (!centered) {
      myFont.draw(mySpriteBatch, s, x, y);
      return;
    }

    // http://www.badlogicgames.com/wordpress/?p=3658
    layout.reset();
    layout.setText(myFont, s);
    x -= layout.width / 2;
    y -= layout.height / 2;
    myFont.draw(mySpriteBatch, layout, x, y);
  }