@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,314 @@
|
|
|
1
|
+
#ifndef GRAPHIC_H_INCLUDED
|
|
2
|
+
#define GRAPHIC_H_INCLUDED
|
|
3
|
+
|
|
4
|
+
#include <map>
|
|
5
|
+
#include <vector>
|
|
6
|
+
|
|
7
|
+
#include "graphic/font_style.h"
|
|
8
|
+
#include "graphic/graphic_basic.h"
|
|
9
|
+
|
|
10
|
+
namespace microtex {
|
|
11
|
+
|
|
12
|
+
class Graphics2D;
|
|
13
|
+
|
|
14
|
+
/** Interface to represents a font. */
|
|
15
|
+
class Font {
|
|
16
|
+
public:
|
|
17
|
+
/** Check if current font is equals to another */
|
|
18
|
+
virtual bool operator==(const Font& f) const = 0;
|
|
19
|
+
|
|
20
|
+
/** Check if current font is not equals to another */
|
|
21
|
+
inline bool operator!=(const Font& f) const { return !(*this == f); }
|
|
22
|
+
|
|
23
|
+
virtual ~Font() = default;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** To layout the text that the program cannot recognize. */
|
|
27
|
+
class TextLayout {
|
|
28
|
+
public:
|
|
29
|
+
/**
|
|
30
|
+
* Get the layout bounds with current text and font
|
|
31
|
+
*
|
|
32
|
+
* @param bounds rectangle to retrieve the bounds. The metrics of the text layout
|
|
33
|
+
* is arranged by following ways:
|
|
34
|
+
*
|
|
35
|
+
* - [bounds.w] takes the width of the layout
|
|
36
|
+
* - [bounds.h] takes the height of the layout (ascent + descent)
|
|
37
|
+
* - [bounds.y] takes the ascent (distance above the baseline, in negative) of the
|
|
38
|
+
* layout
|
|
39
|
+
*/
|
|
40
|
+
virtual void getBounds(Rect& bounds) = 0;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Draw the layout
|
|
44
|
+
*
|
|
45
|
+
* @param g2 the graphics (2D) context
|
|
46
|
+
* @param x the x coordinate
|
|
47
|
+
* @param y the y coordinate, is baseline aligned
|
|
48
|
+
*/
|
|
49
|
+
virtual void draw(Graphics2D& g2, float x, float y) = 0;
|
|
50
|
+
|
|
51
|
+
virtual ~TextLayout() = default;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
struct PlatformFactoryData;
|
|
55
|
+
|
|
56
|
+
/** Simple factory to create platform specific Font and TextLayout. */
|
|
57
|
+
class MICROTEX_EXPORT PlatformFactory {
|
|
58
|
+
private:
|
|
59
|
+
static PlatformFactoryData* _data;
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
virtual ~PlatformFactory() = default;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Create font from file. You may cache the loaded platform specific font
|
|
66
|
+
* to avoid repetitive loading.
|
|
67
|
+
*
|
|
68
|
+
* @param file the 'font file' doesn't have to be a real font file, it depends
|
|
69
|
+
* on the font source you given before. See [lib/unimath/font_src.h: FontSrc]
|
|
70
|
+
* for details.
|
|
71
|
+
*/
|
|
72
|
+
virtual sptr<Font> createFont(const std::string& file) = 0;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Create a TextLayout with given text and font
|
|
76
|
+
*
|
|
77
|
+
* @param src the source text to layout and draw
|
|
78
|
+
* @param style the font style. Unlike the fonts the engine using internally,
|
|
79
|
+
* you are free to create the font you want based on the given style, the style
|
|
80
|
+
* is for reference, not a constraint.
|
|
81
|
+
* @param size the font size
|
|
82
|
+
*/
|
|
83
|
+
virtual sptr<TextLayout>
|
|
84
|
+
createTextLayout(const std::string& src, FontStyle style, float size) = 0;
|
|
85
|
+
|
|
86
|
+
/** Register a factory */
|
|
87
|
+
static void registerFactory(const std::string& name, std::unique_ptr<PlatformFactory> factory);
|
|
88
|
+
|
|
89
|
+
/** Activate a factory */
|
|
90
|
+
static void activate(const std::string& name);
|
|
91
|
+
|
|
92
|
+
/** Get the current platform factory */
|
|
93
|
+
static PlatformFactory* get();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Abstract class to represents a graphics (2D) context, all the TeX drawing operations will on it.
|
|
98
|
+
* It must have scale, translation, and rotation support.
|
|
99
|
+
*/
|
|
100
|
+
class Graphics2D {
|
|
101
|
+
public:
|
|
102
|
+
virtual ~Graphics2D() = default;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Set the color of the context
|
|
106
|
+
*
|
|
107
|
+
* @param c required color
|
|
108
|
+
*/
|
|
109
|
+
virtual void setColor(color c) = 0;
|
|
110
|
+
|
|
111
|
+
/** Get the color of the context */
|
|
112
|
+
virtual color getColor() const = 0;
|
|
113
|
+
|
|
114
|
+
/** Set the stroke of the context */
|
|
115
|
+
virtual void setStroke(const Stroke& s) = 0;
|
|
116
|
+
|
|
117
|
+
/** Get the stroke of the context */
|
|
118
|
+
virtual const Stroke& getStroke() const = 0;
|
|
119
|
+
|
|
120
|
+
/** Set the stroke width of the context */
|
|
121
|
+
virtual void setStrokeWidth(float w) = 0;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Set the dash style to draw the lines.
|
|
125
|
+
* Each line can be drawn with a different pen dash. It defines the style of the line.
|
|
126
|
+
* The pattern is set by the dash array, which is an array of positive floating point values.
|
|
127
|
+
* They set the on and off parts of the dash pattern. We also specify the length of the array
|
|
128
|
+
* and the offset value. If the length is 0, the dashing is disabled. If it is 1, a symmetric
|
|
129
|
+
* pattern is assumed with alternating on and off portions of the size specified by the single
|
|
130
|
+
* value in dashes.
|
|
131
|
+
*
|
|
132
|
+
* @param dash the dash pattern
|
|
133
|
+
*/
|
|
134
|
+
virtual void setDash(const std::vector<float>& dash) = 0;
|
|
135
|
+
|
|
136
|
+
/** Get the dash pattern to draw lines. */
|
|
137
|
+
virtual std::vector<float> getDash() = 0;
|
|
138
|
+
|
|
139
|
+
/** Get the current font */
|
|
140
|
+
virtual sptr<Font> getFont() const = 0;
|
|
141
|
+
|
|
142
|
+
/** Set the font of the context */
|
|
143
|
+
virtual void setFont(const sptr<Font>& font) = 0;
|
|
144
|
+
|
|
145
|
+
/** Get the font size */
|
|
146
|
+
virtual float getFontSize() const = 0;
|
|
147
|
+
|
|
148
|
+
/** Set font size */
|
|
149
|
+
virtual void setFontSize(float size) = 0;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Translate the context by dx, dy
|
|
153
|
+
*
|
|
154
|
+
* @param dx distance in x-direction to translate
|
|
155
|
+
* @param dy distance in y-direction to translate
|
|
156
|
+
*/
|
|
157
|
+
virtual void translate(float dx, float dy) = 0;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Scale the context by sx, sy
|
|
161
|
+
*
|
|
162
|
+
* @param sx scale ratio in x-direction
|
|
163
|
+
* @param sy scale ratio in y-direction
|
|
164
|
+
*/
|
|
165
|
+
virtual void scale(float sx, float sy) = 0;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Rotate the context with the given angle (in radian) and pivot (0, 0).
|
|
169
|
+
*
|
|
170
|
+
* @param angle angle (in radian) amount to rotate
|
|
171
|
+
*/
|
|
172
|
+
virtual void rotate(float angle) = 0;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Rotate the context with the given angle (in radian) and pivot (px, py).
|
|
176
|
+
*
|
|
177
|
+
* @param angle angle (in radian) amount to rotate
|
|
178
|
+
* @param px pivot in x-direction
|
|
179
|
+
* @param py pivot in y-direction
|
|
180
|
+
*/
|
|
181
|
+
virtual void rotate(float angle, float px, float py) = 0;
|
|
182
|
+
|
|
183
|
+
/** Reset transformations */
|
|
184
|
+
virtual void reset() = 0;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Get the scale ratio of the context in x-direction
|
|
188
|
+
*
|
|
189
|
+
* @return the scale in x-direction
|
|
190
|
+
*/
|
|
191
|
+
virtual float sx() const = 0;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Get the scale ratio of the context in y-direction
|
|
195
|
+
*
|
|
196
|
+
* @return the scale in y-direction
|
|
197
|
+
*/
|
|
198
|
+
virtual float sy() const = 0;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Draw glyph, is baseline aligned
|
|
202
|
+
*
|
|
203
|
+
* @param glyph glyph index in the current font
|
|
204
|
+
* @param x x-coordinate
|
|
205
|
+
* @param y y-coordinate, is baseline aligned
|
|
206
|
+
*/
|
|
207
|
+
virtual void drawGlyph(u16 glyph, float x, float y) = 0;
|
|
208
|
+
|
|
209
|
+
// region path commands
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Begin a new path. We promise every path begin with function [beginPath] and
|
|
213
|
+
* end with [fillPath]. You may cache the path via its id.
|
|
214
|
+
*
|
|
215
|
+
* @param id the path id, if id < 0 that means the path is not cacheable.
|
|
216
|
+
* @returns true if the path about to draw given by the id is exists, false otherwise.
|
|
217
|
+
* The id is for optimizing purpose, if the engine find the path is already exists, the
|
|
218
|
+
* following path drawing command will be ignored. If path caching is not supported,
|
|
219
|
+
* just return false.
|
|
220
|
+
*/
|
|
221
|
+
virtual bool beginPath(i32 id) = 0;
|
|
222
|
+
|
|
223
|
+
/** Move to point (x, y). */
|
|
224
|
+
virtual void moveTo(float x, float y) = 0;
|
|
225
|
+
|
|
226
|
+
/** Add a line to path. */
|
|
227
|
+
virtual void lineTo(float x, float y) = 0;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Add a cubic Bezier spline to path, with control points (x1, y1), (x2, y2)
|
|
231
|
+
* and the final point (x3, y3).
|
|
232
|
+
*/
|
|
233
|
+
virtual void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3) = 0;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Add a quadratic Bezier spline to path, with control point (x1, y1) and the
|
|
237
|
+
* final point (x2, y2).
|
|
238
|
+
*/
|
|
239
|
+
virtual void quadTo(float x1, float y1, float x2, float y2) = 0;
|
|
240
|
+
|
|
241
|
+
/** Close the path. */
|
|
242
|
+
virtual void closePath() = 0;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Fill the path with the given id.
|
|
246
|
+
*
|
|
247
|
+
* @param id the path id. If the path is not cacheable, it always is -1.
|
|
248
|
+
*/
|
|
249
|
+
virtual void fillPath(i32 id) = 0;
|
|
250
|
+
|
|
251
|
+
// endregion
|
|
252
|
+
|
|
253
|
+
// region shape commands
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Draw line
|
|
257
|
+
*
|
|
258
|
+
* @param x1 start point in x-direction
|
|
259
|
+
* @param y1 start point in y-direction
|
|
260
|
+
* @param x2 end point in x-direction
|
|
261
|
+
* @param y2 end point in y-direction
|
|
262
|
+
*/
|
|
263
|
+
virtual void drawLine(float x1, float y1, float x2, float y2) = 0;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Draw rectangle
|
|
267
|
+
*
|
|
268
|
+
* @param x left position
|
|
269
|
+
* @param y top position
|
|
270
|
+
* @param w width
|
|
271
|
+
* @param h height
|
|
272
|
+
*/
|
|
273
|
+
virtual void drawRect(float x, float y, float w, float h) = 0;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Fill rectangle
|
|
277
|
+
*
|
|
278
|
+
* @param x left position
|
|
279
|
+
* @param y top position
|
|
280
|
+
* @param w width
|
|
281
|
+
* @param h height
|
|
282
|
+
*/
|
|
283
|
+
virtual void fillRect(float x, float y, float w, float h) = 0;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Draw round rectangle
|
|
287
|
+
*
|
|
288
|
+
* @param x left position
|
|
289
|
+
* @param y top position
|
|
290
|
+
* @param w width
|
|
291
|
+
* @param h height
|
|
292
|
+
* @param rx radius in x-direction
|
|
293
|
+
* @param ry radius in y-direction
|
|
294
|
+
*/
|
|
295
|
+
virtual void drawRoundRect(float x, float y, float w, float h, float rx, float ry) = 0;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Fill round rectangle
|
|
299
|
+
*
|
|
300
|
+
* @param x left position
|
|
301
|
+
* @param y top position
|
|
302
|
+
* @param w width
|
|
303
|
+
* @param h height
|
|
304
|
+
* @param rx radius in x-direction
|
|
305
|
+
* @param ry radius in y-direction
|
|
306
|
+
*/
|
|
307
|
+
virtual void fillRoundRect(float x, float y, float w, float h, float rx, float ry) = 0;
|
|
308
|
+
|
|
309
|
+
// endregion
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
} // namespace microtex
|
|
313
|
+
|
|
314
|
+
#endif // GRAPHIC_H_INCLUDED
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#include "graphic/graphic_basic.h"
|
|
2
|
+
|
|
3
|
+
#include "atom/atom_basic.h"
|
|
4
|
+
#include "utils/string_utils.h"
|
|
5
|
+
|
|
6
|
+
microtex::color microtex::decodeColor(const std::string& s) {
|
|
7
|
+
if (s[0] == '#') {
|
|
8
|
+
const std::string x = s.substr(1);
|
|
9
|
+
color c = black;
|
|
10
|
+
auto success = str2int(s.c_str() + 1, s.length() - 1, reinterpret_cast<int&>(c), 16);
|
|
11
|
+
if (!success) {
|
|
12
|
+
return black;
|
|
13
|
+
}
|
|
14
|
+
if (s.size() == 7) {
|
|
15
|
+
// set alpha value
|
|
16
|
+
c |= 0xff000000;
|
|
17
|
+
} else if (s.size() != 9) {
|
|
18
|
+
return black;
|
|
19
|
+
}
|
|
20
|
+
return c;
|
|
21
|
+
}
|
|
22
|
+
return black;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
microtex::color microtex::getColor(const std::string& name) {
|
|
26
|
+
return ColorAtom::getColor(name);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
bool microtex::Point::operator==(const Point& other) const {
|
|
30
|
+
return x == other.x && y == other.y;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
bool microtex::Rect::operator==(const Rect& other) const {
|
|
34
|
+
return x == other.x && y == other.y && w == other.w && h == other.h;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// clang-format off
|
|
38
|
+
bool microtex::Stroke::operator==(const Stroke& other) const {
|
|
39
|
+
return lineWidth == other.lineWidth
|
|
40
|
+
&& miterLimit == other.miterLimit
|
|
41
|
+
&& cap == other.cap
|
|
42
|
+
&& join == other.join;
|
|
43
|
+
}
|
|
44
|
+
// clang-format on
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
#ifndef GRAPHIC_BASIC_H_INCLUDED
|
|
2
|
+
#define GRAPHIC_BASIC_H_INCLUDED
|
|
3
|
+
|
|
4
|
+
#include <string>
|
|
5
|
+
|
|
6
|
+
#include "microtexexport.h"
|
|
7
|
+
#include "utils/types.h"
|
|
8
|
+
|
|
9
|
+
namespace microtex {
|
|
10
|
+
|
|
11
|
+
using color = std::uint32_t;
|
|
12
|
+
|
|
13
|
+
static constexpr color transparent = 0x00000000;
|
|
14
|
+
static constexpr color black = 0xff000000;
|
|
15
|
+
static constexpr color white = 0xffffffff;
|
|
16
|
+
static constexpr color red = 0xffff0000;
|
|
17
|
+
static constexpr color green = 0xff00ff00;
|
|
18
|
+
static constexpr color blue = 0xff0000ff;
|
|
19
|
+
static constexpr color yellow = 0xffffff00;
|
|
20
|
+
static constexpr color cyan = 0xff00ffff;
|
|
21
|
+
static constexpr color magenta = 0xffff00ff;
|
|
22
|
+
|
|
23
|
+
static constexpr color TRANSPARENT = transparent;
|
|
24
|
+
static constexpr color BLACK = black;
|
|
25
|
+
static constexpr color WHITE = white;
|
|
26
|
+
static constexpr color RED = red;
|
|
27
|
+
static constexpr color GREEN = green;
|
|
28
|
+
static constexpr color BLUE = blue;
|
|
29
|
+
static constexpr color YELLOW = yellow;
|
|
30
|
+
static constexpr color CYAN = cyan;
|
|
31
|
+
static constexpr color MAGENTA = magenta;
|
|
32
|
+
|
|
33
|
+
/** Construct a 32 bit true color with its alpha, red, green and blue channel*/
|
|
34
|
+
inline color MICROTEX_EXPORT argb(int a, int r, int g, int b) {
|
|
35
|
+
return (a << 24) | (r << 16) | (g << 8) | b;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
inline color MICROTEX_EXPORT rgb(int r, int g, int b) {
|
|
39
|
+
return argb(0xff, r, g, b);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
inline color MICROTEX_EXPORT argb(float a, float r, float g, float b) {
|
|
43
|
+
return argb((int)(a * 255), (int)(r * 255), (int)(g * 255), (int)(b * 255));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
inline color MICROTEX_EXPORT rgb(float r, float g, float b) {
|
|
47
|
+
return argb(1.f, r, g, b);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
inline color MICROTEX_EXPORT color_a(color c) {
|
|
51
|
+
return c >> 24;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
inline color MICROTEX_EXPORT color_r(color c) {
|
|
55
|
+
return c >> 16 & 0x00ff;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
inline color MICROTEX_EXPORT color_g(color c) {
|
|
59
|
+
return c >> 8 & 0x0000ff;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
inline color MICROTEX_EXPORT color_b(color c) {
|
|
63
|
+
return c & 0x000000ff;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
inline color MICROTEX_EXPORT cmyk(float c, float m, float y, float k) {
|
|
67
|
+
float kk = 1.f - k;
|
|
68
|
+
return rgb(kk * (1 - c), kk * (1 - m), kk * (1 - y));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Test if the given color is transparent */
|
|
72
|
+
inline bool MICROTEX_EXPORT isTransparent(color c) {
|
|
73
|
+
return (c >> 24 == 0);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Convert #AARRGGBB or #RRGGBB formatted string into color. */
|
|
77
|
+
color MICROTEX_EXPORT decodeColor(const std::string& s);
|
|
78
|
+
|
|
79
|
+
/** Get a color from given name, return black if not found. */
|
|
80
|
+
color MICROTEX_EXPORT getColor(const std::string& name);
|
|
81
|
+
|
|
82
|
+
/** Represents a point in 2D plane */
|
|
83
|
+
struct MICROTEX_EXPORT Point {
|
|
84
|
+
float x, y;
|
|
85
|
+
|
|
86
|
+
Point() : x(0), y(0) {}
|
|
87
|
+
|
|
88
|
+
Point(float x1, float y1) : x(x1), y(y1) {}
|
|
89
|
+
|
|
90
|
+
bool operator==(const Point& other) const;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
struct MICROTEX_EXPORT Rect {
|
|
94
|
+
float x, y, w, h;
|
|
95
|
+
|
|
96
|
+
Rect() : x(0), y(0), w(0), h(0) {}
|
|
97
|
+
|
|
98
|
+
Rect(float x1, float y1, float w1, float h1) : x(x1), y(y1), w(w1), h(h1) {}
|
|
99
|
+
|
|
100
|
+
bool operator==(const Rect& other) const;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** Stroke cap type */
|
|
104
|
+
enum MICROTEX_EXPORT Cap { CAP_BUTT, CAP_ROUND, CAP_SQUARE };
|
|
105
|
+
|
|
106
|
+
/** Stroke join type */
|
|
107
|
+
enum MICROTEX_EXPORT Join { JOIN_BEVEL, JOIN_MITER, JOIN_ROUND };
|
|
108
|
+
|
|
109
|
+
struct MICROTEX_EXPORT Stroke {
|
|
110
|
+
float lineWidth;
|
|
111
|
+
Cap cap;
|
|
112
|
+
Join join;
|
|
113
|
+
float miterLimit;
|
|
114
|
+
|
|
115
|
+
Stroke() : lineWidth(1.f), cap(CAP_ROUND), join(JOIN_ROUND), miterLimit(0) {}
|
|
116
|
+
|
|
117
|
+
Stroke(float w, Cap c, Join j, float ml = 0) : lineWidth(w), cap(c), join(j), miterLimit(ml) {}
|
|
118
|
+
|
|
119
|
+
bool operator==(const Stroke& other) const;
|
|
120
|
+
|
|
121
|
+
inline void set(float w, Cap c, Join j, float ml = 0) {
|
|
122
|
+
lineWidth = w;
|
|
123
|
+
cap = c;
|
|
124
|
+
join = j;
|
|
125
|
+
miterLimit = ml;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
} // namespace microtex
|
|
130
|
+
|
|
131
|
+
#endif // GRAPHIC_BASIC_H_INCLUDED
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#include "macro/macro.h"
|
|
2
|
+
|
|
3
|
+
#include <string>
|
|
4
|
+
|
|
5
|
+
#include "macro/macro_misc.h"
|
|
6
|
+
|
|
7
|
+
using namespace std;
|
|
8
|
+
using namespace microtex;
|
|
9
|
+
|
|
10
|
+
bool NewCommandMacro::_errIfConflict = true;
|
|
11
|
+
|
|
12
|
+
bool NewCommandMacro::isMacro(const string& name) {
|
|
13
|
+
auto it = _codes.find(name);
|
|
14
|
+
return (it != _codes.end());
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
void NewCommandMacro::checkNew(const string& name) {
|
|
18
|
+
if (_errIfConflict && isMacro(name))
|
|
19
|
+
throw ex_parse("Command " + name + " already exists! Use renewcommand instead!");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void NewCommandMacro::checkRenew(const string& name) {
|
|
23
|
+
if (NewCommandMacro::_errIfConflict && !isMacro(name))
|
|
24
|
+
throw ex_parse("Command " + name + " is no defined! Use newcommand instead!");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void NewCommandMacro::addNewCommand(const string& name, const string& code, int argc) {
|
|
28
|
+
checkNew(name);
|
|
29
|
+
_codes[name] = code;
|
|
30
|
+
MacroInfo::add(name, new InflationMacroInfo(_instance, argc));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void NewCommandMacro::addNewCommand(
|
|
34
|
+
const string& name,
|
|
35
|
+
const string& code,
|
|
36
|
+
int argc,
|
|
37
|
+
const string& def
|
|
38
|
+
) {
|
|
39
|
+
checkNew(name);
|
|
40
|
+
_codes[name] = code;
|
|
41
|
+
_replacements[name] = def;
|
|
42
|
+
MacroInfo::add(name, new InflationMacroInfo(_instance, argc, 1));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void NewCommandMacro::addRenewCommand(const string& name, const string& code, int argc) {
|
|
46
|
+
checkRenew(name);
|
|
47
|
+
_codes[name] = code;
|
|
48
|
+
MacroInfo::add(name, new InflationMacroInfo(_instance, argc));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void NewCommandMacro::addRenewCommand(
|
|
52
|
+
const string& name,
|
|
53
|
+
const string& code,
|
|
54
|
+
int argc,
|
|
55
|
+
const string& def
|
|
56
|
+
) {
|
|
57
|
+
checkRenew(name);
|
|
58
|
+
_codes[name] = code;
|
|
59
|
+
_replacements[name] = def;
|
|
60
|
+
MacroInfo::add(name, new InflationMacroInfo(_instance, argc, 1));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void NewCommandMacro::execute(Parser& tp, vector<string>& args) {
|
|
64
|
+
string code = _codes[args[0]];
|
|
65
|
+
string rep;
|
|
66
|
+
size_t argc = args.size() - 12;
|
|
67
|
+
int dec = 0;
|
|
68
|
+
|
|
69
|
+
auto it = _replacements.find(args[0]);
|
|
70
|
+
|
|
71
|
+
// FIXME
|
|
72
|
+
// Keep slash "\" and dollar "$" signs?
|
|
73
|
+
// Example:
|
|
74
|
+
// \newcommand{\cmd}[2][\sqrt{e^x}]{ #2 - #1 }
|
|
75
|
+
// we want the optional argument "\sqrt{e^x}" keep the slash sign
|
|
76
|
+
if (!args[argc + 1].empty()) {
|
|
77
|
+
dec = 1;
|
|
78
|
+
// quotereplace(args[argc + 1], rep);
|
|
79
|
+
replaceAll(code, "#1", args[argc + 1]);
|
|
80
|
+
} else if (it != _replacements.end()) {
|
|
81
|
+
dec = 1;
|
|
82
|
+
// quotereplace(it->second, rep);
|
|
83
|
+
replaceAll(code, "#1", it->second);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
for (int i = 1; i <= argc; i++) {
|
|
87
|
+
rep = args[i];
|
|
88
|
+
replaceAll(code, "#" + toString(i + dec), rep);
|
|
89
|
+
}
|
|
90
|
+
// push back as returned value (inflated macro)
|
|
91
|
+
args.push_back(code);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
void NewEnvironmentMacro::addNewEnvironment(
|
|
95
|
+
const string& name,
|
|
96
|
+
const string& begDef,
|
|
97
|
+
const string& endDef,
|
|
98
|
+
int argc
|
|
99
|
+
) {
|
|
100
|
+
string n = name + "@env";
|
|
101
|
+
string def = begDef + " #" + toString(argc + 1) + " " + endDef;
|
|
102
|
+
addNewCommand(n, def, argc + 1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void NewEnvironmentMacro::addRenewEnvironment(
|
|
106
|
+
const string& name,
|
|
107
|
+
const string& begDef,
|
|
108
|
+
const string& endDef,
|
|
109
|
+
int argc
|
|
110
|
+
) {
|
|
111
|
+
if (_codes.find(name + "@env") == _codes.end()) {
|
|
112
|
+
throw ex_parse("Environment " + name + "is not defined! Use newenvironment instead!");
|
|
113
|
+
}
|
|
114
|
+
addRenewCommand(name + "@env", begDef + " #" + toString(argc + 1) + " " + endDef, argc + 1);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
void NewCommandMacro::_free_() {
|
|
118
|
+
delete _instance;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
void MacroInfo::add(const string& name, MacroInfo* mac) {
|
|
122
|
+
auto it = _commands.find(name);
|
|
123
|
+
if (it != _commands.end()) delete it->second;
|
|
124
|
+
_commands[name] = mac;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
MacroInfo* MacroInfo::get(const std::string& name) {
|
|
128
|
+
auto it = _commands.find(name);
|
|
129
|
+
if (it == _commands.end()) return nullptr;
|
|
130
|
+
return it->second;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
void MacroInfo::_free_() {
|
|
134
|
+
for (const auto& i : _commands) delete i.second;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
sptr<Atom> PreDefMacro::invoke(Parser& tp, vector<string>& args) {
|
|
138
|
+
try {
|
|
139
|
+
return _delegate(tp, args);
|
|
140
|
+
} catch (ex_parse& e) {
|
|
141
|
+
throw ex_parse("Problem with command: " + args[0] + "\n caused by: " + e.what());
|
|
142
|
+
}
|
|
143
|
+
}
|