Commit 504cb853 by 曹玉玺

处理字体

parent 515c9134
...@@ -7,12 +7,12 @@ ADD scratch-web /apps/scratch-web/ ...@@ -7,12 +7,12 @@ ADD scratch-web /apps/scratch-web/
WORKDIR /apps/scratch-web/ WORKDIR /apps/scratch-web/
# 安装思源宋体到系统字体目录并刷新缓存 # 安装思源宋体到系统字体目录并刷新缓存
RUN yum install -y fontconfig \ #RUN yum install -y fontconfig \
&& mkdir -p /usr/share/fonts/zhichan \ # && mkdir -p /usr/share/fonts/zhichan \
&& cp /apps/scratch-web/app/base/api/impl/fonts/SourceHanSerif-Regular.ttc /usr/share/fonts/zhichan/ \ # && cp /apps/scratch-web/app/base/api/impl/fonts/SourceHanSerif-Regular.ttc /usr/share/fonts/zhichan/ \
&& chmod 644 /usr/share/fonts/zhichan/SourceHanSerif-Regular.ttc \ # && chmod 644 /usr/share/fonts/zhichan/SourceHanSerif-Regular.ttc \
&& fc-cache -fv \ # && fc-cache -fv \
&& yum clean all # && yum clean all
RUN cnpm install -S RUN cnpm install -S
CMD ["node","/apps/scratch-web/main.js"] CMD ["node","/apps/scratch-web/main.js"]
...@@ -170,7 +170,7 @@ async png2jpg (srcPng, dstJpg) { ...@@ -170,7 +170,7 @@ async png2jpg (srcPng, dstJpg) {
// var result = await this.ossClient.downfile(jpgpath); // var result = await this.ossClient.downfile(jpgpath);
var downClient=system.getObject("util.restClient"); var downClient=system.getObject("util.restClient");
var result=await downClient.execDownload(jpgpath,jpgpathtmp); var result=await downClient.execDownload(jpgpath,jpgpathtmp);
//检查是否是 png //检查是否是 png
if (await this.isPng(jpgpathtmp)) { if (await this.isPng(jpgpathtmp)) {
let pngPath = "/tmp/" + basename + ".png" let pngPath = "/tmp/" + basename + ".png"
...@@ -180,14 +180,14 @@ async png2jpg (srcPng, dstJpg) { ...@@ -180,14 +180,14 @@ async png2jpg (srcPng, dstJpg) {
await this.png2jpg(pngPath, jpgpathtmp) await this.png2jpg(pngPath, jpgpathtmp)
fs.unlink(pngPath, function (err) { }); fs.unlink(pngPath, function (err) { });
} }
//获取图片尺寸,判断是否需要横向 A4 //获取图片尺寸,判断是否需要横向 A4
var imgSize = await this._getImgSize(jpgpathtmp); var imgSize = await this._getImgSize(jpgpathtmp);
var pageFormat = 'a4'; // 默认竖向 var pageFormat = 'a4'; // 默认竖向
if (imgSize.width > imgSize.height) { if (imgSize.width > imgSize.height) {
pageFormat = 'a4r'; // 横向 A4 pageFormat = 'a4r'; // 横向 A4
} }
//转换为 eps //转换为 eps
var cmd2eps = "jpeg2ps -p " + pageFormat + " " + jpgpathtmp + " -o " + epspath; var cmd2eps = "jpeg2ps -p " + pageFormat + " " + jpgpathtmp + " -o " + epspath;
var x = await this.execClient.exec(cmd2eps); var x = await this.execClient.exec(cmd2eps);
...@@ -389,8 +389,10 @@ async png2jpg (srcPng, dstJpg) { ...@@ -389,8 +389,10 @@ async png2jpg (srcPng, dstJpg) {
//.font(__dirname+"/fonts/heiti.otf") //.font(__dirname+"/fonts/heiti.otf")
var p = new Promise(function (resv, reject) { var p = new Promise(function (resv, reject) {
imageMagick(bs, bs, "#fff") imageMagick(bs, bs, "#fff")
.font("/usr/share/fonts/zhichan/SourceHanSerif-Regular.ttc") // .font(__dirname + "/fonts/songti.TTC")
.font(__dirname + "/fonts/SourceHanSansSC-Regular.otf")
.fontSize(fs) .fontSize(fs)
// .encoding("UTF-8")
.drawText(0, 0, word, "center") .drawText(0, 0, word, "center")
.write(destfile, function (err) { .write(destfile, function (err) {
if (!err) { if (!err) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment