core: text under a rotated transform keeps upright, unscaled glyph cells, so rotate plus scale spreads the letters
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 62/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust, typescript, wasm
- Lĩnh vực
- computer-graphics
Hướng nghiên cứu
Read the transforms section of docs/DESIGN.md and the header of engine/core/src/draw.rs, then compare the TEX_QUAD glyph path at draw.rs:3415 with the GLYPH_RUN emission at draw.rs:3471-3480; the existing TEX_TRI path used for rotated images is the model to follow. Reproduce with the programs/sim/sim.ts script and render.rgba from the issue, measuring letter bounding boxes. Done means the third row's glyphs match the scale-200 row's 23 px height, turned by 3 degrees.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
PocketJS v0.17.0 (83c6cac9, current main). macOS 27.2 arm64, Bun 1.4.2. Rendered with the wasm core's software rasterizer through programs/sim/sim.ts.
Gap
docs/DESIGN.md (transforms) and the header of engine/core/src/draw.rs state that axis-aligned scale transforms glyph positions and glyph cells, while rotated and perspective text keeps upright glyph behaviour. With a rotation in the transform, each glyph is drawn at its unscaled size and upright at its transformed anchor. Combined with a scale, the letters move apart to the scaled advance and keep their 1x size.
Rotation with a scale is common in device UIs: a label on a turning dial or card, a "zoom and turn" entrance animation, a card tilted by a few degrees (the edit-mode jiggle that #418 makes work for rounded boxes and arcs). #418 leaves text out.
Repro
A guest application (no AOT) with three rows of the same text.
pocket.host.json:
{
"format": "pocket-host/2",
"id": "repro-esp32s3",
"platform": "esp-idf",
"form": "takeover",
"cadences": [30],
"display": {
"logicalViewports": [[240, 240]],
"presentations": ["native"],
"rasterDensity": 1,
"animation": "repaint"
},
"panel": { "primary": [240, 240] },
"capabilities": ["input.buttons", "text.glyphs.baked"]
}
// pocket.host.config.ts
import { defineHostConfig } from "@pocketjs/framework/host-config";
export default defineHostConfig({
host: "./pocket.host.json",
app: {
id: "dev.example.render",
title: "Render",
version: "0.1.0",
entry: "main.tsx",
output: "render",
framework: "solid",
viewport: { logical: [240, 240], presentation: "native" },
features: ["input.buttons", "text.glyphs.baked"],
},
});
// main.tsx
import { mount } from "@pocketjs/framework/solid";
import { Text, View } from "@pocketjs/framework/solid/components";
mount(() => (
<View class="w-full h-full bg-white">
<Text class="absolute left-[10px] top-[10px] text-base text-black">HELLO</Text>
<Text class="absolute left-[60px] top-[60px] text-base text-black scale-200">HELLO</Text>
<Text class="absolute left-[60px] top-[120px] text-base text-black scale-200 rotate-3">HELLO</Text>
</View>
));
// render.ts: bun render.ts <pocketjs>
const { bootBundle } = await import(`${Bun.argv[2]}/programs/sim/sim.ts`);
const world = await bootBundle({ js: "dist/render.js", pak: "dist/render.pak", viewport: { width: 240, height: 240 } });
for (let i = 0; i < 10; i++) world.step();
const { width, height, rgba } = world.pixels();
await Bun.write("render.rgba", rgba);
console.log(width, height);
bun $POCKETJS/tools/pocket.ts compile --config pocket.host.config.ts --output out/app.pkb
bun render.ts $POCKETJS
Actual
Bounding boxes of the dark connected components (one per letter) in render.rgba, 240×240 px:
| Row | H |
Glyph height | Left edges of H, E, L, L, O |
|---|---|---|---|
text-base |
9×12 at (11, 14) | 12 px | 11, 23, 33, 42, 51 |
scale-200 |
18×23 at (37, 59) | 23 px | 37, 61, 81, 99, 116 |
scale-200 rotate-3 |
9×12 at (36, 111) | 12 px | 36, 60, 80, 98, 116 |
In the third row the glyphs have the size of the first row and the spacing of the second. They stay upright; each glyph's top is 1 px lower than the previous one (y = 111 to 115).
Expected
Glyphs under any 2D affine are drawn transformed, as axis-aligned scaled text is: the third row shows the second row turned by 3°.
Cause
engine/core/src/draw.rs:3415: only an axis-aligned world with a scale other than 1 draws glyphs as TEX_QUADs from the shared glyph pages. Every other transform emits a GLYPH_RUN whose cells stay axis-aligned and unscaled while their anchors are transformed (draw.rs:3471–3480). The glyph pages and the TEX_TRI path that rotated images use already exist.
Related
#418 (open): rounded boxes and arcs under rotation. #322 (open): rounded boxes under rotation.
- Ngôn ngữ chính
- TypeScript
- Star
- 1.6k
- Fork
- 88
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Chúng tôi chưa kiểm tra các tệp thiết lập môi trường của dự án này. Hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pocket-stack/pocketjs
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
pocket-stack/pocketjs#729 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pocket-stack/pocketjs#725 ·
-
enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
pocket-stack/pocketjs#724 ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
pocket-stack/pocketjs#727 ·
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 52/100
pocket-stack/pocketjs#726 ·
Tất cả issue của pocket-stack/pocketjs
Issue tương tự
-
kind:defect
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
mux-labs/mux-frontend#1240 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: agents-mcp priority: normal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Wait for the IDS correction dialog to settle in the stale-audit testCó thể đã có người làm @louistrue đã nhận hôm nay. Đang mởready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Hono path parameters with a regex pattern keep the pattern in the OpenAPI pathCó thể đã có người làm @0z5a đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
cloudflare/chanfana#400 ·
Maintainer thường phản hồi trong vòng 1 ngày