Package org.toyz.litetext

Examples of org.toyz.litetext.Font


     *
     * @return Font The Font object
     */
    static public Font loadfont(String fontname) {
   
    Font font = new Font();
    Properties fontprops = new Properties();
//    FileInputStream in;
        InputStream in;
        in = FontUtils.class.getResourceAsStream("/fonts/" + fontname + "/font.txt");
        if (in == null) {
          return null;
        }
    try {
      fontprops.load(in);
            in.close();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      return null;
    }
    finally {
      try {
        in.close();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
      font.setMaxwidth(Integer.parseInt(fontprops.getProperty("maxwidth")));
      font.setMaxheight(Integer.parseInt(fontprops.getProperty("maxheight")));
      font.setX(Integer.parseInt(fontprops.getProperty("x")));
      font.setY(Integer.parseInt(fontprops.getProperty("y")));
      font.setOldfont(Integer.parseInt(fontprops.getProperty("oldfont")));
      font.setFcols(Integer.parseInt(fontprops.getProperty("fcols")));
      font.setFrows(Integer.parseInt(fontprops.getProperty("frows")));
      for (int i = 0; i < 256; i++) {
            in = FontUtils.class.getResourceAsStream("/fonts/" + fontname + "/glyph." + i);
            if (in == null) {
              font.addGlyph(null);
        continue;
            }
      Properties gprops = new Properties();
      try {
        gprops.load(in);
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        try {
          in.close();
        } catch (IOException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
        continue;
      }
      Glyph g = new Glyph();
      g.setWidth(Integer.parseInt(gprops.getProperty("width")));
      g.setHeight(Integer.parseInt(gprops.getProperty("height")));
      g.setX(Integer.parseInt(gprops.getProperty("x")));
      g.setY(Integer.parseInt(gprops.getProperty("y")));
      g.setXadd(Integer.parseInt(gprops.getProperty("xadd")));

      try {
        in.close();
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      try {
                InputStream is = FontUtils.class.getResourceAsStream("/fonts/" + fontname + "/glyph_bmap." + i);
                g.setBmap(getBytesFromInputStream(is, g.getWidth() * g.getHeight()));
//        g.setBmap(getBytesFromFile(new File("fonts/" + fontname + "/glyph_bmap." + i)));
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return null;
      }
      font.addGlyph(g);

      }
    return font;
  }
View Full Code Here


     */
    public Font loadfontobject(String fontfile) throws IOException, ClassNotFoundException {
      FileInputStream fis;
      fis = new FileInputStream(fontfile);
      ObjectInputStream ois = new ObjectInputStream(fis);
      Font font = (Font) ois.readObject();
      ois.close();
      return font;
    }
View Full Code Here

          this.fgcolor = new int[3];
          this.fgcolor[0] = 0// #000000 Black
          this.fgcolor[1] = 0;
          this.fgcolor[2] = 0;
        }
        Font font;
    font = loadfont(fontname);
    if (font == null) {
      //log.severe("cannot load font: " + fontname);
      return null;
    }
        //log.info("font " + fontname + " loaded: " + font.toString());
        int vmargin = font.getMaxheight() / 2;
        int hmargin = font.getMaxwidth();
       
        String [] lines = wrapText(inputText, 80);
        //log.info("text wrapped into " + lines.length + " lines");
       
        this.rows = 2 * vmargin + lines.length * font.getMaxheight();

        compute_image_width(lines, font, (float)0.0);
      
        this.cols = 2 * hmargin + maxwidth;
        //log.info("image width computed: " + cols);
View Full Code Here

TOP

Related Classes of org.toyz.litetext.Font

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.