jtypeset 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jtypeset-0.1.0/.github/workflows/ci.yml +89 -0
- jtypeset-0.1.0/.github/workflows/docs.yml +84 -0
- jtypeset-0.1.0/.github/workflows/wheels.yml +121 -0
- jtypeset-0.1.0/.gitignore +15 -0
- jtypeset-0.1.0/CLAUDE.md +98 -0
- jtypeset-0.1.0/CMakeLists.txt +156 -0
- jtypeset-0.1.0/CMakePresets.json +125 -0
- jtypeset-0.1.0/LICENSE +21 -0
- jtypeset-0.1.0/Makefile +89 -0
- jtypeset-0.1.0/PKG-INFO +168 -0
- jtypeset-0.1.0/README.md +139 -0
- jtypeset-0.1.0/cmake/glyphware.cmake +38 -0
- jtypeset-0.1.0/data/download_fonts.py +112 -0
- jtypeset-0.1.0/docs/Doxyfile +54 -0
- jtypeset-0.1.0/docs/architecture.md +93 -0
- jtypeset-0.1.0/docs/build.md +80 -0
- jtypeset-0.1.0/docs/cpp_guide.md +84 -0
- jtypeset-0.1.0/docs/index.md +43 -0
- jtypeset-0.1.0/docs/markdown.md +277 -0
- jtypeset-0.1.0/docs/python_guide.md +142 -0
- jtypeset-0.1.0/docs/samples/report.pdf +0 -0
- jtypeset-0.1.0/docs/samples/report_p1.png +0 -0
- jtypeset-0.1.0/docs/samples/report_vertical.pdf +0 -0
- jtypeset-0.1.0/docs/samples/report_vertical_p1.png +0 -0
- jtypeset-0.1.0/docs/samples.md +19 -0
- jtypeset-0.1.0/handlers/microtex/CMakeLists.txt +59 -0
- jtypeset-0.1.0/handlers/microtex/microtex_handler.cpp +462 -0
- jtypeset-0.1.0/handlers/microtex/microtex_handler.hpp +39 -0
- jtypeset-0.1.0/handlers/microtex/sample_microtex.cpp +113 -0
- jtypeset-0.1.0/include/typeset/backend/pdf_writer.hpp +69 -0
- jtypeset-0.1.0/include/typeset/backend/raster.hpp +72 -0
- jtypeset-0.1.0/include/typeset/backend/svg_writer.hpp +30 -0
- jtypeset-0.1.0/include/typeset/block/block.hpp +296 -0
- jtypeset-0.1.0/include/typeset/dl/display_list.hpp +149 -0
- jtypeset-0.1.0/include/typeset/dl/glyph_transform.hpp +63 -0
- jtypeset-0.1.0/include/typeset/font/font_set.hpp +83 -0
- jtypeset-0.1.0/include/typeset/geom.hpp +178 -0
- jtypeset-0.1.0/include/typeset/image/image.hpp +37 -0
- jtypeset-0.1.0/include/typeset/inl/annotation.hpp +104 -0
- jtypeset-0.1.0/include/typeset/inl/item_builder.hpp +52 -0
- jtypeset-0.1.0/include/typeset/inl/line_breaker.hpp +110 -0
- jtypeset-0.1.0/include/typeset/inl/line_item.hpp +106 -0
- jtypeset-0.1.0/include/typeset/inl/paragraph.hpp +215 -0
- jtypeset-0.1.0/include/typeset/inl/shaped.hpp +88 -0
- jtypeset-0.1.0/include/typeset/inl/shaper.hpp +60 -0
- jtypeset-0.1.0/include/typeset/obj/object.hpp +97 -0
- jtypeset-0.1.0/include/typeset/obj/svg_import.hpp +34 -0
- jtypeset-0.1.0/include/typeset/page/flow_layouter.hpp +67 -0
- jtypeset-0.1.0/include/typeset/page/page.hpp +135 -0
- jtypeset-0.1.0/include/typeset/style.hpp +124 -0
- jtypeset-0.1.0/include/typeset/text/char_class.hpp +81 -0
- jtypeset-0.1.0/include/typeset/text/line_break.hpp +31 -0
- jtypeset-0.1.0/include/typeset/text/orientation.hpp +26 -0
- jtypeset-0.1.0/include/typeset/text/spacing_table.hpp +44 -0
- jtypeset-0.1.0/include/typeset/text/utf.hpp +50 -0
- jtypeset-0.1.0/include/typeset/writing_mode.hpp +72 -0
- jtypeset-0.1.0/mkdocs.yml +44 -0
- jtypeset-0.1.0/pyproject.toml +57 -0
- jtypeset-0.1.0/python/CMakeLists.txt +56 -0
- jtypeset-0.1.0/python/examples/objects.py +84 -0
- jtypeset-0.1.0/python/examples/script.py +127 -0
- jtypeset-0.1.0/python/jtypeset/__init__.py +26 -0
- jtypeset-0.1.0/python/jtypeset/_jtypeset/__init__.pyi +1367 -0
- jtypeset-0.1.0/python/jtypeset/_jtypeset/paper.pyi +14 -0
- jtypeset-0.1.0/python/jtypeset/md/__init__.py +19 -0
- jtypeset-0.1.0/python/jtypeset/md/__main__.py +3 -0
- jtypeset-0.1.0/python/jtypeset/md/cli.py +85 -0
- jtypeset-0.1.0/python/jtypeset/md/convert.py +996 -0
- jtypeset-0.1.0/python/typeset_module.cpp +699 -0
- jtypeset-0.1.0/samples/handlers/plot.py +69 -0
- jtypeset-0.1.0/samples/markdown/figure.png +0 -0
- jtypeset-0.1.0/samples/markdown/report.md +105 -0
- jtypeset-0.1.0/samples/sample_common.hpp +40 -0
- jtypeset-0.1.0/samples/sample_dl.cpp +240 -0
- jtypeset-0.1.0/samples/sample_inline.cpp +190 -0
- jtypeset-0.1.0/samples/sample_novel.cpp +169 -0
- jtypeset-0.1.0/samples/sample_objects.cpp +189 -0
- jtypeset-0.1.0/samples/sample_report.cpp +344 -0
- jtypeset-0.1.0/samples/sample_script.cpp +152 -0
- jtypeset-0.1.0/samples/sample_tech.cpp +287 -0
- jtypeset-0.1.0/scripts/gcc_syntax_check.sh +19 -0
- jtypeset-0.1.0/src/backend/path_raster.cpp +222 -0
- jtypeset-0.1.0/src/backend/path_raster.hpp +48 -0
- jtypeset-0.1.0/src/backend/pdf_writer.cpp +996 -0
- jtypeset-0.1.0/src/backend/raster.cpp +528 -0
- jtypeset-0.1.0/src/backend/sfnt_info.cpp +127 -0
- jtypeset-0.1.0/src/backend/sfnt_info.hpp +43 -0
- jtypeset-0.1.0/src/backend/svg_writer.cpp +333 -0
- jtypeset-0.1.0/src/dl/display_list.cpp +71 -0
- jtypeset-0.1.0/src/font/font_set.cpp +135 -0
- jtypeset-0.1.0/src/geom.cpp +220 -0
- jtypeset-0.1.0/src/image/image.cpp +158 -0
- jtypeset-0.1.0/src/inl/annotation.cpp +16 -0
- jtypeset-0.1.0/src/inl/item_builder.cpp +726 -0
- jtypeset-0.1.0/src/inl/line_breaker.cpp +262 -0
- jtypeset-0.1.0/src/inl/paragraph_layouter.cpp +441 -0
- jtypeset-0.1.0/src/inl/shaper.cpp +319 -0
- jtypeset-0.1.0/src/obj/object.cpp +203 -0
- jtypeset-0.1.0/src/obj/svg_import.cpp +704 -0
- jtypeset-0.1.0/src/page/flow_layouter.cpp +2241 -0
- jtypeset-0.1.0/src/page/page.cpp +123 -0
- jtypeset-0.1.0/src/text/char_class.cpp +251 -0
- jtypeset-0.1.0/src/text/line_break.cpp +34 -0
- jtypeset-0.1.0/src/text/orientation.cpp +71 -0
- jtypeset-0.1.0/src/text/spacing_table.cpp +98 -0
- jtypeset-0.1.0/src/text/utf.cpp +63 -0
- jtypeset-0.1.0/tests/CMakeLists.txt +15 -0
- jtypeset-0.1.0/tests/main.cpp +2 -0
- jtypeset-0.1.0/tests/test_flow3.cpp +987 -0
- jtypeset-0.1.0/tests/test_geom.cpp +76 -0
- jtypeset-0.1.0/tests/test_inline.cpp +329 -0
- jtypeset-0.1.0/tests/test_obj.cpp +472 -0
- jtypeset-0.1.0/tests/test_page.cpp +201 -0
- jtypeset-0.1.0/tests/test_raster.cpp +142 -0
- jtypeset-0.1.0/vcpkg.json +23 -0
- jtypeset-0.1.0//345/256/237/350/243/205.md +390 -0
- jtypeset-0.1.0//346/244/234/350/250/216.md +269 -0
- jtypeset-0.1.0//350/250/255/350/250/210.md +370 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# C++ ライブラリのビルドとテスト(Windows / Linux)
|
|
2
|
+
#
|
|
3
|
+
# vcpkg は lukka/run-vcpkg でセットアップし、CMake の preset(CMakePresets.json)で構成する。
|
|
4
|
+
# テスト用フォントは data/download_fonts.py で取る(無いテストは skip するが、あった方が検査が効く)。
|
|
5
|
+
|
|
6
|
+
name: ci
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
branches: [main, master]
|
|
11
|
+
pull_request:
|
|
12
|
+
workflow_dispatch:
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build:
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
include:
|
|
20
|
+
- os: windows-latest
|
|
21
|
+
preset: x64-windows
|
|
22
|
+
tests: build/x64-windows/tests/Release/typeset_tests.exe
|
|
23
|
+
- os: ubuntu-latest
|
|
24
|
+
preset: x64-linux
|
|
25
|
+
tests: build/x64-linux/tests/typeset_tests
|
|
26
|
+
runs-on: ${{ matrix.os }}
|
|
27
|
+
env:
|
|
28
|
+
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
|
|
29
|
+
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
|
|
33
|
+
- name: Export GitHub Actions cache environment variables (vcpkg binary cache)
|
|
34
|
+
uses: actions/github-script@v7
|
|
35
|
+
with:
|
|
36
|
+
script: |
|
|
37
|
+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
|
38
|
+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
39
|
+
|
|
40
|
+
- name: Linux packages
|
|
41
|
+
if: runner.os == 'Linux'
|
|
42
|
+
run: |
|
|
43
|
+
sudo apt-get update
|
|
44
|
+
sudo apt-get install -y ninja-build autoconf automake libtool pkg-config
|
|
45
|
+
|
|
46
|
+
- name: Windows packages
|
|
47
|
+
if: runner.os == 'Windows'
|
|
48
|
+
run: choco install ninja -y
|
|
49
|
+
|
|
50
|
+
# preset は Ninja + cl なので MSVC の環境変数(vcvars)が要る
|
|
51
|
+
- name: MSVC environment
|
|
52
|
+
if: runner.os == 'Windows'
|
|
53
|
+
uses: ilammy/msvc-dev-cmd@v1
|
|
54
|
+
with:
|
|
55
|
+
arch: x64
|
|
56
|
+
|
|
57
|
+
- uses: lukka/run-vcpkg@v11
|
|
58
|
+
with:
|
|
59
|
+
vcpkgDirectory: ${{ github.workspace }}/vcpkg
|
|
60
|
+
vcpkgJsonGlob: vcpkg.json
|
|
61
|
+
runVcpkgInstall: false
|
|
62
|
+
|
|
63
|
+
- uses: actions/setup-python@v5
|
|
64
|
+
with:
|
|
65
|
+
python-version: "3.12"
|
|
66
|
+
|
|
67
|
+
- name: Fonts for tests
|
|
68
|
+
run: python data/download_fonts.py
|
|
69
|
+
|
|
70
|
+
- name: Configure
|
|
71
|
+
shell: bash
|
|
72
|
+
run: cmake --preset ${{ matrix.preset }} -DTYPESET_BUILD_PYTHON=OFF
|
|
73
|
+
|
|
74
|
+
- name: Build
|
|
75
|
+
shell: bash
|
|
76
|
+
run: cmake --build build/${{ matrix.preset }} --config Release
|
|
77
|
+
|
|
78
|
+
- name: Test
|
|
79
|
+
shell: bash
|
|
80
|
+
run: |
|
|
81
|
+
if [ -f "${{ matrix.tests }}" ]; then "${{ matrix.tests }}"; else ctest --test-dir build/${{ matrix.preset }} -C Release --output-on-failure; fi
|
|
82
|
+
|
|
83
|
+
- name: Samples
|
|
84
|
+
shell: bash
|
|
85
|
+
run: |
|
|
86
|
+
for s in sample_inline sample_script sample_novel sample_tech sample_report sample_objects; do
|
|
87
|
+
exe=$(find build/${{ matrix.preset }} -name "$s" -o -name "$s.exe" | head -1)
|
|
88
|
+
[ -n "$exe" ] && "$exe" > /dev/null || true
|
|
89
|
+
done
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# ドキュメントサイトを GitHub Pages に配信する
|
|
2
|
+
#
|
|
3
|
+
# build/site = MkDocs(docs/*.md) + Doxygen(C++ リファレンス → cpp/) + pdoc(Python リファレンス → python/)
|
|
4
|
+
#
|
|
5
|
+
# Python リファレンスには拡張モジュールのビルドが要るので、vcpkg で依存を入れて pip install する。
|
|
6
|
+
# それが失敗してもサイト自体(手引き・C++ リファレンス)は配信する(continue-on-error)。
|
|
7
|
+
# リポジトリの Settings → Pages → Source を "GitHub Actions" にしておく。
|
|
8
|
+
|
|
9
|
+
name: docs
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
push:
|
|
13
|
+
branches: [main, master]
|
|
14
|
+
workflow_dispatch:
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
pages: write
|
|
19
|
+
id-token: write
|
|
20
|
+
|
|
21
|
+
concurrency:
|
|
22
|
+
group: pages
|
|
23
|
+
cancel-in-progress: true
|
|
24
|
+
|
|
25
|
+
jobs:
|
|
26
|
+
build:
|
|
27
|
+
runs-on: ubuntu-latest
|
|
28
|
+
env:
|
|
29
|
+
VCPKG_ROOT: ${{ github.workspace }}/vcpkg
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
|
|
33
|
+
- name: Install tools
|
|
34
|
+
run: |
|
|
35
|
+
sudo apt-get update
|
|
36
|
+
sudo apt-get install -y doxygen ninja-build
|
|
37
|
+
python -m pip install --upgrade pip
|
|
38
|
+
python -m pip install mkdocs pdoc pybind11-stubgen pybind11 markdown-it-py mdit-py-plugins PyYAML Pygments
|
|
39
|
+
|
|
40
|
+
- name: C++ reference (Doxygen)
|
|
41
|
+
run: |
|
|
42
|
+
mkdir -p build/docs
|
|
43
|
+
doxygen docs/Doxyfile
|
|
44
|
+
|
|
45
|
+
- name: vcpkg
|
|
46
|
+
uses: lukka/run-vcpkg@v11
|
|
47
|
+
with:
|
|
48
|
+
vcpkgDirectory: ${{ github.workspace }}/vcpkg
|
|
49
|
+
vcpkgJsonGlob: vcpkg.json
|
|
50
|
+
runVcpkgInstall: false
|
|
51
|
+
|
|
52
|
+
- name: Build Python package
|
|
53
|
+
id: pybuild
|
|
54
|
+
continue-on-error: true
|
|
55
|
+
run: |
|
|
56
|
+
python -m pip install . --no-deps -v
|
|
57
|
+
|
|
58
|
+
- name: Python reference (pdoc)
|
|
59
|
+
if: steps.pybuild.outcome == 'success'
|
|
60
|
+
continue-on-error: true
|
|
61
|
+
run: |
|
|
62
|
+
mkdir -p build/docs
|
|
63
|
+
pdoc jtypeset -o build/docs/python --no-show-source
|
|
64
|
+
|
|
65
|
+
- name: Site (MkDocs)
|
|
66
|
+
run: |
|
|
67
|
+
mkdocs build
|
|
68
|
+
mkdir -p build/site/cpp build/site/python
|
|
69
|
+
cp -r build/docs/cpp/html build/site/cpp/
|
|
70
|
+
if [ -d build/docs/python ]; then cp -r build/docs/python/. build/site/python/; else echo "<p>Python リファレンスはこのビルドでは生成されませんでした。</p>" > build/site/python/index.html; fi
|
|
71
|
+
|
|
72
|
+
- uses: actions/upload-pages-artifact@v3
|
|
73
|
+
with:
|
|
74
|
+
path: build/site
|
|
75
|
+
|
|
76
|
+
deploy:
|
|
77
|
+
needs: build
|
|
78
|
+
runs-on: ubuntu-latest
|
|
79
|
+
environment:
|
|
80
|
+
name: github-pages
|
|
81
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
82
|
+
steps:
|
|
83
|
+
- id: deployment
|
|
84
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# Python パッケージ jtypeset の wheel / sdist を作り、タグ v* で PyPI に公開する
|
|
2
|
+
#
|
|
3
|
+
# - wheel は cibuildwheel(Windows x64 / Linux x86_64 manylinux / macOS arm64・x86_64、CPython 3.9〜3.13)
|
|
4
|
+
# - 依存は vcpkg。manylinux コンテナでは CIBW_BEFORE_ALL で vcpkg を bootstrap する(freetype / harfbuzz をソースから
|
|
5
|
+
# ビルドするので初回は時間がかかる。ビルド結果は vcpkg の binary cache に乗らないので毎回 10〜20 分程度)
|
|
6
|
+
# - 公開は PyPI の Trusted Publishing(OIDC)。PyPI 側で publisher(owner: wamsoft, repo: jtypeset,
|
|
7
|
+
# workflow: wheels.yml, environment: pypi)を登録しておく。API トークンの secret は要らない
|
|
8
|
+
# - 手動実行(workflow_dispatch)では wheel を作るだけで公開しない
|
|
9
|
+
|
|
10
|
+
name: wheels
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
push:
|
|
14
|
+
tags: ["v*"]
|
|
15
|
+
workflow_dispatch:
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
sdist:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
- uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
- run: |
|
|
26
|
+
python -m pip install build
|
|
27
|
+
python -m build --sdist
|
|
28
|
+
- uses: actions/upload-artifact@v4
|
|
29
|
+
with:
|
|
30
|
+
name: sdist
|
|
31
|
+
path: dist/*.tar.gz
|
|
32
|
+
|
|
33
|
+
wheels:
|
|
34
|
+
strategy:
|
|
35
|
+
fail-fast: false
|
|
36
|
+
matrix:
|
|
37
|
+
include:
|
|
38
|
+
- os: windows-latest
|
|
39
|
+
arch: AMD64
|
|
40
|
+
- os: ubuntu-latest
|
|
41
|
+
arch: x86_64
|
|
42
|
+
# macOS は Apple Silicon のランナーで両アーキテクチャを作る(Intel ランナー macos-13 は少なく待ちが長い)。
|
|
43
|
+
# x86_64 は cibuildwheel のクロスビルド。vcpkg の依存も triplet を x64-osx にして x86_64 で作る
|
|
44
|
+
- os: macos-14
|
|
45
|
+
arch: arm64
|
|
46
|
+
triplet: arm64-osx
|
|
47
|
+
cmake_arch: arm64
|
|
48
|
+
- os: macos-14
|
|
49
|
+
arch: x86_64
|
|
50
|
+
triplet: x64-osx
|
|
51
|
+
cmake_arch: x86_64
|
|
52
|
+
runs-on: ${{ matrix.os }}
|
|
53
|
+
steps:
|
|
54
|
+
- uses: actions/checkout@v4
|
|
55
|
+
|
|
56
|
+
- uses: actions/setup-python@v5
|
|
57
|
+
with:
|
|
58
|
+
python-version: "3.12"
|
|
59
|
+
|
|
60
|
+
# Windows / macOS はホストに vcpkg を用意する(manylinux はコンテナ内で bootstrap)
|
|
61
|
+
- uses: lukka/run-vcpkg@v11
|
|
62
|
+
if: runner.os != 'Linux'
|
|
63
|
+
with:
|
|
64
|
+
vcpkgDirectory: ${{ github.workspace }}/vcpkg
|
|
65
|
+
vcpkgJsonGlob: vcpkg.json
|
|
66
|
+
runVcpkgInstall: false
|
|
67
|
+
|
|
68
|
+
- name: macOS packages
|
|
69
|
+
if: runner.os == 'macOS'
|
|
70
|
+
run: brew install ninja autoconf automake libtool pkg-config
|
|
71
|
+
|
|
72
|
+
- name: Build wheels
|
|
73
|
+
uses: pypa/cibuildwheel@v3.2.1
|
|
74
|
+
env:
|
|
75
|
+
CIBW_ARCHS: ${{ matrix.arch }}
|
|
76
|
+
CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*"
|
|
77
|
+
CIBW_SKIP: "*-musllinux_* *-win32 *_i686"
|
|
78
|
+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
|
|
79
|
+
# Windows / macOS: ホストの vcpkg
|
|
80
|
+
CIBW_ENVIRONMENT_WINDOWS: VCPKG_ROOT='${{ github.workspace }}\vcpkg'
|
|
81
|
+
CIBW_ENVIRONMENT_MACOS: >-
|
|
82
|
+
VCPKG_ROOT='${{ github.workspace }}/vcpkg'
|
|
83
|
+
MACOSX_DEPLOYMENT_TARGET=11.0
|
|
84
|
+
SKBUILD_CMAKE_DEFINE='VCPKG_TARGET_TRIPLET=${{ matrix.triplet }};CMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }}'
|
|
85
|
+
# Linux: コンテナ内に vcpkg を入れる。vcpkg.json の builtin-baseline のコミットだけを浅く取って
|
|
86
|
+
# チェックアウトする(Windows / macOS の run-vcpkg と同じコミットになり、再現性が揃う)
|
|
87
|
+
CIBW_BEFORE_ALL_LINUX: >
|
|
88
|
+
yum install -y curl zip unzip tar perl-IPC-Cmd ninja-build autoconf automake libtool pkgconfig &&
|
|
89
|
+
BASE=$(grep -oP '"builtin-baseline":\s*"\K[0-9a-f]+' vcpkg.json) &&
|
|
90
|
+
echo "vcpkg baseline: $BASE" &&
|
|
91
|
+
git init /opt/vcpkg &&
|
|
92
|
+
git -C /opt/vcpkg remote add origin https://github.com/microsoft/vcpkg.git &&
|
|
93
|
+
git -C /opt/vcpkg fetch --depth 1 origin "$BASE" &&
|
|
94
|
+
git -C /opt/vcpkg checkout FETCH_HEAD &&
|
|
95
|
+
/opt/vcpkg/bootstrap-vcpkg.sh -disableMetrics
|
|
96
|
+
CIBW_ENVIRONMENT_LINUX: VCPKG_ROOT=/opt/vcpkg VCPKG_FORCE_SYSTEM_BINARIES=1
|
|
97
|
+
CIBW_TEST_REQUIRES: markdown-it-py mdit-py-plugins PyYAML
|
|
98
|
+
CIBW_TEST_COMMAND: python -c "import jtypeset, jtypeset.md; print(jtypeset.__version__)"
|
|
99
|
+
|
|
100
|
+
- uses: actions/upload-artifact@v4
|
|
101
|
+
with:
|
|
102
|
+
name: wheels-${{ matrix.os }}-${{ matrix.arch }}
|
|
103
|
+
path: wheelhouse/*.whl
|
|
104
|
+
compression-level: 0
|
|
105
|
+
|
|
106
|
+
publish:
|
|
107
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
108
|
+
needs: [sdist, wheels]
|
|
109
|
+
runs-on: ubuntu-latest
|
|
110
|
+
environment:
|
|
111
|
+
name: pypi
|
|
112
|
+
url: https://pypi.org/p/jtypeset
|
|
113
|
+
permissions:
|
|
114
|
+
id-token: write
|
|
115
|
+
steps:
|
|
116
|
+
- uses: actions/download-artifact@v4
|
|
117
|
+
with:
|
|
118
|
+
path: dist
|
|
119
|
+
merge-multiple: true
|
|
120
|
+
- run: ls -la dist
|
|
121
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
jtypeset-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## 概要
|
|
6
|
+
|
|
7
|
+
縦書き・横書きの日本語組版(JLReq 水準)を 1 つのエンジンで行い、同一の組版結果をラスタ / PDF / SVG へ出す
|
|
8
|
+
C++17 ライブラリ。用途は台本・小説・技術文書などのツール作成(Python バインディングあり)。
|
|
9
|
+
フォント層は glyphware(FreeType + HarfBuzz)。richtext の縦組みエンジンを書字方向非依存に一般化して移植した。
|
|
10
|
+
**minikin と ICU は使わない**(UAX #14 は libunibreak、双方向は SheenBidi、スクリプト判定は HarfBuzz)。
|
|
11
|
+
|
|
12
|
+
## ビルド
|
|
13
|
+
|
|
14
|
+
`VCPKG_ROOT` を設定しておく。glyphware は開発中はローカルツリー(`GLYPHWARE_DIR`)、未指定なら GitHub から FetchContent。
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
make fontdata # テスト用 Noto フォント → data/
|
|
18
|
+
make prebuild GLYPHWARE_DIR=d:/work/kirikiri/glyphware # CMakeOPT=-DTYPESET_BUILD_PYTHON=ON で Python も
|
|
19
|
+
make build # BUILD_TYPE=Debug も可
|
|
20
|
+
make test # ctest(doctest。リポジトリルートで動く前提)
|
|
21
|
+
./build/x64-windows/Release/sample_tech.exe # サンプルは必ずリポジトリルートで実行(./data/ を読む)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Bash ツールから直接叩く場合: `cmake --build build/x64-windows --config Release`、
|
|
25
|
+
テストは `./build/x64-windows/tests/Release/typeset_tests.exe`(フォントが無いテストは skip する)。
|
|
26
|
+
|
|
27
|
+
## レイヤー構造(下から上へ)
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
font/ FontSet glyphware の包み。family 列+文字カバレッジでフォールバック解決。
|
|
31
|
+
シェイピング用 hb_font はフォントのバイト列から OT funcs で自前に作る
|
|
32
|
+
(glyphware の Face::hb() は hb-ft でピクセルサイズに縛られるので使わない)
|
|
33
|
+
text/ CharClass JLReq 附属書 A の文字クラス。ASCII の約物は欧文扱い
|
|
34
|
+
SpacingTable JLReq 表 3 のアキ量(自然値・伸び・縮み = TeX の glue)
|
|
35
|
+
orientation UAX #50(縦組みの正立/横倒し)
|
|
36
|
+
line_break libunibreak(UAX #14)。欧文単語内を割らないためだけに使う
|
|
37
|
+
inl/ shaper Itemizer(スタイル・face・向き)+ HarfBuzz。正立は TTB、他は LTR
|
|
38
|
+
item_builder クラスタ列+注記 → Box / Glue / Penalty(禁則・ぶら下げ・ルビ・縦中横・圏点・割注・字取り)
|
|
39
|
+
line_breaker Greedy / Knuth–Plass。行長は LineShapeProvider::at(lineIndex) で行ごと(\parshape)
|
|
40
|
+
paragraph Paragraph → ParagraphFragment(LineBox 列)。charStart からの再開と maxLines。
|
|
41
|
+
行内オブジェクト/画像が行送りの箱から出る行は extraBefore/After で送りを広げる
|
|
42
|
+
(行位置は lineCenterOffset、消費量は blockExtent。等間隔の pitch × n を仮定しない)
|
|
43
|
+
block/ Block 段落・見出し・罫線・ラベル付き段落・画像・表・セクション、BlockStyle(orphans/widows/keepWithNext/改ページ)
|
|
44
|
+
page/ PageMaster/Region 判型・余白・段。Region は排除領域(回り込み)を持ち RegionLineShape が行の形を返す
|
|
45
|
+
FlowLayouter Flow をページ列へ流し込む。柱・ノンブル({page} {pages} {title})。
|
|
46
|
+
段組ページの途中の段抜きと最終ページの段揃えは、ページの再開点(pageStart_)から段を縮めて
|
|
47
|
+
組み直す試行モード(trial_ / trialOverflow_)で行う。再開点には採番状態(pageNumbering_)も持つ。
|
|
48
|
+
見出しの採番・図表番号・相互参照({ref:} {page:})・目次は 2〜3 パス(RefInfo を次パスへ渡す)。
|
|
49
|
+
表は owner グリッド(colspan / rowspan)で罫線を決め、段より高い行はセルごとに続きから分ける。
|
|
50
|
+
脚注は段落を組む前に番号を振り、断片に載る注の高さを Region::reserved に確保して finishPage で描く
|
|
51
|
+
dl/ DisplayList GlyphRun / Path / Rect / Image / Group。レイアウトと backend の分割線
|
|
52
|
+
glyph_transform グリフ固有の変形(回転・平体長体・斜体)。3 backend で共有
|
|
53
|
+
backend/ raster glyphware のカバレッジマスク+自前合成。パスは自前スキャンライン AA。PNG 出力
|
|
54
|
+
pdf_writer Identity-H でグリフ ID 直書き、hb-subset でサブセット化、Flate 圧縮、画像 XObject
|
|
55
|
+
svg_writer グリフは <defs>+<use>、画像は data URI
|
|
56
|
+
image/ stb_image 読み込み、PNG エンコード、base64
|
|
57
|
+
obj/ ObjectRegistry 外部オブジェクト(数式・グラフ)の差し込み口。関数ハンドラ/外部コマンド(JSON → SVG)を登録し、
|
|
58
|
+
(ハンドラ, ソース, パラメータ, サイズ) でキャッシュ。本体は数式の知識を持たない
|
|
59
|
+
svg_import SVG サブセット → dl(path 全コマンド・基本図形・defs/use・transform・塗り線)。
|
|
60
|
+
ベースラインは <!-- typeset baseline="pt" --> か vertical-align(ex)
|
|
61
|
+
python/ jtypeset/ パッケージ(PyPI 名 jtypeset)。`_jtypeset`(pybind11 拡張。typeset_module.cpp)を `__init__.py` が再エクスポート。
|
|
62
|
+
ビルドツリーでは build/<preset>/python/<Config>/jtypeset/ にまとまる(PYTHONPATH にその親を足す)
|
|
63
|
+
jtypeset/md/ Markdown → Flow → PDF(markdown-it-py)。CLI `jtypeset-md` / `python -m jtypeset.md`。
|
|
64
|
+
front matter の Options、`{#label}` と `{ref:}`、脚注・数式・ルビ記法。pybind の vector 属性は
|
|
65
|
+
コピーを返すので Python 側でリストを作って代入する
|
|
66
|
+
handlers/ microtex/ MicroTeX(LaTeX 数式)のサンプルハンドラ。任意ターゲット(TYPESET_HANDLER_MICROTEX、vcpkg feature microtex)。
|
|
67
|
+
tex::Font / TextLayout / Graphics2D を実装して数式を GlyphRun + Path で返す。本体は依存しない
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 設計上の約束(変えるときは 設計.md も直す)
|
|
71
|
+
|
|
72
|
+
- 文書内部の単位は **pt**。座標はページ左上原点・y-down。ラスタは dpi/72 を掛ける
|
|
73
|
+
- 行内は論理座標 **inline_(送り)/ block(行の中心線からのずれ。縦組みは右が正、横組みは下が正)**で組み、
|
|
74
|
+
物理化は `inl::emitParagraph` / `toPhysical` の 1 箇所。注記の付く側は `annotationSide()`(縦: 右、横: 上)
|
|
75
|
+
- ブロック軸は「**em box の中心=行の中心線**」。横組みのベースラインは第一候補フォントの ascender/descender から
|
|
76
|
+
`baselineOffset()` で決め、フォールバック先も同じベースラインに乗せる
|
|
77
|
+
- 和文組版は「1 文字=1em の箱」ではなく **Box / Glue / Penalty 列を解く**。禁則は Glue の直前の Penalty(∞)、
|
|
78
|
+
ぶら下げは幅が負の Penalty、和字間には `kanjiSkipStretch` の伸び(追い出し用)
|
|
79
|
+
- 揃えない段落(ragged)では縮みを使わずに収まりを判定する(TeX の ragged-right と同じ)
|
|
80
|
+
- 組版結果は表示リストで切る。backend は組版の知識を持たない。グリフ変形の組み立ては `glyph_transform.hpp` のみ
|
|
81
|
+
- PDF: `Tm` にフォントサイズを入れない(`Tf` が掛ける)。y-down → y-up は Y 反転で共役(シアーの符号が入れ替わる)。
|
|
82
|
+
縦組みでも Identity-V は使わない
|
|
83
|
+
- Windows の `windows.h` を含むサンプルでは `small` など Windows のマクロ名を変数に使わない
|
|
84
|
+
|
|
85
|
+
## テストとサンプル
|
|
86
|
+
|
|
87
|
+
- `tests/` は doctest。組版結果は数値で検算する(禁則違反 0、両端揃えの行長一致、グリフが版面内、ヘッダ行の繰り返し等)。
|
|
88
|
+
フォントは `data/` から読むので `WORKING_DIRECTORY` はリポジトリルート
|
|
89
|
+
- `samples/sample_inline`(縦横同一文)、`sample_script`(台本)、`sample_novel`(小説 2 段)、`sample_tech`(技術文書:回り込み・表・2 段組)、
|
|
90
|
+
`sample_dl`(表示リスト直書き)。出力 `output_*.png/.pdf/.svg` はリポジトリルートに出る(gitignore 済み)
|
|
91
|
+
- 3 backend の一致確認は Inkscape で SVG / PDF(`--pdf-poppler`)を PNG にして ImageMagick `compare -metric RMSE`。
|
|
92
|
+
外接矩形が 1〜2px 以内、RMSE 数%(AA 差)なら一致とみなす
|
|
93
|
+
|
|
94
|
+
## 参考ドキュメント
|
|
95
|
+
|
|
96
|
+
- `検討.md` — 既存資産(richtext / glyphware)の棚卸し、設計判断、参照仕様、フェーズ計画、決定事項
|
|
97
|
+
- `設計.md` — 型・処理の流れの具体化
|
|
98
|
+
- `実装.md` — フェーズ別の進捗・確認結果・積み残し(作業を進めたらここを更新する)
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.24)
|
|
2
|
+
|
|
3
|
+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|
4
|
+
add_compile_options("$<$<AND:$<C_COMPILER_ID:MSVC>,$<COMPILE_LANGUAGE:C>>:/utf-8>")
|
|
5
|
+
add_compile_options("$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<COMPILE_LANGUAGE:CXX>>:/utf-8>")
|
|
6
|
+
add_compile_options("$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<COMPILE_LANGUAGE:CXX>>:/Zc:__cplusplus>")
|
|
7
|
+
endif()
|
|
8
|
+
|
|
9
|
+
# vcpkg: toolchain が渡されていなければ VCPKG_ROOT から補う(pip / scikit-build-core 経由のビルド用)
|
|
10
|
+
if(NOT CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{VCPKG_ROOT} AND EXISTS "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
|
|
11
|
+
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE FILEPATH "vcpkg toolchain")
|
|
12
|
+
endif()
|
|
13
|
+
|
|
14
|
+
project(typeset VERSION 0.1.0 LANGUAGES C CXX)
|
|
15
|
+
|
|
16
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
17
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
18
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
19
|
+
|
|
20
|
+
option(TYPESET_BUILD_SAMPLES "Build sample executables" ${PROJECT_IS_TOP_LEVEL})
|
|
21
|
+
option(TYPESET_BUILD_TESTS "Build unit tests (doctest)" ${PROJECT_IS_TOP_LEVEL})
|
|
22
|
+
option(TYPESET_BUILD_PYTHON "Build pybind11 Python bindings" OFF)
|
|
23
|
+
option(TYPESET_HANDLER_MICROTEX "Build the MicroTeX (LaTeX math) object handler (default ON; tinyxml2 from vcpkg, MicroTeX via FetchContent)" ON)
|
|
24
|
+
|
|
25
|
+
if(TYPESET_BUILD_PYTHON)
|
|
26
|
+
# 拡張モジュールに静的ライブラリをリンクするので全部 PIC にする
|
|
27
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
28
|
+
endif()
|
|
29
|
+
|
|
30
|
+
#------------------------------------------------------------------------------
|
|
31
|
+
# 依存
|
|
32
|
+
#------------------------------------------------------------------------------
|
|
33
|
+
find_package(Freetype REQUIRED)
|
|
34
|
+
find_package(harfbuzz CONFIG REQUIRED)
|
|
35
|
+
find_package(ZLIB REQUIRED)
|
|
36
|
+
find_package(libunibreak CONFIG REQUIRED)
|
|
37
|
+
find_path(STB_INCLUDE_DIRS "stb_image.h" REQUIRED)
|
|
38
|
+
|
|
39
|
+
# glyphware(フォントエンジン)。GLYPHWARE_DIR でローカルツリーを指すか、
|
|
40
|
+
# 未指定なら GitHub から FetchContent で取る(cmake/glyphware.cmake)
|
|
41
|
+
include(cmake/glyphware.cmake)
|
|
42
|
+
|
|
43
|
+
#------------------------------------------------------------------------------
|
|
44
|
+
# ライブラリ本体
|
|
45
|
+
#------------------------------------------------------------------------------
|
|
46
|
+
set(TYPESET_SOURCES
|
|
47
|
+
src/geom.cpp
|
|
48
|
+
src/font/font_set.cpp
|
|
49
|
+
src/dl/display_list.cpp
|
|
50
|
+
src/image/image.cpp
|
|
51
|
+
src/obj/object.cpp
|
|
52
|
+
src/obj/svg_import.cpp
|
|
53
|
+
# text: Unicode / JLReq のテーブル
|
|
54
|
+
src/text/utf.cpp
|
|
55
|
+
src/text/char_class.cpp
|
|
56
|
+
src/text/spacing_table.cpp
|
|
57
|
+
src/text/orientation.cpp
|
|
58
|
+
src/text/line_break.cpp
|
|
59
|
+
# inl: インライン組版
|
|
60
|
+
src/inl/shaper.cpp
|
|
61
|
+
src/inl/annotation.cpp
|
|
62
|
+
src/inl/item_builder.cpp
|
|
63
|
+
src/inl/line_breaker.cpp
|
|
64
|
+
src/inl/paragraph_layouter.cpp
|
|
65
|
+
# page: ブロック/ページ
|
|
66
|
+
src/page/page.cpp
|
|
67
|
+
src/page/flow_layouter.cpp
|
|
68
|
+
src/backend/raster.cpp
|
|
69
|
+
src/backend/path_raster.cpp
|
|
70
|
+
src/backend/sfnt_info.cpp
|
|
71
|
+
src/backend/pdf_writer.cpp
|
|
72
|
+
src/backend/svg_writer.cpp
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
add_library(typeset STATIC ${TYPESET_SOURCES})
|
|
76
|
+
add_library(typeset::typeset ALIAS typeset)
|
|
77
|
+
|
|
78
|
+
target_include_directories(typeset
|
|
79
|
+
PUBLIC
|
|
80
|
+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
81
|
+
$<INSTALL_INTERFACE:include>
|
|
82
|
+
PRIVATE
|
|
83
|
+
${STB_INCLUDE_DIRS}
|
|
84
|
+
)
|
|
85
|
+
target_link_libraries(typeset
|
|
86
|
+
PUBLIC
|
|
87
|
+
glyphware::glyphware
|
|
88
|
+
PRIVATE
|
|
89
|
+
Freetype::Freetype
|
|
90
|
+
harfbuzz::harfbuzz
|
|
91
|
+
harfbuzz::harfbuzz-subset
|
|
92
|
+
ZLIB::ZLIB
|
|
93
|
+
libunibreak::libunibreak
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
if(MSVC)
|
|
97
|
+
target_compile_definitions(typeset PUBLIC NOMINMAX)
|
|
98
|
+
target_compile_options(typeset PRIVATE /W3 /permissive-)
|
|
99
|
+
else()
|
|
100
|
+
target_compile_options(typeset PRIVATE -Wall -Wextra)
|
|
101
|
+
endif()
|
|
102
|
+
|
|
103
|
+
#------------------------------------------------------------------------------
|
|
104
|
+
# サンプル
|
|
105
|
+
#------------------------------------------------------------------------------
|
|
106
|
+
if(TYPESET_BUILD_SAMPLES)
|
|
107
|
+
add_executable(sample_dl samples/sample_dl.cpp)
|
|
108
|
+
target_link_libraries(sample_dl PRIVATE typeset)
|
|
109
|
+
|
|
110
|
+
add_executable(sample_inline samples/sample_inline.cpp)
|
|
111
|
+
target_link_libraries(sample_inline PRIVATE typeset)
|
|
112
|
+
|
|
113
|
+
add_executable(sample_script samples/sample_script.cpp)
|
|
114
|
+
target_link_libraries(sample_script PRIVATE typeset)
|
|
115
|
+
|
|
116
|
+
add_executable(sample_novel samples/sample_novel.cpp)
|
|
117
|
+
target_link_libraries(sample_novel PRIVATE typeset)
|
|
118
|
+
|
|
119
|
+
add_executable(sample_tech samples/sample_tech.cpp)
|
|
120
|
+
target_link_libraries(sample_tech PRIVATE typeset)
|
|
121
|
+
|
|
122
|
+
add_executable(sample_objects samples/sample_objects.cpp)
|
|
123
|
+
target_link_libraries(sample_objects PRIVATE typeset)
|
|
124
|
+
|
|
125
|
+
add_executable(sample_report samples/sample_report.cpp)
|
|
126
|
+
target_link_libraries(sample_report PRIVATE typeset)
|
|
127
|
+
endif()
|
|
128
|
+
|
|
129
|
+
#------------------------------------------------------------------------------
|
|
130
|
+
# テスト
|
|
131
|
+
#------------------------------------------------------------------------------
|
|
132
|
+
if(TYPESET_BUILD_TESTS)
|
|
133
|
+
enable_testing()
|
|
134
|
+
add_subdirectory(tests)
|
|
135
|
+
endif()
|
|
136
|
+
|
|
137
|
+
#------------------------------------------------------------------------------
|
|
138
|
+
# Python バインド
|
|
139
|
+
#------------------------------------------------------------------------------
|
|
140
|
+
if(TYPESET_HANDLER_MICROTEX)
|
|
141
|
+
add_subdirectory(handlers/microtex)
|
|
142
|
+
endif()
|
|
143
|
+
|
|
144
|
+
# リファレンス(Doxygen があれば): cmake --build <build> --target docs → build/docs/cpp/html/index.html
|
|
145
|
+
find_package(Doxygen QUIET)
|
|
146
|
+
if(DOXYGEN_FOUND)
|
|
147
|
+
add_custom_target(docs
|
|
148
|
+
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/docs/Doxyfile
|
|
149
|
+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
150
|
+
COMMENT "Doxygen: C++ reference → build/docs/cpp"
|
|
151
|
+
VERBATIM)
|
|
152
|
+
endif()
|
|
153
|
+
|
|
154
|
+
if(TYPESET_BUILD_PYTHON)
|
|
155
|
+
add_subdirectory(python)
|
|
156
|
+
endif()
|