Package com.badlogic.gdx.graphics.g2d

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


  @Override
  public void touchDragged (float x, float y, int pointer) {
  }

  public boolean keyDown (int keycode) {
    final BitmapFont font = style.font;

    if (parent.keyboardFocusedActor == this) {
      // clipboard
      if (Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT)) {
        if (keycode == Keys.V) {
          String content = clipboard.getContents();
          if (content != null) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < content.length(); i++) {
              char c = content.charAt(i);
              if (font.containsCharacter(c)) {
                builder.append(c);
              }
            }
            content = builder.toString();
            text = text.substring(0, cursor) + content + text.substring(cursor, text.length());
            cursor += content.length();
            font.computeGlyphAdvancesAndPositions(text, glyphAdvances, glyphPositions);
          }
        }
        if (keycode == Keys.C) {
          if (hasSelection) {
            int minIndex = Math.min(cursor, selectionStart);
View Full Code Here


    }
    return false;
  }

  public boolean keyTyped (char character) {
    final BitmapFont font = style.font;

    if (parent.keyboardFocusedActor == this) {
      if (character == 8 && (cursor > 0 || hasSelection)) {
        if (!hasSelection) {
          text = text.substring(0, cursor - 1) + text.substring(cursor);
          cursor--;
          font.computeGlyphAdvancesAndPositions(text, glyphAdvances, glyphPositions);
        } else {
          int minIndex = Math.min(cursor, selectionStart);
          int maxIndex = Math.max(cursor, selectionStart);

          text = (minIndex > 0 ? text.substring(0, minIndex) : "")
            + (maxIndex < text.length() ? text.substring(maxIndex, text.length()) : "");
          cursor = minIndex;
          font.computeGlyphAdvancesAndPositions(text, glyphAdvances, glyphPositions);
          hasSelection = false;
        }
      }
      if (character == 127 && (cursor < text.length() || hasSelection)) {
        if (!hasSelection) {
          text = text.substring(0, cursor) + text.substring(cursor + 1);
          font.computeGlyphAdvancesAndPositions(text, glyphAdvances, glyphPositions);
        } else {
          int minIndex = Math.min(cursor, selectionStart);
          int maxIndex = Math.max(cursor, selectionStart);

          text = (minIndex > 0 ? text.substring(0, minIndex) : "")
            + (maxIndex < text.length() ? text.substring(maxIndex, text.length()) : "");
          cursor = minIndex;
          font.computeGlyphAdvancesAndPositions(text, glyphAdvances, glyphPositions);
          hasSelection = false;
        }
      }
      if (font.containsCharacter(character)) {
        if (!hasSelection) {
          text = text.substring(0, cursor) + character + text.substring(cursor, text.length());
          cursor++;
          font.computeGlyphAdvancesAndPositions(text, glyphAdvances, glyphPositions);
        } else {
          int minIndex = Math.min(cursor, selectionStart);
          int maxIndex = Math.max(cursor, selectionStart);

          text = (minIndex > 0 ? text.substring(0, minIndex) : "")
            + (maxIndex < text.length() ? text.substring(maxIndex, text.length()) : "");
          cursor = minIndex;
          text = text.substring(0, cursor) + character + text.substring(cursor, text.length());
          cursor++;
          font.computeGlyphAdvancesAndPositions(text, glyphAdvances, glyphPositions);
          hasSelection = false;
        }
      }
      if (listener != null) listener.keyTyped(this, character);
      return true;
View Full Code Here

  /** Sets the text of this text field.
   * @param text the text */
  public void setText (String text) {
    if (text == null) throw new IllegalArgumentException("text must not be null");

    BitmapFont font = style.font;

    this.text = text;
    this.cursor = 0;
    this.hasSelection = false;
    font.computeGlyphAdvancesAndPositions(text, this.glyphAdvances, this.glyphPositions);

    textBounds.set(font.getBounds(text));
    textBounds.height -= font.getDescent() * 2;
    font.computeGlyphAdvancesAndPositions(text, glyphAdvances, glyphPositions);
  }
View Full Code Here

    fonts.put(name, font);
    if (defaultFont == null) defaultFont = font;
  }

  static public BitmapFont getFont (String name) {
    BitmapFont font = fonts.get(name);
    if (font == null) throw new IllegalArgumentException("Font not found: " + name);
    return font;
  }
View Full Code Here

        //Ces deux variable indiquent les fichier à utiliser pour la police / la taille, et la couleur (voir le
        //programme "hiero" que je vais (ou ai déjà) ajouté au repository (data/font -> 9Mo)
        //Voici les sept combinaisons que tu peux tester pour le moment :
        // "ar16ora" / "ar40deg" / "ar12whi" / "ar13whi" (défaut) / "ar14whi" /"ar15whi" / "inf16grey"
        //m_font = new BitmapFont();
        m_font = new BitmapFont(Gdx.files.internal("data/font/ar13whi.fnt"), Gdx.files.internal("data/font/ar13whi.png"), false); //TODO: change the font/size
        //m_font.scale(size);
    }
View Full Code Here

            m_path = "ar13whi";
        } else {
            m_path = font;
        }

        m_font = new BitmapFont(Gdx.files.internal("data/font/" + font + ".fnt"), Gdx.files.internal("data/font/" + font + ".png"), false); //TODO: change the font/size
        //m_font.scale(size);
    }
View Full Code Here

        m_stage = new Stage(0, 0, true);

        m_map = null;

        m_font = new BitmapFont();

        m_entityGroup = new Group("EntityGroup");
        m_menuGroup = new Group("MenuGroup");

        m_stage.addActor(m_entityGroup);
View Full Code Here

    @Override
    public void stopContact(String firstEntity, String secondEntity, Vector2D normal, Vector2D point) {
    }

    public float calcWidth(String s, String font) {
        BitmapFont myFont = new BitmapFont(Gdx.files.internal("data/font/" + font + ".fnt"), Gdx.files.internal("data/font/" + font + ".png"), false); //TODO: change the font/size
        float res = myFont.getBounds(s).width;
        return res;
    }
View Full Code Here

    public void addTextEntity(String name, WorldTextEntity entity) {
        m_worldTextEntities.put(name, entity);
    }

    public float calcWidth(String s, String font) {
        BitmapFont myFont = new BitmapFont(Gdx.files.internal("data/font/" + font + ".fnt"), Gdx.files.internal("data/font/" + font + ".png"), false); //TODO: change the font/size
        float res = myFont.getBounds(s).width;
        return res;
    }
View Full Code Here

            }
        }
    }

    public float calcWidth(String s, String font) {
        BitmapFont myFont = new BitmapFont(Gdx.files.internal("data/font/" + font + ".fnt"), Gdx.files.internal("data/font/" + font + ".png"), false); //TODO: change the font/size
        float res = myFont.getBounds(s).width;
        return res;
    }
View Full Code Here

TOP

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

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.