feat(core): bundle Liberation Sans for PDF tests and improve image handling#10
Merged
feat(core): bundle Liberation Sans for PDF tests and improve image handling#10
Conversation
- Add genpdf images feature and image 0.23 for embedding images - Render Table as genpdf TableLayout with cell text from paragraphs - Embed ShapeComponentPicture from BinData when embed_images is true - ShapeComponent without picture still outputs [Image] placeholder
- ToPdfOptions: font_dir, embed_images - to-pdf CLI: -o/--output required, --font-dir, --no-embed-images
- pdf_content_summary(): text summary of PDF elements for snapshot (no font) - to_pdf_returns_valid_pdf_bytes: valid PDF magic, skip on missing font/fixture - pdf_content_summary_snapshot_noori/table/embed_images_false: insta snapshots - to_pdf_table_fixture_returns_valid_pdf: table.hwp roundtrip
…ndling - Add Liberation Sans TTF (2.00.1) under tests/fixtures/fonts with LICENSE - Add find_font_dir() in tests/common for PDF tests to use bundled fonts - PDF: robust base64 decode for BinData, convert to RGB for genpdf (no alpha) - PDF: write actual .pdf files on snapshot run (pdf_export__*.pdf in snapshots dir) - pdf_generated tests: assert valid PDF and write file; drop byte snapshot (non-deterministic metadata) - Clippy: rename document to _document in collect_summary_records; allow(dead_code) for find_font_dir - Format and snapshot updates for content_summary tests
- 001: CLI to-pdf -o path validation (P1) - 002: Base64/image size limits (P2) - 003: font_dir policy doc (P2) - 004: batch --format pdf (P2) - 005: RN toPdf (P2) - 006: README to-pdf/toPdf (P2) - 007: Remove dead code + duplicate test (P2) - 008: find_fixture_file path validation (P3) - 009: common.rs tests_base_dir (P3) - 010: docs/plans font bundle note (P3)
- Add MAX_BASE64_INPUT_LEN (16 MiB) and MAX_IMAGE_DECODED_LEN (12 MiB) to prevent memory exhaustion attacks - Add length validation in try_build_image before decoding and rendering - Update font_dir documentation: clarify it's a directory path with security warning - Remove dead code: minimal_pdf_bytes function (previously #[allow(dead_code)])
- Rename docs/ to documents/ (Rspress 문서 사이트) - Update root package.json workspaces and dev:docs/build:docs filter - Rename @hwpjs/docs to @hwpjs/documents - Update AGENTS.md, HEARTBEAT.md, README.md, folder-structure.md, commit-rules.md - Update GitHub Actions: docs.yml paths and artifact path, CI paths-ignore - Add scope 'documents' to commit conventions - Update internal refs in documents/ and todos
- PDF viewer mod and test common/pdf_export adjustments - Update pdf_export__table_pdf_generated.pdf snapshot
… clippy fixes - to-pdf CLI and batch --format pdf, getDefaultFontDir - packages/hwpjs/fonts/ with README, download-pdf-fonts.mjs script - package.json files include fonts, Noto Sans KR download - README to-pdf and font_dir usage - NAPI toPdf options path and clippy fixes (generated.rs, lib.rs) - dist build artifacts for CLI
…CONTRIBUTING - Add dist/hwpjs.darwin-arm64.node for macOS ARM64 - Document macOS → Windows (cargo-xwin) and macOS → Linux (cross/Docker) in CONTRIBUTING.md
- Build with cargo-xwin (rustup target x86_64-pc-windows-msvc) - Linux build requires cross + Docker; skipped when cross not installed
…cross-build - Cross.toml: use docker/Dockerfile.x86_64-unknown-linux-gnu for x86_64-unknown-linux-gnu (Ubuntu 24.04 + Rust + LLD) - Avoid ld segfault under QEMU on Apple Silicon when using cross
- development.mdx: add 'Linux x64 크로스 빌드 (macOS)' section with Colima+Docker install, cross install, build command, and CROSS_BUILD_OPTS for Apple Silicon - CONTRIBUTING.md: expand Linux cross-build steps and link to guide
ad90236 to
e8de57d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(core): PDF export tests, bundled fonts, documents rename
Purpose
docs/에서documents/로 변경하여 경로 충돌 해소Work content
tests/fixtures/fonts/에 Liberation Sans TTF 4종(LiberationSans-Regular/Bold/Italic/BoldItalic) 및 LICENSE(SIL OFL 1.1), README 추가.find_font_dir()로 테스트에서 자동 사용.decode_bindata_base64), genpdf/printpdf 미지원 알파 채널 대응으로to_rgb8()후 RGB만 전달해 PDF 이미지 임베딩 안정화.pdf_generated테스트 실행 시tests/snapshots/에pdf_export__noori_pdf_generated.pdf,pdf_export__table_pdf_generated.pdf형식으로 저장.pdf_generated_*테스트는 유효 PDF 검사 및 파일 쓰기만 수행. content_summary 스냅샷 유지.collect_summary_records의document→_document,find_font_dir에#[allow(dead_code)]적용.docs/→documents/로 디렉터리 이름 변경. 루트 package.json workspaces·스크립트,@hwpjs/documents패키지명, AGENTS.md·HEARTBEAT·README·folder-structure·commit-rules·커밋 scope, GitHub Actions(docs.yml·CI paths), 내부 경로 참조(documents/·todos) 전부 갱신.--format pdf, 기본 font_dir(getDefaultFontDir),packages/hwpjs/fonts/(Noto Sans KR 포함)·download-pdf-fonts.mjs, README to-pdf·font_dir 안내, NAPI toPdf 경로·clippy 수정(generated.rs, lib.rs), dist 빌드 산출물.dist/hwpjs.darwin-arm64.node·dist/hwpjs.win32-x64-msvc.node커밋, CONTRIBUTING에 맥에서 Windows(cargo-xwin)·Linux(cross/Docker) 크로스 빌드 사용법 추가. Windows x64는 cargo-xwin으로 크로스 빌드 후 반영.docker/Dockerfile.x86_64-unknown-linux-gnu)과Cross.toml추가. LLD 링커 사용으로 Apple Silicon + QEMU 환경에서 ld 세그폴트 방지. 문서 사이트 개발 가이드에 "Linux x64 크로스 빌드 (macOS)" 절 추가(Colima·Docker·cross 설치,CROSS_BUILD_OPTS안내), CONTRIBUTING.md에도 동일 설치법 반영.How to test
bun run test:rust(또는cargo test -p hwp-core --test pdf_export) 실행 시 PDF export 테스트 통과.crates/hwp-core/tests/snapshots/아래에pdf_export__table_pdf_generated.pdf등이 생성되는지 확인.Additional info
font_dir에 지정해 사용.