Package de.lessvoid.nifty.spi.render

Examples of de.lessvoid.nifty.spi.render.RenderFont


    }
    if (fontCache.containsKey(filename)) {
      return fontCache.get(filename);
    } else {
      NiftyStopwatch.start();
      RenderFont newFont = renderDevice.createFont(filename);
      fontCache.put(filename, newFont);
      NiftyStopwatch.stop("RenderDevice.createFont(" + filename + ")");
      return newFont;
    }
  }
View Full Code Here


    }
    renderLines(w, r, textLines);
  }

  private void renderLines(final Element w, final NiftyRenderEngine r, String[] lines) {
    RenderFont font = ensureFont(r);

    boolean stateSaved = prepareRenderEngine(r, font);

    int y = getStartYWithVerticalAlign(lines.length * font.getHeight(), w.getHeight(), textVAlign);
    for (String line : lines) {
      int yy = w.getY() + y;
      if (Math.abs(xoffsetHack) > 0) {
        int fittingOffset = FontHelper.getVisibleCharactersFromStart(font, line, Math.abs(xoffsetHack), 1.0f);
        String cut = line.substring(0, fittingOffset);
        String substring = line.substring(fittingOffset, line.length());
        int xx = w.getX() + xoffsetHack + font.getWidth(cut);
        renderLine(xx, yy, substring, r, selectionStart - fittingOffset, selectionEnd - fittingOffset);
      } else {
        int xx = w.getX() + getStartXWithHorizontalAlign(font.getWidth(line), w.getWidth(), textHAlign);
        renderLine(xx, yy, line, r, selectionStart, selectionEnd);
      }
      y += font.getHeight();
    }

    restoreRenderEngine(r, stateSaved);
  }
View Full Code Here

      r.restoreState();
    }
  }

  private RenderFont ensureFont(final NiftyRenderEngine r) {
    RenderFont font = r.getFont();
    if (font == null) {
      font = this.font;
    }
    return font;
  }
View Full Code Here

    public void dispose() {
    }
  }

  private String[] wrapText(final int width, final NiftyRenderEngine r, final String[] textLines) {
    RenderFont font = ensureFont(r);
    List < String > lines = new ArrayList < String > ();
    for (String line : textLines) {
      int lineLengthInPixel = font.getWidth(line);
      if (lineLengthInPixel > width) {
        lines.addAll(new TextBreak(line, width, font).split());
      } else {
        lines.add(line);
      }
View Full Code Here

TOP

Related Classes of de.lessvoid.nifty.spi.render.RenderFont

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.