Commit 3fb87894 authored by zhangtingting's avatar zhangtingting

修改lineHeight设置

parent 046c83ff
{ {
"name": "psd-parse-web", "name": "psd-parse-web",
"version": "2.1.7", "version": "2.1.8",
"main": "src/index.js", "main": "src/index.js",
"module": "dist/index.es.js", "module": "dist/index.es.js",
"license": "MIT", "license": "MIT",
......
...@@ -125,9 +125,10 @@ async function compilePsdToJson(psdFile, options) { ...@@ -125,9 +125,10 @@ async function compilePsdToJson(psdFile, options) {
properties.style.fontSize = parseInt(fsize);//字体取整 properties.style.fontSize = parseInt(fsize);//字体取整
//字体取整情况下有可能导致宽度不够,默认扩大10像素 //字体取整情况下有可能导致宽度不够,默认扩大10像素
viewNode.properties.style.width += 10; viewNode.properties.style.width += 10;
viewNode.properties.style.lineHeight = `${height}`;
if((height / fsize) < 2){ //超过两行不设置行高
viewNode.properties.style.lineHeight = `${height}`;
}
let [r, g, b, a] = colors[0]; let [r, g, b, a] = colors[0];
properties.style.color = `rgba(${r}, ${g}, ${b}, ${a / 255})`; properties.style.color = `rgba(${r}, ${g}, ${b}, ${a / 255})`;
......
var {execute}= require( '../src/index'); var {execute, compilePsdToJson}= require( '../src/index');
let test = async()=>{ let test = async()=>{
let result = await execute('/Users/davezh/Downloads/1.psd',{mode:'none',singleView:true}) let result = await execute('/Users/tiffany/Downloads/1.psd',{mode:'none',projectPath: '/Users/tiffany/Downloads/test/', singleView:true})
console.log("---------"); console.log("---------");
console.log(result); // await compilePsdToJson('/Users/tiffany/Downloads/1.psd', { mode: 'none', singleView: true, assetsPath: '/Users/tiffany/Downloads/test/' });
} }
test(); test();
\ No newline at end of file
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