fix text box size
This commit is contained in:
@@ -696,10 +696,25 @@ export const useEditorStore = create<EditorStoreType>((set, get) => {
|
||||
let maxY = -Infinity;
|
||||
|
||||
objectsToGroup.forEach((obj) => {
|
||||
const cx = (obj.x || 0) + (obj.width || 0) / 2;
|
||||
const cy = (obj.y || 0) + (obj.height || 0) / 2;
|
||||
const w = obj.width || 0;
|
||||
const h = obj.height || 0;
|
||||
// برای متنهایی که width و height ندارند، از مقادیر پیشفرض استفاده کن
|
||||
let w = obj.width || 0;
|
||||
let h = obj.height || 0;
|
||||
|
||||
if (obj.type === "text") {
|
||||
// اگر متن width نداره، از fontSize و طول متن برای تخمین استفاده کن
|
||||
if (!w) {
|
||||
const textLength = (obj.text || "").length;
|
||||
const fontSize = obj.fontSize || 24;
|
||||
w = Math.max(textLength * fontSize * 0.6, 50);
|
||||
}
|
||||
// اگر height نداره، از fontSize استفاده کن
|
||||
if (!h) {
|
||||
h = obj.fontSize || 24;
|
||||
}
|
||||
}
|
||||
|
||||
const cx = (obj.x || 0) + w / 2;
|
||||
const cy = (obj.y || 0) + h / 2;
|
||||
const rot = ((obj.rotation || 0) * Math.PI) / 180;
|
||||
|
||||
// محاسبه چهار گوشه rectangle با rotation
|
||||
|
||||
Reference in New Issue
Block a user