@simonklee/opentui-tex-native-source 0.2.0
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.
- package/LICENSE +674 -0
- package/LICENSE-PROJECT +21 -0
- package/README.md +7 -0
- package/build.zig +112 -0
- package/build.zig.zon +12 -0
- package/native/lib.zig +280 -0
- package/native/nanosvg.c +4 -0
- package/native/vendor/.bootstrap-v5 +1 -0
- package/native/vendor/LICENSE-NANOSVG +18 -0
- package/native/vendor/microtex/.clang-format +26 -0
- package/native/vendor/microtex/.github/workflows/ubuntu.yml +92 -0
- package/native/vendor/microtex/.github/workflows/windows-gdi.yml +34 -0
- package/native/vendor/microtex/.github/workflows/windows-qt.yml +52 -0
- package/native/vendor/microtex/CMakeLists.txt +110 -0
- package/native/vendor/microtex/LICENSE +21 -0
- package/native/vendor/microtex/MicroTeXInstall.cmake +42 -0
- package/native/vendor/microtex/README.md +600 -0
- package/native/vendor/microtex/build.zig +209 -0
- package/native/vendor/microtex/clatexmath.wrap +6 -0
- package/native/vendor/microtex/doc/meson.build +38 -0
- package/native/vendor/microtex/doc/microtex-doc.toml.in +47 -0
- package/native/vendor/microtex/doc/microtex.svg +39 -0
- package/native/vendor/microtex/doc/urlmap.js +6 -0
- package/native/vendor/microtex/example/gtk/CMakeLists.txt +68 -0
- package/native/vendor/microtex/example/gtk/gtk_main.c +170 -0
- package/native/vendor/microtex/example/gtk/isamples.cpp +21 -0
- package/native/vendor/microtex/example/gtk/isamples.h +15 -0
- package/native/vendor/microtex/example/gtk/meson.build +27 -0
- package/native/vendor/microtex/example/gtk/microtex-gtk.gresource.xml +6 -0
- package/native/vendor/microtex/example/gtk/microtex-gtk.ui +117 -0
- package/native/vendor/microtex/example/gtkmm/CMakeLists.txt +19 -0
- package/native/vendor/microtex/example/gtkmm/gtkmm_main.cpp +531 -0
- package/native/vendor/microtex/example/gtkmm/meson.build +19 -0
- package/native/vendor/microtex/example/memcheck/CMakeLists.txt +12 -0
- package/native/vendor/microtex/example/memcheck/mem_check_main.cpp +154 -0
- package/native/vendor/microtex/example/qt/CMakeLists.txt +37 -0
- package/native/vendor/microtex/example/qt/meson.build +25 -0
- package/native/vendor/microtex/example/qt/qt_main.cpp +70 -0
- package/native/vendor/microtex/example/qt/qt_mainwindow.cpp +107 -0
- package/native/vendor/microtex/example/qt/qt_mainwindow.h +40 -0
- package/native/vendor/microtex/example/qt/qt_skiatexwidget.cpp +149 -0
- package/native/vendor/microtex/example/qt/qt_skiatexwidget.h +48 -0
- package/native/vendor/microtex/example/qt/qt_tex_render.h +15 -0
- package/native/vendor/microtex/example/qt/qt_texqmlitem.cpp +56 -0
- package/native/vendor/microtex/example/qt/qt_texqmlitem.h +31 -0
- package/native/vendor/microtex/example/qt/qt_texwidget.cpp +62 -0
- package/native/vendor/microtex/example/qt/qt_texwidget.h +31 -0
- package/native/vendor/microtex/example/qtpng/CMakeLists.txt +11 -0
- package/native/vendor/microtex/example/qtpng/latex2png.cpp +115 -0
- package/native/vendor/microtex/example/samples/samples.cpp +52 -0
- package/native/vendor/microtex/example/samples/samples.h +32 -0
- package/native/vendor/microtex/example/win32/CMakeLists.txt +15 -0
- package/native/vendor/microtex/example/win32/meson.build +18 -0
- package/native/vendor/microtex/example/win32/win32_main.cpp +375 -0
- package/native/vendor/microtex/githooks/pre-commit +19 -0
- package/native/vendor/microtex/githooks/pre-push +103 -0
- package/native/vendor/microtex/lib/CMakeLists.txt +234 -0
- package/native/vendor/microtex/lib/atom/atom.cpp +14 -0
- package/native/vendor/microtex/lib/atom/atom.h +96 -0
- package/native/vendor/microtex/lib/atom/atom_accent.cpp +115 -0
- package/native/vendor/microtex/lib/atom/atom_accent.h +53 -0
- package/native/vendor/microtex/lib/atom/atom_basic.cpp +146 -0
- package/native/vendor/microtex/lib/atom/atom_basic.h +273 -0
- package/native/vendor/microtex/lib/atom/atom_box.cpp +41 -0
- package/native/vendor/microtex/lib/atom/atom_box.h +70 -0
- package/native/vendor/microtex/lib/atom/atom_char.cpp +99 -0
- package/native/vendor/microtex/lib/atom/atom_char.h +147 -0
- package/native/vendor/microtex/lib/atom/atom_delim.cpp +65 -0
- package/native/vendor/microtex/lib/atom/atom_delim.h +58 -0
- package/native/vendor/microtex/lib/atom/atom_fence.cpp +65 -0
- package/native/vendor/microtex/lib/atom/atom_fence.h +56 -0
- package/native/vendor/microtex/lib/atom/atom_font.cpp +20 -0
- package/native/vendor/microtex/lib/atom/atom_font.h +49 -0
- package/native/vendor/microtex/lib/atom/atom_frac.cpp +101 -0
- package/native/vendor/microtex/lib/atom/atom_frac.h +42 -0
- package/native/vendor/microtex/lib/atom/atom_matrix.cpp +756 -0
- package/native/vendor/microtex/lib/atom/atom_matrix.h +268 -0
- package/native/vendor/microtex/lib/atom/atom_misc.cpp +230 -0
- package/native/vendor/microtex/lib/atom/atom_misc.h +200 -0
- package/native/vendor/microtex/lib/atom/atom_operator.cpp +51 -0
- package/native/vendor/microtex/lib/atom/atom_operator.h +41 -0
- package/native/vendor/microtex/lib/atom/atom_root.cpp +61 -0
- package/native/vendor/microtex/lib/atom/atom_root.h +27 -0
- package/native/vendor/microtex/lib/atom/atom_row.cpp +334 -0
- package/native/vendor/microtex/lib/atom/atom_row.h +176 -0
- package/native/vendor/microtex/lib/atom/atom_scripts.cpp +182 -0
- package/native/vendor/microtex/lib/atom/atom_scripts.h +52 -0
- package/native/vendor/microtex/lib/atom/atom_sideset.cpp +92 -0
- package/native/vendor/microtex/lib/atom/atom_sideset.h +24 -0
- package/native/vendor/microtex/lib/atom/atom_space.cpp +22 -0
- package/native/vendor/microtex/lib/atom/atom_space.h +38 -0
- package/native/vendor/microtex/lib/atom/atom_stack.cpp +117 -0
- package/native/vendor/microtex/lib/atom/atom_stack.h +103 -0
- package/native/vendor/microtex/lib/atom/atom_text.cpp +17 -0
- package/native/vendor/microtex/lib/atom/atom_text.h +33 -0
- package/native/vendor/microtex/lib/atom/atom_vrow.cpp +96 -0
- package/native/vendor/microtex/lib/atom/atom_vrow.h +47 -0
- package/native/vendor/microtex/lib/atom/atom_zstack.cpp +66 -0
- package/native/vendor/microtex/lib/atom/atom_zstack.h +37 -0
- package/native/vendor/microtex/lib/atom/colors_def.cpp +157 -0
- package/native/vendor/microtex/lib/atom/meson.build +50 -0
- package/native/vendor/microtex/lib/box/box.cpp +49 -0
- package/native/vendor/microtex/lib/box/box.h +184 -0
- package/native/vendor/microtex/lib/box/box_factory.cpp +162 -0
- package/native/vendor/microtex/lib/box/box_factory.h +24 -0
- package/native/vendor/microtex/lib/box/box_group.cpp +503 -0
- package/native/vendor/microtex/lib/box/box_group.h +285 -0
- package/native/vendor/microtex/lib/box/box_single.cpp +179 -0
- package/native/vendor/microtex/lib/box/box_single.h +157 -0
- package/native/vendor/microtex/lib/box/meson.build +15 -0
- package/native/vendor/microtex/lib/core/debug_config.cpp +3 -0
- package/native/vendor/microtex/lib/core/debug_config.h +24 -0
- package/native/vendor/microtex/lib/core/formula.cpp +180 -0
- package/native/vendor/microtex/lib/core/formula.h +137 -0
- package/native/vendor/microtex/lib/core/formula_def.cpp +167 -0
- package/native/vendor/microtex/lib/core/glue.cpp +108 -0
- package/native/vendor/microtex/lib/core/glue.h +55 -0
- package/native/vendor/microtex/lib/core/localized_num.cpp +51 -0
- package/native/vendor/microtex/lib/core/meson.build +19 -0
- package/native/vendor/microtex/lib/core/parser.cpp +874 -0
- package/native/vendor/microtex/lib/core/parser.h +306 -0
- package/native/vendor/microtex/lib/core/split.cpp +185 -0
- package/native/vendor/microtex/lib/core/split.h +40 -0
- package/native/vendor/microtex/lib/env/env.cpp +141 -0
- package/native/vendor/microtex/lib/env/env.h +221 -0
- package/native/vendor/microtex/lib/env/meson.build +11 -0
- package/native/vendor/microtex/lib/env/units.cpp +109 -0
- package/native/vendor/microtex/lib/env/units.h +61 -0
- package/native/vendor/microtex/lib/graphic/font_style.cpp +63 -0
- package/native/vendor/microtex/lib/graphic/font_style.h +61 -0
- package/native/vendor/microtex/lib/graphic/graphic.cpp +38 -0
- package/native/vendor/microtex/lib/graphic/graphic.h +314 -0
- package/native/vendor/microtex/lib/graphic/graphic_basic.cpp +44 -0
- package/native/vendor/microtex/lib/graphic/graphic_basic.h +131 -0
- package/native/vendor/microtex/lib/graphic/meson.build +13 -0
- package/native/vendor/microtex/lib/macro/macro.cpp +143 -0
- package/native/vendor/microtex/lib/macro/macro.h +155 -0
- package/native/vendor/microtex/lib/macro/macro_accent.cpp +50 -0
- package/native/vendor/microtex/lib/macro/macro_accent.h +61 -0
- package/native/vendor/microtex/lib/macro/macro_boxes.h +68 -0
- package/native/vendor/microtex/lib/macro/macro_colors.cpp +42 -0
- package/native/vendor/microtex/lib/macro/macro_colors.h +42 -0
- package/native/vendor/microtex/lib/macro/macro_decl.h +16 -0
- package/native/vendor/microtex/lib/macro/macro_def.cpp +418 -0
- package/native/vendor/microtex/lib/macro/macro_delims.cpp +56 -0
- package/native/vendor/microtex/lib/macro/macro_delims.h +73 -0
- package/native/vendor/microtex/lib/macro/macro_env.h +212 -0
- package/native/vendor/microtex/lib/macro/macro_fonts.cpp +53 -0
- package/native/vendor/microtex/lib/macro/macro_fonts.h +78 -0
- package/native/vendor/microtex/lib/macro/macro_frac.cpp +138 -0
- package/native/vendor/microtex/lib/macro/macro_frac.h +50 -0
- package/native/vendor/microtex/lib/macro/macro_misc.cpp +211 -0
- package/native/vendor/microtex/lib/macro/macro_misc.h +217 -0
- package/native/vendor/microtex/lib/macro/macro_scripts.cpp +32 -0
- package/native/vendor/microtex/lib/macro/macro_scripts.h +17 -0
- package/native/vendor/microtex/lib/macro/macro_sizes.h +110 -0
- package/native/vendor/microtex/lib/macro/macro_space.cpp +31 -0
- package/native/vendor/microtex/lib/macro/macro_space.h +17 -0
- package/native/vendor/microtex/lib/macro/macro_styles.cpp +45 -0
- package/native/vendor/microtex/lib/macro/macro_styles.h +22 -0
- package/native/vendor/microtex/lib/macro/macro_types.h +48 -0
- package/native/vendor/microtex/lib/macro/meson.build +33 -0
- package/native/vendor/microtex/lib/meson.build +102 -0
- package/native/vendor/microtex/lib/microtex.cpp +208 -0
- package/native/vendor/microtex/lib/microtex.h +225 -0
- package/native/vendor/microtex/lib/microtexConfig.cmake.in +2 -0
- package/native/vendor/microtex/lib/microtexapi.h +22 -0
- package/native/vendor/microtex/lib/microtexconfig.h.in +7 -0
- package/native/vendor/microtex/lib/microtexexport.h +31 -0
- package/native/vendor/microtex/lib/otf/clm.cpp +405 -0
- package/native/vendor/microtex/lib/otf/clm.h +61 -0
- package/native/vendor/microtex/lib/otf/fontsense.cpp +191 -0
- package/native/vendor/microtex/lib/otf/fontsense.h +20 -0
- package/native/vendor/microtex/lib/otf/glyph.cpp +53 -0
- package/native/vendor/microtex/lib/otf/glyph.h +384 -0
- package/native/vendor/microtex/lib/otf/math_consts.h +154 -0
- package/native/vendor/microtex/lib/otf/meson.build +18 -0
- package/native/vendor/microtex/lib/otf/otf.cpp +84 -0
- package/native/vendor/microtex/lib/otf/otf.h +177 -0
- package/native/vendor/microtex/lib/otf/otfconfig.h +32 -0
- package/native/vendor/microtex/lib/otf/path.cpp +187 -0
- package/native/vendor/microtex/lib/otf/path.h +120 -0
- package/native/vendor/microtex/lib/render/builder.cpp +68 -0
- package/native/vendor/microtex/lib/render/builder.h +73 -0
- package/native/vendor/microtex/lib/render/meson.build +11 -0
- package/native/vendor/microtex/lib/render/render.cpp +136 -0
- package/native/vendor/microtex/lib/render/render.h +59 -0
- package/native/vendor/microtex/lib/unimath/font_meta.h +22 -0
- package/native/vendor/microtex/lib/unimath/font_src.cpp +21 -0
- package/native/vendor/microtex/lib/unimath/font_src.h +61 -0
- package/native/vendor/microtex/lib/unimath/math_type.cpp +318 -0
- package/native/vendor/microtex/lib/unimath/math_type.h +105 -0
- package/native/vendor/microtex/lib/unimath/meson.build +18 -0
- package/native/vendor/microtex/lib/unimath/uni_char.cpp +121 -0
- package/native/vendor/microtex/lib/unimath/uni_char.h +109 -0
- package/native/vendor/microtex/lib/unimath/uni_font.cpp +248 -0
- package/native/vendor/microtex/lib/unimath/uni_font.h +139 -0
- package/native/vendor/microtex/lib/unimath/uni_symbol.cpp +2929 -0
- package/native/vendor/microtex/lib/unimath/uni_symbol.h +31 -0
- package/native/vendor/microtex/lib/utils/dict_tree.h +68 -0
- package/native/vendor/microtex/lib/utils/exceptions.h +61 -0
- package/native/vendor/microtex/lib/utils/log.h +34 -0
- package/native/vendor/microtex/lib/utils/meson.build +18 -0
- package/native/vendor/microtex/lib/utils/nums.h +24 -0
- package/native/vendor/microtex/lib/utils/string_utils.cpp +85 -0
- package/native/vendor/microtex/lib/utils/string_utils.h +130 -0
- package/native/vendor/microtex/lib/utils/types.h +152 -0
- package/native/vendor/microtex/lib/utils/utf.cpp +115 -0
- package/native/vendor/microtex/lib/utils/utf.h +58 -0
- package/native/vendor/microtex/lib/utils/utils.cpp +40 -0
- package/native/vendor/microtex/lib/utils/utils.h +88 -0
- package/native/vendor/microtex/lib/wrapper/byte_seq.cpp +46 -0
- package/native/vendor/microtex/lib/wrapper/byte_seq.h +70 -0
- package/native/vendor/microtex/lib/wrapper/callback.cpp +10 -0
- package/native/vendor/microtex/lib/wrapper/callback.h +72 -0
- package/native/vendor/microtex/lib/wrapper/cwrapper.cpp +206 -0
- package/native/vendor/microtex/lib/wrapper/cwrapper.h +305 -0
- package/native/vendor/microtex/lib/wrapper/graphic_wrapper.cpp +211 -0
- package/native/vendor/microtex/lib/wrapper/graphic_wrapper.h +159 -0
- package/native/vendor/microtex/lib/wrapper/meson.build +22 -0
- package/native/vendor/microtex/meson.build +75 -0
- package/native/vendor/microtex/meson_options.txt +29 -0
- package/native/vendor/microtex/platform/cairo/CMakeLists.txt +36 -0
- package/native/vendor/microtex/platform/cairo/graphic_cairo.cpp +384 -0
- package/native/vendor/microtex/platform/cairo/graphic_cairo.h +119 -0
- package/native/vendor/microtex/platform/cairo/meson.build +47 -0
- package/native/vendor/microtex/platform/cairo/microtex-cairoConfig.cmake.in +11 -0
- package/native/vendor/microtex/platform/flutter/microtex/.metadata +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/CHANGELOG.md +3 -0
- package/native/vendor/microtex/platform/flutter/microtex/LICENSE +1 -0
- package/native/vendor/microtex/platform/flutter/microtex/README.md +15 -0
- package/native/vendor/microtex/platform/flutter/microtex/analysis_options.yaml +4 -0
- package/native/vendor/microtex/platform/flutter/microtex/android/build.gradle +56 -0
- package/native/vendor/microtex/platform/flutter/microtex/android/settings.gradle +1 -0
- package/native/vendor/microtex/platform/flutter/microtex/android/src/main/AndroidManifest.xml +3 -0
- package/native/vendor/microtex/platform/flutter/microtex/android/src/main/kotlin/io/nano/microtex/microtex/MicrotexPlugin.kt +35 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/.metadata +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/README.md +16 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/analysis_options.yaml +31 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/build.gradle +68 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/debug/AndroidManifest.xml +7 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/AndroidManifest.xml +34 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/kotlin/io/nano/microtex/microtex_example/MainActivity.kt +6 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/drawable/launch_background.xml +12 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/drawable-v21/launch_background.xml +12 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/values/styles.xml +18 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/main/res/values-night/styles.xml +18 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/app/src/profile/AndroidManifest.xml +7 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/build.gradle +31 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/gradle.properties +3 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/android/settings.gradle +11 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Flutter/AppFrameworkInfo.plist +26 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Flutter/Debug.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Flutter/Release.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Podfile +41 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Podfile.lock +22 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/AppDelegate.swift +13 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +122 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json +23 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md +5 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Base.lproj/LaunchScreen.storyboard +37 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Base.lproj/Main.storyboard +26 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Info.plist +49 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner/Runner-Bridging-Header.h +1 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcodeproj/project.pbxproj +549 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +87 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcworkspace/contents.xcworkspacedata +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/main.dart +23 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/screen/edit_in_one.dart +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/screen/edit_screen.dart +208 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/utils/convert_spans.dart +63 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/utils/string_ext.dart +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/cmp.dart +118 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/draggable.dart +75 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/rich.dart +23 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/split.dart +72 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/tex_highlight_controller.dart +66 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/lib/widget/tex_input_controller.dart +19 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/CMakeLists.txt +116 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/flutter/CMakeLists.txt +87 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/flutter/generated_plugin_registrant.cc +15 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/flutter/generated_plugin_registrant.h +15 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/flutter/generated_plugins.cmake +24 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/main.cc +6 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/my_application.cc +104 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/linux/my_application.h +18 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Flutter/Flutter-Debug.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Flutter/Flutter-Release.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Flutter/GeneratedPluginRegistrant.swift +12 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Podfile +40 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Podfile.lock +22 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/AppDelegate.swift +9 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json +68 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Base.lproj/MainMenu.xib +343 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Configs/AppInfo.xcconfig +14 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Configs/Debug.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Configs/Release.xcconfig +2 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Configs/Warnings.xcconfig +13 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/DebugProfile.entitlements +12 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Info.plist +32 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/MainFlutterWindow.swift +15 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner/Release.entitlements +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner.xcodeproj/project.pbxproj +633 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +87 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner.xcworkspace/contents.xcworkspacedata +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/pubspec.lock +191 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/pubspec.yaml +56 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/test/widget_test.dart +26 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/CMakeLists.txt +95 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/flutter/CMakeLists.txt +103 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/flutter/generated_plugin_registrant.cc +14 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/flutter/generated_plugin_registrant.h +15 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/flutter/generated_plugins.cmake +24 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/CMakeLists.txt +17 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/Runner.rc +121 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/flutter_window.cpp +61 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/flutter_window.h +33 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/main.cpp +43 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/resource.h +16 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/resources/app_icon.ico +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/runner.exe.manifest +20 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/utils.cpp +64 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/utils.h +19 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/win32_window.cpp +245 -0
- package/native/vendor/microtex/platform/flutter/microtex/example/windows/runner/win32_window.h +98 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/Assets/.gitkeep +0 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/Classes/MicrotexPlugin.h +4 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/Classes/MicrotexPlugin.m +19 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/Classes/SwiftMicrotexPlugin.swift +14 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/Classes/dummy.h +4 -0
- package/native/vendor/microtex/platform/flutter/microtex/ios/microtex.podspec +27 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/microtex.dart +7 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/bindings.dart +218 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/bounds.dart +10 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/context.dart +205 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/fontdesc.dart +14 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/fontmeta.dart +14 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/pathcache.dart +17 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/render.dart +291 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/texstyle.dart +11 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/textlayout.dart +93 -0
- package/native/vendor/microtex/platform/flutter/microtex/lib/src/widget.dart +163 -0
- package/native/vendor/microtex/platform/flutter/microtex/linux/CMakeLists.txt +33 -0
- package/native/vendor/microtex/platform/flutter/microtex/linux/include/microtex/microtex_plugin.h +26 -0
- package/native/vendor/microtex/platform/flutter/microtex/linux/microtex_plugin.cc +70 -0
- package/native/vendor/microtex/platform/flutter/microtex/macos/Classes/MicrotexPlugin.swift +20 -0
- package/native/vendor/microtex/platform/flutter/microtex/macos/Classes/dummy.h +4 -0
- package/native/vendor/microtex/platform/flutter/microtex/macos/Classes/microtex-Bridging-Header.h +1 -0
- package/native/vendor/microtex/platform/flutter/microtex/macos/microtex.podspec +26 -0
- package/native/vendor/microtex/platform/flutter/microtex/nativelib/CMakeLists.txt +44 -0
- package/native/vendor/microtex/platform/flutter/microtex/nativelib/builddarwin.sh +108 -0
- package/native/vendor/microtex/platform/flutter/microtex/pubspec.yaml +37 -0
- package/native/vendor/microtex/platform/flutter/microtex/test/microtex_test.dart +23 -0
- package/native/vendor/microtex/platform/flutter/microtex/windows/CMakeLists.txt +32 -0
- package/native/vendor/microtex/platform/flutter/microtex/windows/include/microtex/microtex_plugin.h +23 -0
- package/native/vendor/microtex/platform/flutter/microtex/windows/microtex_plugin.cpp +82 -0
- package/native/vendor/microtex/platform/gdi_win/CMakeLists.txt +20 -0
- package/native/vendor/microtex/platform/gdi_win/graphic_win32.cpp +352 -0
- package/native/vendor/microtex/platform/gdi_win/graphic_win32.h +137 -0
- package/native/vendor/microtex/platform/gdi_win/meson.build +39 -0
- package/native/vendor/microtex/platform/gtk/CMakeLists.txt +36 -0
- package/native/vendor/microtex/platform/gtk/meson.build +65 -0
- package/native/vendor/microtex/platform/gtk/microtex-gtkConfig.cmake.in +11 -0
- package/native/vendor/microtex/platform/gtk/microtexequation.cpp +708 -0
- package/native/vendor/microtex/platform/gtk/microtexequation.h +72 -0
- package/native/vendor/microtex/platform/qt/CMakeLists.txt +37 -0
- package/native/vendor/microtex/platform/qt/graphic_qt.cpp +355 -0
- package/native/vendor/microtex/platform/qt/graphic_qt.h +116 -0
- package/native/vendor/microtex/platform/qt/meson.build +38 -0
- package/native/vendor/microtex/platform/qt/microtex-qtConfig.cmake.in +7 -0
- package/native/vendor/microtex/platform/skia/CMakeLists.txt +46 -0
- package/native/vendor/microtex/platform/skia/graphic_skia.cpp +306 -0
- package/native/vendor/microtex/platform/skia/graphic_skia.h +125 -0
- package/native/vendor/microtex/platform/skia/microtex-skiaConfig.cmake.in +6 -0
- package/native/vendor/microtex/platform/wasm/CMakeLists.txt +38 -0
- package/native/vendor/microtex/platform/wasm/emscripten.cross +31 -0
- package/native/vendor/microtex/platform/wasm/main.cpp +15 -0
- package/native/vendor/microtex/platform/wasm/meson.build +8 -0
- package/native/vendor/microtex/platform/wasm/prebuild-example-meson.sh +21 -0
- package/native/vendor/microtex/platform/wasm/prebuild-example.sh +21 -0
- package/native/vendor/microtex/platform/wasm/prebuild-lib-meson.sh +28 -0
- package/native/vendor/microtex/platform/wasm/prebuild-lib.sh +31 -0
- package/native/vendor/microtex/platform/wasm/web/.babelrc +10 -0
- package/native/vendor/microtex/platform/wasm/web/example/examples.js +43 -0
- package/native/vendor/microtex/platform/wasm/web/example/hello.js +31 -0
- package/native/vendor/microtex/platform/wasm/web/example/index.html +55 -0
- package/native/vendor/microtex/platform/wasm/web/example/index.js +243 -0
- package/native/vendor/microtex/platform/wasm/web/example/styles.css +86 -0
- package/native/vendor/microtex/platform/wasm/web/example/utils.js +47 -0
- package/native/vendor/microtex/platform/wasm/web/lib/context.js +271 -0
- package/native/vendor/microtex/platform/wasm/web/lib/index.js +10 -0
- package/native/vendor/microtex/platform/wasm/web/lib/render.js +293 -0
- package/native/vendor/microtex/platform/wasm/web/lib/runtime.js +14 -0
- package/native/vendor/microtex/platform/wasm/web/lib/svg.js +237 -0
- package/native/vendor/microtex/platform/wasm/web/lib/textlayout.js +88 -0
- package/native/vendor/microtex/platform/wasm/web/package-lock.json +5931 -0
- package/native/vendor/microtex/platform/wasm/web/package.json +45 -0
- package/native/vendor/microtex/platform/wasm/web/publish-example.sh +17 -0
- package/native/vendor/microtex/platform/wasm/web/rollup.config.example.js +24 -0
- package/native/vendor/microtex/platform/wasm/web/rollup.config.lib.js +16 -0
- package/native/vendor/microtex/prebuilt/otf2clm.py +807 -0
- package/native/vendor/microtex/prebuilt/otf2clm.sh +9 -0
- package/native/vendor/microtex/prebuilt/preclms.sh +17 -0
- package/native/vendor/microtex/readme/example_bw_false.svg +680 -0
- package/native/vendor/microtex/readme/example_bw_true.svg +680 -0
- package/native/vendor/microtex/readme/example_cjk_trying.svg +54 -0
- package/native/vendor/microtex/readme/example_custom_symbols.svg +92 -0
- package/native/vendor/microtex/readme/example_debug.svg +764 -0
- package/native/vendor/microtex/readme/example_emoji.svg +199 -0
- package/native/vendor/microtex/readme/example_have_log.svg +79 -0
- package/native/vendor/microtex/readme/example_keep_trying.svg +101 -0
- package/native/vendor/microtex/readme/example_logos.svg +50 -0
- package/native/vendor/microtex/readme/example_ubuntu.png +0 -0
- package/native/vendor/microtex/readme/example_windows.png +0 -0
- package/native/vendor/microtex/readme/samples/sample_0.svg +665 -0
- package/native/vendor/microtex/readme/samples/sample_1.svg +1259 -0
- package/native/vendor/microtex/readme/samples/sample_10.svg +333 -0
- package/native/vendor/microtex/readme/samples/sample_11.svg +306 -0
- package/native/vendor/microtex/readme/samples/sample_2.svg +2461 -0
- package/native/vendor/microtex/readme/samples/sample_3.svg +2653 -0
- package/native/vendor/microtex/readme/samples/sample_4.svg +554 -0
- package/native/vendor/microtex/readme/samples/sample_5.svg +247 -0
- package/native/vendor/microtex/readme/samples/sample_6.svg +1082 -0
- package/native/vendor/microtex/readme/samples/sample_7.svg +518 -0
- package/native/vendor/microtex/readme/samples/sample_8.svg +529 -0
- package/native/vendor/microtex/readme/samples/sample_9.svg +1702 -0
- package/native/vendor/microtex/readme/samples.md +301 -0
- package/native/vendor/microtex/readme/tex_logo.svg +19 -0
- package/native/vendor/microtex/res/EXAMPLE.txt +25 -0
- package/native/vendor/microtex/res/SAMPLES.tex +946 -0
- package/native/vendor/microtex/res/firamath/FiraMath-Regular.clm1 +0 -0
- package/native/vendor/microtex/res/firamath/FiraMath-Regular.clm2 +0 -0
- package/native/vendor/microtex/res/firamath/FiraMath-Regular.otf +0 -0
- package/native/vendor/microtex/res/firamath/README.md +42 -0
- package/native/vendor/microtex/res/lm-math/README +92 -0
- package/native/vendor/microtex/res/lm-math/latinmodern-math.clm1 +0 -0
- package/native/vendor/microtex/res/lm-math/latinmodern-math.clm2 +0 -0
- package/native/vendor/microtex/res/lm-math/latinmodern-math.otf +0 -0
- package/native/vendor/microtex/res/tex-gyre/README-TeX-Gyre-DejaVu-Math.txt +82 -0
- package/native/vendor/microtex/res/tex-gyre/texgyredejavu-math.clm1 +0 -0
- package/native/vendor/microtex/res/tex-gyre/texgyredejavu-math.clm2 +0 -0
- package/native/vendor/microtex/res/tex-gyre/texgyredejavu-math.otf +0 -0
- package/native/vendor/microtex/res/xits/FONTLOG.txt +246 -0
- package/native/vendor/microtex/res/xits/OFL.txt +98 -0
- package/native/vendor/microtex/res/xits/README.txt +15 -0
- package/native/vendor/microtex/res/xits/XITS-Bold.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Bold.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Bold.otf +0 -0
- package/native/vendor/microtex/res/xits/XITS-BoldItalic.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITS-BoldItalic.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITS-BoldItalic.otf +0 -0
- package/native/vendor/microtex/res/xits/XITS-Italic.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Italic.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Italic.otf +0 -0
- package/native/vendor/microtex/res/xits/XITS-Regular.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Regular.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITS-Regular.otf +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Bold.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Bold.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Bold.otf +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Regular.clm1 +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Regular.clm2 +0 -0
- package/native/vendor/microtex/res/xits/XITSMath-Regular.otf +0 -0
- package/native/vendor/microtex/test/clm/meson.build +10 -0
- package/native/vendor/microtex/test/clm/test_clm.cpp +140 -0
- package/native/vendor/microtex/test/env/meson.build +10 -0
- package/native/vendor/microtex/test/env/test_env.cpp +100 -0
- package/native/vendor/microtex/test/fuzzer/afl.native +20 -0
- package/native/vendor/microtex/test/fuzzer/fuzz.sh +135 -0
- package/native/vendor/microtex/test/fuzzer/fuzzer.cpp +61 -0
- package/native/vendor/microtex/test/fuzzer/generateSeed.java +33 -0
- package/native/vendor/microtex/test/fuzzer/meson.build +9 -0
- package/native/vendor/microtex/test/fuzzer/microtex.dict +3708 -0
- package/native/vendor/microtex/test/fuzzer/platform_none.cpp +100 -0
- package/native/vendor/microtex/test/has_filesystem.cpp +8 -0
- package/native/vendor/microtex/test/meson.build +6 -0
- package/native/vendor/nanosvg.h +3278 -0
- package/native/vendor/nanosvgrast.h +1472 -0
- package/native/vendor/zigtex/.github/assets/example.svg +27 -0
- package/native/vendor/zigtex/LICENSE +674 -0
- package/native/vendor/zigtex/README.md +52 -0
- package/native/vendor/zigtex/build.zig +52 -0
- package/native/vendor/zigtex/build.zig.zon +16 -0
- package/native/vendor/zigtex/fonts/latinmodern-math.clm2 +0 -0
- package/native/vendor/zigtex/src/main.zig +22 -0
- package/native/vendor/zigtex/src/root.zig +124 -0
- package/native/vendor/zigtex/src/svg.zig +273 -0
- package/native/vendor/zigtex/src/tex.zig +383 -0
- package/native/zigtex-0.16.patch +35 -0
- package/package.json +27 -0
- package/scripts/bootstrap-native +89 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src=".github/assets/example.svg" style="max-height: 150px; background-color: white;"/>
|
|
3
|
+
<h1 style="text-align: center;">ZigTeX</h1>
|
|
4
|
+
</p>
|
|
5
|
+
|
|
6
|
+
ZigTeX is a wrapper around [MicroTeX](https://github.com/NanoMichael/MicroTeX/tree/openmath) with a custom SVG renderer. ZigTeX principally gives you one function, which takes some LaTeX code and spits out an SVG:
|
|
7
|
+
|
|
8
|
+
```zig
|
|
9
|
+
const std = @import("std");
|
|
10
|
+
const ztex = @import("zigtex");
|
|
11
|
+
|
|
12
|
+
pub fn main() !void {
|
|
13
|
+
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
14
|
+
defer _ = gpa.deinit();
|
|
15
|
+
const allocator = gpa.allocator();
|
|
16
|
+
|
|
17
|
+
var render = try ztex.TexSvgRender.init(allocator, .{});
|
|
18
|
+
defer render.deinit();
|
|
19
|
+
|
|
20
|
+
const tex =
|
|
21
|
+
\\\begin{equation}
|
|
22
|
+
\\ \hat{F}(\nu) = \int_{-\infty}^\infty e^{-i 2\pi t \nu} f(t) \text{d}t
|
|
23
|
+
\\\end{equation}
|
|
24
|
+
;
|
|
25
|
+
|
|
26
|
+
const output = try render.parseRender(allocator, tex, .{});
|
|
27
|
+
defer allocator.free(output);
|
|
28
|
+
|
|
29
|
+
var f = try std.fs.cwd().createFile("example.svg", .{});
|
|
30
|
+
defer f.close();
|
|
31
|
+
try f.writeAll(output);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
This produces the title image on a transparent background.
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
To use in your Zig project, add this project as a dependency
|
|
39
|
+
```bash
|
|
40
|
+
zig fetch --save https://github.com/fjebaker/zigtex/archive/main.tar.gz
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then modify your `build.zig` in the usual way:
|
|
44
|
+
```zig
|
|
45
|
+
const zigtex_dep = b.dependency(
|
|
46
|
+
"zigtex",
|
|
47
|
+
.{.optimize = optimize, .target = target},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// ...
|
|
51
|
+
exe.root_module.addImport("zigtex", zigtex_dep.module("zigtex"));
|
|
52
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
|
|
3
|
+
pub fn build(b: *std.Build) void {
|
|
4
|
+
const target = b.standardTargetOptions(.{});
|
|
5
|
+
const optimize = b.standardOptimizeOption(.{});
|
|
6
|
+
|
|
7
|
+
const microtex_dep = b.dependency(
|
|
8
|
+
"microtex",
|
|
9
|
+
.{ .target = target },
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const mod = b.addModule("zigtex", .{
|
|
13
|
+
.root_source_file = b.path("src/root.zig"),
|
|
14
|
+
.optimize = optimize,
|
|
15
|
+
.target = target,
|
|
16
|
+
});
|
|
17
|
+
mod.linkLibrary(microtex_dep.artifact("microtex"));
|
|
18
|
+
mod.addAnonymousImport(
|
|
19
|
+
"@DEFAULT_FONT@",
|
|
20
|
+
.{ .root_source_file = b.path("./fonts/latinmodern-math.clm2") },
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const exe = b.addExecutable(.{
|
|
24
|
+
.name = "texample",
|
|
25
|
+
.root_module = b.createModule(.{
|
|
26
|
+
.root_source_file = b.path("src/main.zig"),
|
|
27
|
+
.target = target,
|
|
28
|
+
.optimize = optimize,
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
exe.root_module.addImport("zigtex", mod);
|
|
32
|
+
|
|
33
|
+
const install_exe = b.addInstallArtifact(exe, .{});
|
|
34
|
+
const run_cmd = b.addRunArtifact(exe);
|
|
35
|
+
run_cmd.step.dependOn(&install_exe.step);
|
|
36
|
+
|
|
37
|
+
if (b.args) |args| {
|
|
38
|
+
run_cmd.addArgs(args);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const run_step = b.step("run", "Run the app");
|
|
42
|
+
run_step.dependOn(&run_cmd.step);
|
|
43
|
+
|
|
44
|
+
const exe_unit_tests = b.addTest(.{
|
|
45
|
+
.root_module = exe.root_module,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
|
|
49
|
+
|
|
50
|
+
const test_step = b.step("test", "Run unit tests");
|
|
51
|
+
test_step.dependOn(&run_exe_unit_tests.step);
|
|
52
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
const ztex = @import("zigtex");
|
|
3
|
+
|
|
4
|
+
pub fn main() !void {
|
|
5
|
+
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
|
6
|
+
defer _ = gpa.deinit();
|
|
7
|
+
const allocator = gpa.allocator();
|
|
8
|
+
|
|
9
|
+
var render = try ztex.TexSvgRender.init(allocator, .{});
|
|
10
|
+
defer render.deinit();
|
|
11
|
+
|
|
12
|
+
const tex =
|
|
13
|
+
\\\frac{\text{d}}{\text{d} t} \left( \frac{\partial L}{\partial \dot{q}} \right) = \frac{\partial L}{\partial q}.
|
|
14
|
+
;
|
|
15
|
+
|
|
16
|
+
const output = try render.parseRender(allocator, tex, .{});
|
|
17
|
+
defer allocator.free(output);
|
|
18
|
+
|
|
19
|
+
var f = try std.fs.cwd().createFile("example.svg", .{});
|
|
20
|
+
defer f.close();
|
|
21
|
+
try f.writeAll(output);
|
|
22
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
pub const microtex = @import("tex.zig");
|
|
3
|
+
pub const svg = @import("svg.zig");
|
|
4
|
+
|
|
5
|
+
const DEFAULT_FONT = @embedFile("@DEFAULT_FONT@");
|
|
6
|
+
|
|
7
|
+
pub const TexSvgRender = struct {
|
|
8
|
+
pub const Options = struct {
|
|
9
|
+
font_data: []const u8 = DEFAULT_FONT,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
context: microtex.FontContext,
|
|
13
|
+
mtex: microtex.MicroTeX,
|
|
14
|
+
|
|
15
|
+
pub fn init(
|
|
16
|
+
allocator: std.mem.Allocator,
|
|
17
|
+
opts: Options,
|
|
18
|
+
) !TexSvgRender {
|
|
19
|
+
microtex.setRenderGlyphUsePath(true);
|
|
20
|
+
var context = microtex.FontContext.init(allocator);
|
|
21
|
+
errdefer context.deinit();
|
|
22
|
+
|
|
23
|
+
const mtex = try microtex.MicroTeX.init(
|
|
24
|
+
allocator,
|
|
25
|
+
opts.font_data,
|
|
26
|
+
&context,
|
|
27
|
+
);
|
|
28
|
+
errdefer mtex.deinit();
|
|
29
|
+
return .{
|
|
30
|
+
.context = context,
|
|
31
|
+
.mtex = mtex,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
pub fn deinit(self: *TexSvgRender) void {
|
|
36
|
+
self.mtex.deinit();
|
|
37
|
+
self.context.deinit();
|
|
38
|
+
self.* = undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
pub const RenderOptions = struct {
|
|
42
|
+
size: usize = 20,
|
|
43
|
+
spacing: usize = 6,
|
|
44
|
+
style: ?enum { display, in_line } = null,
|
|
45
|
+
x_pad: u32 = 3,
|
|
46
|
+
y_pad: u32 = 3,
|
|
47
|
+
full_header: bool = true,
|
|
48
|
+
class: ?[]const u8 = null,
|
|
49
|
+
/// RBGA
|
|
50
|
+
default_color: []const u8 = "#3b3b3b",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
pub fn parseRender(
|
|
54
|
+
self: *TexSvgRender,
|
|
55
|
+
allocator: std.mem.Allocator,
|
|
56
|
+
tex: []const u8,
|
|
57
|
+
opts: RenderOptions,
|
|
58
|
+
) ![]const u8 {
|
|
59
|
+
const null_term = try allocator.dupeZ(u8, tex);
|
|
60
|
+
defer allocator.free(null_term);
|
|
61
|
+
|
|
62
|
+
const style: u32 = b: {
|
|
63
|
+
if (opts.style) |s| {
|
|
64
|
+
break :b switch (s) {
|
|
65
|
+
.display => 1,
|
|
66
|
+
.in_line => 0,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
break :b 0;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
var r = try self.mtex.parseRender(null_term, .{
|
|
73
|
+
.text_size = @floatFromInt(opts.size),
|
|
74
|
+
.line_space = @floatFromInt(opts.spacing),
|
|
75
|
+
.override_syle = opts.style == null,
|
|
76
|
+
.style = style,
|
|
77
|
+
.color = 0,
|
|
78
|
+
});
|
|
79
|
+
defer r.deinit();
|
|
80
|
+
|
|
81
|
+
var data = r.getDrawingData(opts.x_pad, opts.y_pad);
|
|
82
|
+
|
|
83
|
+
var s = svg.Svg.init(allocator);
|
|
84
|
+
defer s.deinit();
|
|
85
|
+
|
|
86
|
+
s.x_pad = @floatFromInt(opts.x_pad);
|
|
87
|
+
s.y_pad = @floatFromInt(opts.y_pad);
|
|
88
|
+
s.setColor(opts.default_color);
|
|
89
|
+
|
|
90
|
+
var color: [9]u8 = undefined;
|
|
91
|
+
while (data.next()) |cmd| {
|
|
92
|
+
switch (cmd) {
|
|
93
|
+
.set_color => |c| {
|
|
94
|
+
if (c == 0) {
|
|
95
|
+
s.setColor(opts.default_color);
|
|
96
|
+
} else {
|
|
97
|
+
s.setColor(try std.fmt.bufPrint(&color, "#{x:0>6}", .{c >> 8}));
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
.translate => |i| s.translate(i.x, i.y),
|
|
101
|
+
.scale => |i| s.scale(i.x, i.y),
|
|
102
|
+
.move_to => |i| try s.moveTo(i.x, i.y),
|
|
103
|
+
.line_to => |i| try s.lineTo(i.x, i.y),
|
|
104
|
+
.cubic_to => |i| try s.cubicTo(i.x1, i.y1, i.x2, i.y2, i.x3, i.y3),
|
|
105
|
+
.begin_path => |id| try s.beginPath(@intCast(id)),
|
|
106
|
+
.close_path => try s.closePath(),
|
|
107
|
+
.fill_path => try s.fillPath(),
|
|
108
|
+
.draw_line => |i| try s.drawLine(i.x1, i.y1, i.x2, i.y2),
|
|
109
|
+
.set_stroke => |i| try s.setStroke(i.width),
|
|
110
|
+
else => {
|
|
111
|
+
std.log.default.warn("Unhandled opcopde: {any}", .{cmd});
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
var buf_writer: std.Io.Writer.Allocating = .init(allocator);
|
|
116
|
+
defer buf_writer.deinit();
|
|
117
|
+
try s.write(&buf_writer.writer, .{
|
|
118
|
+
.full_header = opts.full_header,
|
|
119
|
+
.svg_content = tex,
|
|
120
|
+
.class = opts.class,
|
|
121
|
+
});
|
|
122
|
+
return buf_writer.toOwnedSlice();
|
|
123
|
+
}
|
|
124
|
+
};
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
const std = @import("std");
|
|
2
|
+
|
|
3
|
+
pub const Svg = struct {
|
|
4
|
+
const AttrMap = std.StringHashMap([]const u8);
|
|
5
|
+
|
|
6
|
+
pub const Tag = struct {
|
|
7
|
+
name: []const u8,
|
|
8
|
+
id: usize,
|
|
9
|
+
attr: AttrMap,
|
|
10
|
+
style: AttrMap,
|
|
11
|
+
path: std.ArrayList(u8) = .empty,
|
|
12
|
+
|
|
13
|
+
pub fn write(self: *const Tag, writer: *std.Io.Writer) !void {
|
|
14
|
+
try writer.print("<{s}", .{self.name});
|
|
15
|
+
if (self.path.items.len > 0) {
|
|
16
|
+
try writer.print(" d=\"{s}\"", .{self.path.items});
|
|
17
|
+
}
|
|
18
|
+
if (self.style.count() > 0) {
|
|
19
|
+
try writer.writeAll(" style=\"");
|
|
20
|
+
var itt = self.style.iterator();
|
|
21
|
+
while (itt.next()) |item| {
|
|
22
|
+
try writer.print(
|
|
23
|
+
" {s}:{s};",
|
|
24
|
+
.{ item.key_ptr.*, item.value_ptr.* },
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
try writer.writeAll("\"");
|
|
28
|
+
}
|
|
29
|
+
var itt = self.attr.iterator();
|
|
30
|
+
while (itt.next()) |item| {
|
|
31
|
+
try writer.print(
|
|
32
|
+
" {s}=\"{s}\"",
|
|
33
|
+
.{ item.key_ptr.*, item.value_ptr.* },
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
try writer.writeAll("/>");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
pub fn appendPath(
|
|
40
|
+
self: *Tag,
|
|
41
|
+
comptime fmt: []const u8,
|
|
42
|
+
args: anytype,
|
|
43
|
+
) !void {
|
|
44
|
+
const allocator = self.attr.allocator;
|
|
45
|
+
if (self.path.items.len > 0) {
|
|
46
|
+
try self.path.append(allocator, ' ');
|
|
47
|
+
}
|
|
48
|
+
var path_writer = std.Io.Writer.Allocating.fromArrayList(allocator, &self.path);
|
|
49
|
+
defer self.path = path_writer.toArrayList();
|
|
50
|
+
try path_writer.writer.print(fmt, args);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
pub const State = enum {
|
|
55
|
+
none,
|
|
56
|
+
in_path,
|
|
57
|
+
path_done,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
arena: std.heap.ArenaAllocator,
|
|
61
|
+
allocator: std.mem.Allocator,
|
|
62
|
+
tags: std.ArrayList(Tag) = .empty,
|
|
63
|
+
|
|
64
|
+
state: State = .none,
|
|
65
|
+
color: []const u8 = "#3b3b3bff",
|
|
66
|
+
stroke: struct {
|
|
67
|
+
width: f32 = 1,
|
|
68
|
+
} = .{},
|
|
69
|
+
// translation
|
|
70
|
+
tx: f32 = 0,
|
|
71
|
+
ty: f32 = 0,
|
|
72
|
+
// scaling
|
|
73
|
+
sx: f32 = 1,
|
|
74
|
+
sy: f32 = 1,
|
|
75
|
+
|
|
76
|
+
x_min: f32 = std.math.floatMax(f32),
|
|
77
|
+
y_min: f32 = std.math.floatMax(f32),
|
|
78
|
+
x_max: f32 = std.math.floatMin(f32),
|
|
79
|
+
y_max: f32 = std.math.floatMin(f32),
|
|
80
|
+
|
|
81
|
+
x_pad: f32 = 0,
|
|
82
|
+
y_pad: f32 = 0,
|
|
83
|
+
|
|
84
|
+
pub fn init(allocator: std.mem.Allocator) Svg {
|
|
85
|
+
return .{
|
|
86
|
+
.arena = std.heap.ArenaAllocator.init(allocator),
|
|
87
|
+
.allocator = allocator,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
fn newTag(self: *Svg, name: []const u8, id: usize) !*Tag {
|
|
92
|
+
const ptr = try self.tags.addOne(self.allocator);
|
|
93
|
+
ptr.* = .{
|
|
94
|
+
.attr = AttrMap.init(self.arena.allocator()),
|
|
95
|
+
.name = name,
|
|
96
|
+
.id = id,
|
|
97
|
+
.style = AttrMap.init(self.arena.allocator()),
|
|
98
|
+
.path = .empty,
|
|
99
|
+
};
|
|
100
|
+
return ptr;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
pub fn deinit(self: *Svg) void {
|
|
104
|
+
self.tags.deinit(self.allocator);
|
|
105
|
+
self.arena.deinit();
|
|
106
|
+
self.* = undefined;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
inline fn current(self: *const Svg) *Tag {
|
|
110
|
+
std.debug.assert(self.tags.items.len > 0);
|
|
111
|
+
return &self.tags.items[self.tags.items.len - 1];
|
|
112
|
+
}
|
|
113
|
+
inline fn xfmXNoSave(self: *const Svg, x: f32) f32 {
|
|
114
|
+
return x * self.sx + self.tx;
|
|
115
|
+
}
|
|
116
|
+
inline fn xfmYNoSave(self: *const Svg, y: f32) f32 {
|
|
117
|
+
return y * self.sy + self.ty;
|
|
118
|
+
}
|
|
119
|
+
inline fn xfmX(self: *Svg, x: f32) f32 {
|
|
120
|
+
const new_x = self.xfmXNoSave(x);
|
|
121
|
+
self.x_min = @min(new_x, self.x_min);
|
|
122
|
+
self.x_max = @max(new_x, self.x_max);
|
|
123
|
+
return new_x;
|
|
124
|
+
}
|
|
125
|
+
inline fn xfmY(self: *Svg, y: f32) f32 {
|
|
126
|
+
const new_y = self.xfmYNoSave(y);
|
|
127
|
+
self.y_min = @min(new_y, self.y_min);
|
|
128
|
+
self.y_max = @max(new_y, self.y_max);
|
|
129
|
+
return new_y;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
pub fn setColor(self: *Svg, string: []const u8) void {
|
|
133
|
+
self.color = string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
pub fn moveTo(self: *Svg, x: f32, y: f32) !void {
|
|
137
|
+
try self.current().appendPath("M{d} {d}", .{
|
|
138
|
+
self.xfmX(x),
|
|
139
|
+
self.xfmY(y),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
pub fn lineTo(self: *Svg, x: f32, y: f32) !void {
|
|
144
|
+
try self.current().appendPath("L{d} {d}", .{
|
|
145
|
+
self.xfmX(x),
|
|
146
|
+
self.xfmY(y),
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
pub fn cubicTo(
|
|
151
|
+
self: *Svg,
|
|
152
|
+
dx1: f32,
|
|
153
|
+
dy1: f32,
|
|
154
|
+
dx2: f32,
|
|
155
|
+
dy2: f32,
|
|
156
|
+
x: f32,
|
|
157
|
+
y: f32,
|
|
158
|
+
) !void {
|
|
159
|
+
try self.current().appendPath("C{d} {d}, {d} {d}, {d} {d}", .{
|
|
160
|
+
self.xfmX(dx1),
|
|
161
|
+
self.xfmY(dy1),
|
|
162
|
+
self.xfmX(dx2),
|
|
163
|
+
self.xfmY(dy2),
|
|
164
|
+
self.xfmX(x),
|
|
165
|
+
self.xfmY(y),
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
pub fn beginPath(self: *Svg, id: usize) !void {
|
|
170
|
+
_ = try self.newTag("path", id);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
pub fn closePath(self: *Svg) !void {
|
|
174
|
+
try self.current().appendPath("Z", .{});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
pub fn drawLine(self: *Svg, x1: f32, y1: f32, x2: f32, y2: f32) !void {
|
|
178
|
+
const ptr = try self.newTag("path", 0);
|
|
179
|
+
const alloc = self.arena.allocator();
|
|
180
|
+
try ptr.appendPath(
|
|
181
|
+
"M {d} {d} L {d} {d}",
|
|
182
|
+
.{ x1 * self.sx, y1 * self.sy, x2 * self.sx, y2 * self.sy },
|
|
183
|
+
);
|
|
184
|
+
try ptr.attr.put("stroke", try alloc.dupe(u8, self.color));
|
|
185
|
+
try ptr.attr.put(
|
|
186
|
+
"stroke-width",
|
|
187
|
+
try std.fmt.allocPrint(alloc, "{d}", .{self.stroke.width * self.sx}),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
pub fn setStroke(self: *Svg, width: f32) !void {
|
|
192
|
+
self.stroke.width = width;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
pub fn fillPath(self: *Svg) !void {
|
|
196
|
+
const alloc = self.arena.allocator();
|
|
197
|
+
try self.current().attr.put("fill", try alloc.dupe(u8, self.color));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
pub fn translate(self: *Svg, x: f32, y: f32) void {
|
|
201
|
+
self.tx = x * self.sx;
|
|
202
|
+
self.ty = y * self.sy;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
pub fn scale(self: *Svg, x: f32, y: f32) void {
|
|
206
|
+
self.sx *= x;
|
|
207
|
+
self.sy *= y;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
pub const WriteOptions = struct {
|
|
211
|
+
svg_content: ?[]const u8 = null,
|
|
212
|
+
full_header: bool = true,
|
|
213
|
+
class: ?[]const u8 = null,
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
pub fn write(self: *const Svg, writer: *std.Io.Writer, opts: WriteOptions) !void {
|
|
217
|
+
try self.writeHeader(writer, opts.class, opts.full_header);
|
|
218
|
+
try writer.writeByte('\n');
|
|
219
|
+
|
|
220
|
+
const indent: usize = 1;
|
|
221
|
+
if (opts.svg_content) |content| {
|
|
222
|
+
try writer.splatByteAll(' ', indent * 2);
|
|
223
|
+
try writer.print(
|
|
224
|
+
"<desc>{s}</desc>\n",
|
|
225
|
+
.{std.mem.trim(u8, content, "\n\t ")},
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
for (self.tags.items) |tag| {
|
|
230
|
+
try writer.splatByteAll(' ', indent * 2);
|
|
231
|
+
try tag.write(writer);
|
|
232
|
+
try writer.writeByte('\n');
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
try self.writeFooter(writer);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
fn writeHeader(
|
|
239
|
+
self: *const Svg,
|
|
240
|
+
writer: anytype,
|
|
241
|
+
class: ?[]const u8,
|
|
242
|
+
full_header: bool,
|
|
243
|
+
) !void {
|
|
244
|
+
if (self.x_min >= self.x_max) return error.BadViewbox;
|
|
245
|
+
if (self.y_min >= self.y_max) return error.BadViewbox;
|
|
246
|
+
|
|
247
|
+
if (full_header) {
|
|
248
|
+
try writer.writeAll(
|
|
249
|
+
\\<?xml version="1.0" encoding="UTF-8"?>
|
|
250
|
+
\\ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
251
|
+
);
|
|
252
|
+
try writer.writeAll("\n ");
|
|
253
|
+
}
|
|
254
|
+
const xlow = self.x_min - self.x_pad;
|
|
255
|
+
const ylow = self.y_min - self.x_pad;
|
|
256
|
+
const xhigh = self.x_max + 2 * self.x_pad;
|
|
257
|
+
const yhigh = self.y_max + 2 * self.y_pad;
|
|
258
|
+
|
|
259
|
+
try writer.print(
|
|
260
|
+
\\<svg xmlns="http://www.w3.org/2000/svg" viewBox="{d} {d} {d} {d}" width="{d}" height="{d}"
|
|
261
|
+
, .{
|
|
262
|
+
xlow, ylow, xhigh, yhigh, xhigh - xlow, yhigh - ylow,
|
|
263
|
+
});
|
|
264
|
+
if (class) |cls| {
|
|
265
|
+
try writer.print(" class=\"{s}\"", .{cls});
|
|
266
|
+
}
|
|
267
|
+
try writer.writeAll(">");
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
fn writeFooter(_: *const Svg, writer: anytype) !void {
|
|
271
|
+
try writer.writeAll("</svg>");
|
|
272
|
+
}
|
|
273
|
+
};
|