caelum / caelum-stella

O Caelum Stella visa suprir as necessidades do dia a dia do desenvolvedor brasileiro

Home Page:http://stella.caelum.com.br

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Boleto - Fontes devem ser portáveis entre sistemas

garcia-jj opened this issue · comments

Atualmente o boleto usa fonte Arial que não é encontrada em ambientes Unix.

Exception in thread "main" br.com.caelum.stella.boleto.exception.GeracaoBoletoException: br.com.caelum.stella.boleto.exception.GeracaoBoletoException: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Arial' is not available to the JVM. See the Javadoc for more details.
    at br.com.caelum.stella.boleto.transformer.GeradorDeBoleto.geraPDF(GeradorDeBoleto.java:129)
    at br.com.caelum.stella.boleto.transformer.GeradorDeBoleto.geraPDF(GeradorDeBoleto.java:113)
    at br.com.caelum.stella.boleto.transformer.GeradorDeBoleto.geraPDF(GeradorDeBoleto.java:90)
    at br.com.caelum.stella.boleto.example.BoletoBancoDoBrasilExample.main(BoletoBancoDoBrasilExample.java:53)
Caused by: br.com.caelum.stella.boleto.exception.GeracaoBoletoException: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Arial' is not available to the JVM. See the Javadoc for more details.
    at br.com.caelum.stella.boleto.transformer.GeradorDeBoleto.geraRelatorio(GeradorDeBoleto.java:101)
    at br.com.caelum.stella.boleto.transformer.GeradorDeBoleto.geraPDF(GeradorDeBoleto.java:126)
    ... 3 more
Caused by: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font 'Arial' is not available to the JVM. See the Javadoc for more details.
    at net.sf.jasperreports.engine.fonts.FontUtil.checkAwtFont(FontUtil.java:347)

Bom, isso é um problema, e já não é a primeira vez.

Precisamos de uma fonte que seja portável entre todos os SO's, e que ainda permita o boleto a manter o layout.

Nós rodamos o seguinte código para descobrir quais fontes estavam instaladas:

import java.awt.Font;
import java.awt.GraphicsEnvironment;
public class MainClass {
  public static void main(String[] a) {
    GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = e.getAllFonts(); // Get the fonts
    for (Font f : fonts) {
      System.out.println(f.getFontName());
    }
  }
}

vc pode rodar ai e nos passar qual o albiente e quais fontes existem Otávio?

PS: nos nossos testes aqui, Arial estava disponível no linux, por isso usamos. :)

Segue: https://gist.github.com/garcia-jj/3c6c91673c69c0ecacd8

Lembrei que dá para instalar o msttcorefonts no Linux. Então fiz isso e funcionou. :D

Posso fechar? Arial está bom?

Sim. Obrigado :)
On Jun 4, 2014 5:41 PM, "Mario Amaral" notifications@github.com wrote:

Posso fechar? Arial está bom?


Reply to this email directly or view it on GitHub
#108 (comment)
.