直接在应用里放你需要的字体然后自己引用(验证通过)
File file = new java.io.File(PATHImageURL +
"font/SIMHEI.TTF");
java.io.FileInputStream fi = new
java.io.FileInputStream(file);
java.io.BufferedInputStream fb = new
java.io.BufferedInputStream(fi);
Font nf =
Font.createFont(Font.TRUETYPE_FONT, fb);
nf = nf.deriveFont(Font.BOLD,
45);
g.setFont(nf);
String name="地图名片 ";
String
str="名称:"+mapCard.getName();
String
str1="地址:"+mapCard.getAddress();
String
str2="电话:"+mapCard.getTele();
String
str3="公交:"+mapCard.getTransit();
String
str4="地铁:"+mapCard.getSubway();
String
str5="其它:"+mapCard.getOthers();
Color color=new
Color(252,251,247);
g.setColor(color);
g.fillRect(0,0,
width,60);
g.setColor(Color.BLACK);
g.drawString(name,410,50);
nf =
nf.deriveFont(Font.BOLD,30);
g.setFont(nf);
g.setColor(Color.white);
g.fillRect(0,60, width,300);
g.setColor(Color.BLACK);//设置文本颜色
g.drawString(str,5,100);//向BUFFEREDIMAGE写入文字
g.drawString(str1,5,150);//向BUFFEREDIMAGE写入文字
g.drawString(str2,5,200);//向BUFFEREDIMAGE写入文字
g.drawString(str3,5,250);//向BUFFEREDIMAGE写入文字
g.drawString(str4,5,300);//向BUFFEREDIMAGE写入文字
g.drawString(str5,5,350);
g.dispose();
解决部署到bae或sae上的代码,中文水印为方块乱码问题,布布扣,bubuko.com