显卡完善
This commit is contained in:
parent
c470b9074e
commit
a59b923ed1
@ -1070,8 +1070,11 @@ export default {
|
|||||||
zone.fontColor = item.txt.col || 0; // 文本颜色
|
zone.fontColor = item.txt.col || 0; // 文本颜色
|
||||||
zone.fontBold = item.txt.fW || 0; // 字体加粗
|
zone.fontBold = item.txt.fW || 0; // 字体加粗
|
||||||
zone.fontStretch = item.txt.stch || 0; // 拉伸方向
|
zone.fontStretch = item.txt.stch || 0; // 拉伸方向
|
||||||
zone.hAlign = typeof item.txt.hPos === 'number' ? Math.max(item.txt.hPos - 1, 0) : 1; // 水平对齐
|
// 调试输出
|
||||||
zone.vAlign = typeof item.txt.vPos === 'number' ? Math.max(item.txt.vPos - 1, 0) : 1; // 垂直对齐
|
console.log('编辑节目item.txt.hPos:', item.txt.hPos, 'item.txt.vPos:', item.txt.vPos);
|
||||||
|
zone.hAlign = typeof item.txt.hPos === 'number' ? (item.txt.hPos + 1) : 0; // 水平对齐(1左,2中,3右)
|
||||||
|
zone.vAlign = typeof item.txt.vPos === 'number' ? (item.txt.vPos + 1) : 0; // 垂直对齐(1顶,2中,3底)
|
||||||
|
console.log('zone.hAlign:', zone.hAlign, 'zone.vAlign:', zone.vAlign);
|
||||||
} else if (item.typ === 1 && item.img) {
|
} else if (item.typ === 1 && item.img) {
|
||||||
// 图片类型
|
// 图片类型
|
||||||
zone.playType = 1;
|
zone.playType = 1;
|
||||||
@ -2362,8 +2365,8 @@ export default {
|
|||||||
fEn: zone.fontEn + 1, // 英文字体
|
fEn: zone.fontEn + 1, // 英文字体
|
||||||
fW: zone.fontBold, // 字体加粗
|
fW: zone.fontBold, // 字体加粗
|
||||||
stch: zone.fontStretch, // 拉伸方向
|
stch: zone.fontStretch, // 拉伸方向
|
||||||
hPos: zone.hAlign - 1, // 水平对齐
|
hPos: zone.hAlign + 1, // 水平对齐(1左,2中,3右)
|
||||||
vPos: zone.vAlign - 1 // 垂直对齐
|
vPos: zone.vAlign + 1 // 垂直对齐(1顶,2中,3底)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
area.pLst.push(textItem);
|
area.pLst.push(textItem);
|
||||||
@ -2506,13 +2509,19 @@ export default {
|
|||||||
ctx.fillStyle = colors[zone.fontColor] || '#000000';
|
ctx.fillStyle = colors[zone.fontColor] || '#000000';
|
||||||
ctx.textBaseline = 'top';
|
ctx.textBaseline = 'top';
|
||||||
// 这里根据zone.fontEn选择英文字体
|
// 这里根据zone.fontEn选择英文字体
|
||||||
let fontFamily = ['SimSun', 'SimHei', 'KaiTi'][zone.font] || 'SimSun';
|
const fontFamilies = [
|
||||||
if (zone.fontEn !== undefined && zone.fontEn !== null) {
|
'SimSun, 宋体, Songti SC, serif',
|
||||||
// 你可以根据实际需求映射到具体英文字体
|
'SimHei, 黑体, Heiti SC, sans-serif',
|
||||||
|
'KaiTi, 楷体, Kaiti SC, serif'
|
||||||
|
];
|
||||||
const enFontMap = [
|
const enFontMap = [
|
||||||
'Courier New', 'Arial Black', 'Arial Italic', 'Lucida Console', 'Impact', 'Gothic', 'Arial Narrow', 'Comic Sans MS', 'Brush Script MT', 'Century Gothic', 'Times New Roman'
|
'Courier New', 'Arial Black', 'Arial Italic', 'Lucida Console', 'Impact', 'Gothic', 'Arial Narrow', 'Comic Sans MS', 'Brush Script MT', 'Century Gothic', 'Times New Roman'
|
||||||
];
|
];
|
||||||
fontFamily = enFontMap[zone.fontEn] || fontFamily;
|
let fontFamily;
|
||||||
|
if (/^[A-Za-z0-9\s]+$/.test(zone.displayText)) {
|
||||||
|
fontFamily = enFontMap[zone.fontEn] || fontFamilies[0];
|
||||||
|
} else {
|
||||||
|
fontFamily = fontFamilies[zone.font] || fontFamilies[0];
|
||||||
}
|
}
|
||||||
ctx.font = `${asset.fontWeight} ${asset.scaledFontSize}px ${fontFamily}`;
|
ctx.font = `${asset.fontWeight} ${asset.scaledFontSize}px ${fontFamily}`;
|
||||||
|
|
||||||
@ -2528,6 +2537,8 @@ export default {
|
|||||||
startY = zoneY + (zoneHeight - totalHeight) / 2;
|
startY = zoneY + (zoneHeight - totalHeight) / 2;
|
||||||
} else if (verticalAlign === 2) { // 底部对齐
|
} else if (verticalAlign === 2) { // 底部对齐
|
||||||
startY = zoneY + zoneHeight - totalHeight;
|
startY = zoneY + zoneHeight - totalHeight;
|
||||||
|
} else { // 顶部对齐
|
||||||
|
startY = zoneY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绘制每一行文本
|
// 绘制每一行文本
|
||||||
@ -2540,6 +2551,8 @@ export default {
|
|||||||
startX = zoneX + (zoneWidth - textWidth) / 2;
|
startX = zoneX + (zoneWidth - textWidth) / 2;
|
||||||
} else if (zone.hAlign === 2) { // 右对齐
|
} else if (zone.hAlign === 2) { // 右对齐
|
||||||
startX = zoneX + zoneWidth - textWidth;
|
startX = zoneX + zoneWidth - textWidth;
|
||||||
|
} else { // 左对齐
|
||||||
|
startX = zoneX;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算动画偏移
|
// 计算动画偏移
|
||||||
@ -2675,13 +2688,31 @@ export default {
|
|||||||
// 计算缩放后的字体大小
|
// 计算缩放后的字体大小
|
||||||
const scaledFontSize = Math.max(10, Math.round(fontSize * scale * 0.8)); // 添加0.8缩放系数
|
const scaledFontSize = Math.max(10, Math.round(fontSize * scale * 0.8)); // 添加0.8缩放系数
|
||||||
|
|
||||||
const fontFamily = ['SimSun', 'SimHei', 'KaiTi'][zone.font] || 'SimSun';
|
const fontFamily = [
|
||||||
|
'SimSun, 宋体, Songti SC, serif',
|
||||||
|
'SimHei, 黑体, Heiti SC, sans-serif',
|
||||||
|
'KaiTi, 楷体, Kaiti SC, serif'
|
||||||
|
];
|
||||||
const fontWeight = zone.fontBold ? 'bold' : 'normal';
|
const fontWeight = zone.fontBold ? 'bold' : 'normal';
|
||||||
|
|
||||||
// 创建临时canvas测量文本
|
// 创建临时canvas测量文本
|
||||||
const measureCanvas = document.createElement('canvas');
|
const measureCanvas = document.createElement('canvas');
|
||||||
const measureCtx = measureCanvas.getContext('2d');
|
const measureCtx = measureCanvas.getContext('2d');
|
||||||
measureCtx.font = `${fontWeight} ${scaledFontSize}px ${fontFamily}`;
|
const fontFamilies2 = [
|
||||||
|
'SimSun, 宋体, Songti SC, serif',
|
||||||
|
'SimHei, 黑体, Heiti SC, sans-serif',
|
||||||
|
'KaiTi, 楷体, Kaiti SC, serif'
|
||||||
|
];
|
||||||
|
const enFontMap2 = [
|
||||||
|
'Courier New', 'Arial Black', 'Arial Italic', 'Lucida Console', 'Impact', 'Gothic', 'Arial Narrow', 'Comic Sans MS', 'Brush Script MT', 'Century Gothic', 'Times New Roman'
|
||||||
|
];
|
||||||
|
let fontFamily2;
|
||||||
|
if (/^[A-Za-z0-9\s]+$/.test(zone.displayText)) {
|
||||||
|
fontFamily2 = enFontMap2[zone.fontEn] || fontFamilies2[0];
|
||||||
|
} else {
|
||||||
|
fontFamily2 = fontFamilies2[zone.font] || fontFamilies2[0];
|
||||||
|
}
|
||||||
|
measureCtx.font = `${fontWeight} ${scaledFontSize}px ${fontFamily2}`;
|
||||||
|
|
||||||
// 分行逻辑
|
// 分行逻辑
|
||||||
const zoneRenderWidth = swapWH ? zone.height : zone.width;
|
const zoneRenderWidth = swapWH ? zone.height : zone.width;
|
||||||
@ -2720,7 +2751,7 @@ export default {
|
|||||||
pages,
|
pages,
|
||||||
isText: true,
|
isText: true,
|
||||||
scaledFontSize,
|
scaledFontSize,
|
||||||
fontFamily,
|
fontFamily: fontFamily2,
|
||||||
fontWeight,
|
fontWeight,
|
||||||
lineHeight
|
lineHeight
|
||||||
};
|
};
|
||||||
@ -2765,9 +2796,13 @@ export default {
|
|||||||
const scale = Math.min(canvasW / screenW, canvasH / screenH);
|
const scale = Math.min(canvasW / screenW, canvasH / screenH);
|
||||||
let fontSize = parseInt(this.addProgramFontSizes[zone.fontSize] || '16px');
|
let fontSize = parseInt(this.addProgramFontSizes[zone.fontSize] || '16px');
|
||||||
let scaledFontSize = Math.max(10, Math.round(fontSize * scale));
|
let scaledFontSize = Math.max(10, Math.round(fontSize * scale));
|
||||||
const fontFamily = ['SimSun', 'SimHei', 'KaiTi'][zone.font] || 'SimSun';
|
const fontFamily = [
|
||||||
|
'SimSun, 宋体, Songti SC, serif',
|
||||||
|
'SimHei, 黑体, Heiti SC, sans-serif',
|
||||||
|
'KaiTi, 楷体, Kaiti SC, serif'
|
||||||
|
];
|
||||||
const fontWeight = zone.fontBold ? 'bold' : 'normal';
|
const fontWeight = zone.fontBold ? 'bold' : 'normal';
|
||||||
ctx.font = `${fontWeight} ${scaledFontSize}px ${fontFamily}`;
|
ctx.font = `${fontWeight} ${scaledFontSize}px ${fontFamily[zone.font]}`;
|
||||||
let lines = [];
|
let lines = [];
|
||||||
let text = zone.displayText;
|
let text = zone.displayText;
|
||||||
let zw = zone.width * scale;
|
let zw = zone.width * scale;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user