Chinese chars lost from PDF export
in
Programming Questions
•
2 years ago
I need generate a PDF file with some chinese chars, the main structure of my code likes that:
- import processing.pdf.*;
PFont myFont=createFont("微软雅黑",24,true);//微软雅黑 is the name of a chinese font.
boolean recordPDF = false; - void setup(){
size(640,480);
smooth();
} - void draw(){
background(255);
fill(0);
textFont(myFont,48);
textAlign(CENTER,CENTER);
text("显示控制窗外框design",width/2,height/2);//to display both chinese and english chars.
} - void keyReleased() {
if (key =='r' || key =='R') {
if (recordPDF == false) {
beginRecord(PDF, timestamp()+".pdf");
println("recording started");
recordPDF = true;
}
}
else if (key == 'e' || key =='E') {
if (recordPDF) {
println("recording stopped");
endRecord();
recordPDF = false;
}
}
} - String timestamp() {
Calendar now = Calendar.getInstance();
return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
}
-
Both chinese and english chars display correctly in the sketch window, but only english chars can be found in the final output PDF file, all the chinese chars lost.
-
So anyone can help me? thx a lot.
1