mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 08:46:55 +08:00
1 parent
5545c3d4b5
commit
e99501ca5f
2 files changed
+11
-4
No files matched your search
@@ -1379,6 +1379,8 @@ export class CanvasEditor {
|
||||
bottom = Math.max(bottom, y + size - baseline);
|
||||
}
|
||||
for (const char of run.text) {
|
||||
x = run.positions[index][0] * PX_PER_MM;
|
||||
y = run.positions[index][1] * PX_PER_MM;
|
||||
const span = document.createElement("span"), node = document.createTextNode(char);
|
||||
span.append(node);
|
||||
Object.assign(span.style, { display: "inline-block", opacity: String((item.alpha ?? 255) / 255), transformOrigin: "left top", transform: `translate(${x - naturalX}px,${y - baseline - lineIndex * size}px) scaleX(${source.scale})` });
|
||||
@@ -1391,8 +1393,6 @@ export class CanvasEditor {
|
||||
right = Math.max(right, x + advance * source.scale);
|
||||
bottom = Math.max(bottom, y + size - baseline);
|
||||
naturalX += advance;
|
||||
x += run.dx?.length ? run.dx[Math.min(index, run.dx.length - 1)] * PX_PER_MM : 0;
|
||||
y += run.dy?.length ? run.dy[Math.min(index, run.dy.length - 1)] * PX_PER_MM : 0;
|
||||
index++;
|
||||
}
|
||||
if (!line.hasChildNodes()) {
|
||||
|
||||
@@ -2346,8 +2346,15 @@ func previewText(args []js.Value) (any, error) {
|
||||
offset++
|
||||
}
|
||||
content := (ofdgo.TextObject{TextCode: []ofdgo.TextCode{code}}).Text()
|
||||
runs = append(runs, map[string]any{"text": content, "x": x, "y": y, "dx": code.GetDeltaX(), "dy": code.GetDeltaY(), "line": line})
|
||||
offset += len([]rune(content))
|
||||
code.X, code.Y = fmt.Sprint(x), fmt.Sprint(y)
|
||||
positioner := ofdgo.NewTextPositioner(code)
|
||||
positions := make([][2]float64, len([]rune(content)))
|
||||
for i := range positions {
|
||||
point := positioner.Next()
|
||||
positions[i] = [2]float64{point.X, point.Y}
|
||||
}
|
||||
runs = append(runs, map[string]any{"text": content, "x": x, "y": y, "positions": positions, "line": line})
|
||||
offset += len(positions)
|
||||
}
|
||||
scale := text.HScale
|
||||
if scale == 0 {
|
||||
|
||||
Reference in new issue
Block a user