在我的系统上,我需要注册两个外部字体.TTF文件:
HamletOrNot.ttf (74 KB)
MorrisRoman-Black.ttf (67 KB)
Run Code Online (Sandbox Code Playgroud)
在创建Font()对象之前,我使用以下命令进行记录:
/* Set full path of font */
String path = filesPath + fileName;
/* Read file */
Resource resource = applicationContext.getResource( path );
File fontFile = resource.getFile();
/* Load font */
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, fontFile ));
Run Code Online (Sandbox Code Playgroud)
然后我创建了对象(我创建了多个Font()因为格式不同):
Font font = new Font( "HamletOrNot" , Font.TRUETYPE_FONT , 10 );
Font font = new Font( "HamletOrNot" , Font.TRUETYPE_FONT , 12 );
Font font = new Font( "MorrisRoman-Black" , Font.TRUETYPE_FONT , 20 ); …Run Code Online (Sandbox Code Playgroud) 我正在使用Nginx在端口80上发布静态内容,并将433重定向(使用SSL)发布到NodeJS.Nginx的配置如下:
server {
listen 443 ssl;
ssl_certificate /opt/projetos/nodejs-project-ssl/vectortowns-cert.pem;
ssl_certificate_key /opt/projetos/nodejs-project-ssl/vectortowns-key.pem;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
server_name 127.0.0.1:443;
location / {
proxy_pass https://127.0.0.1:8443;
proxy_redirect off;
proxy_set_header Host $host ;
proxy_set_header X-Real-IP $remote_addr ;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
proxy_set_header X-Forwarded-Proto https;
}
Run Code Online (Sandbox Code Playgroud)
}
使用NodeJS,Express和EJS,我将动态内容发布到端口8443,也配置为使用HTTPS.请参阅下面的javascript代码(仅对问题很重要的部分).
// other codes...
/* Enable https */
var privateKey = fs.readFileSync('/opt/projetos/nodejs-project-ssl/vectortowns-key.pem');
var certificate = fs.readFileSync('/opt/projetos/nodejs-project-ssl/vectortowns-cert.pem');
var credentials = {
key: privateKey,
cert: certificate
};
// other codes...
/* Controllers */
app.use(require('./controllers'));
https.createServer(credentials, app).listen(
configuration.server.port,
configuration.server.address,
function(){
logger.info('Server started: …Run Code Online (Sandbox Code Playgroud)