@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,708 @@
|
|
|
1
|
+
#include "microtexequation.h"
|
|
2
|
+
|
|
3
|
+
#include <cairo-svg.h>
|
|
4
|
+
#include <cairo.h>
|
|
5
|
+
#include <graphic_cairo.h>
|
|
6
|
+
#include <microtex.h>
|
|
7
|
+
#include <utils/exceptions.h>
|
|
8
|
+
#include <utils/nums.h>
|
|
9
|
+
namespace tex = microtex;
|
|
10
|
+
|
|
11
|
+
class MicroTeXErrorState {
|
|
12
|
+
public:
|
|
13
|
+
tex::ex_tex exception;
|
|
14
|
+
|
|
15
|
+
void (*ui_handler)(cairo_t*);
|
|
16
|
+
|
|
17
|
+
gint width;
|
|
18
|
+
gint height;
|
|
19
|
+
gint baseline;
|
|
20
|
+
|
|
21
|
+
MicroTeXErrorState(
|
|
22
|
+
tex::ex_tex& exception,
|
|
23
|
+
void (*fun)(cairo_t*),
|
|
24
|
+
gint width = 128,
|
|
25
|
+
gint height = 16,
|
|
26
|
+
gint baseline = 0
|
|
27
|
+
)
|
|
28
|
+
: exception(std::move(exception)),
|
|
29
|
+
ui_handler(fun),
|
|
30
|
+
width(width),
|
|
31
|
+
height(height),
|
|
32
|
+
baseline(baseline) {}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* MicroTexEquation:
|
|
37
|
+
*
|
|
38
|
+
* `MicroTexEquation` renders a LaTeX equation using
|
|
39
|
+
* [µTeX](https://github.com/NanoMichael/MicroTeX)
|
|
40
|
+
*
|
|
41
|
+
* A basic implementation could be as simple as
|
|
42
|
+
* ```c
|
|
43
|
+
* // allocate this widget
|
|
44
|
+
* GtkWidget* equation = microtex_equation_new();
|
|
45
|
+
* // set the width used to determine when to linebreak (0 means no breaking)
|
|
46
|
+
* microtex_equation_set_width(equation, 0.f);
|
|
47
|
+
* // set the LaTeX string that will be rendered
|
|
48
|
+
* microtex_equation_set_equation(equation, "\\LaTeX");
|
|
49
|
+
* // insert widget into parent: e.g.
|
|
50
|
+
* gtk_box_append(GTK_BOX(parent), equation);
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* A far more in-depth demo application / example is available in the
|
|
54
|
+
* [µTeX github repository](https://github.com/NanoMichael/MicroTeX)
|
|
55
|
+
* under `example/gtk/`.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
typedef struct {
|
|
59
|
+
gboolean shown;
|
|
60
|
+
|
|
61
|
+
tex::Render* microtex;
|
|
62
|
+
MicroTeXErrorState* error;
|
|
63
|
+
|
|
64
|
+
gchar* equation;
|
|
65
|
+
gfloat width;
|
|
66
|
+
|
|
67
|
+
gfloat text_size;
|
|
68
|
+
guint32 color;
|
|
69
|
+
|
|
70
|
+
} MicroTexEquationPrivate;
|
|
71
|
+
|
|
72
|
+
G_DEFINE_TYPE_WITH_PRIVATE(MicroTexEquation, microtex_equation, GTK_TYPE_WIDGET)
|
|
73
|
+
|
|
74
|
+
#define MICROTEX_EQUATION_GET_PRIVATE(obj) \
|
|
75
|
+
static_cast<MicroTexEquationPrivate*>( \
|
|
76
|
+
microtex_equation_get_instance_private(MICROTEX_EQUATION(obj)) \
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
enum { PROP_EQUATION = 1, PROP_WIDTH, PROP_TEXT_SIZE, PROP_COLOR, N_PROPERTIES };
|
|
80
|
+
|
|
81
|
+
static GParamSpec* obj_properties[N_PROPERTIES] = {
|
|
82
|
+
NULL,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
static void
|
|
86
|
+
microtex_equation_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) {
|
|
87
|
+
MicroTexEquation* self = MICROTEX_EQUATION(object);
|
|
88
|
+
|
|
89
|
+
switch (prop_id) {
|
|
90
|
+
case PROP_EQUATION: g_value_set_string(value, microtex_equation_get_equation(self)); break;
|
|
91
|
+
case PROP_WIDTH: g_value_set_float(value, microtex_equation_get_width(self)); break;
|
|
92
|
+
case PROP_TEXT_SIZE: g_value_set_float(value, microtex_equation_get_text_size(self)); break;
|
|
93
|
+
case PROP_COLOR: g_value_set_uint(value, microtex_equation_get_color(self)); break;
|
|
94
|
+
default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static void microtex_equation_set_property(
|
|
99
|
+
GObject* object,
|
|
100
|
+
guint prop_id,
|
|
101
|
+
const GValue* value,
|
|
102
|
+
GParamSpec* pspec
|
|
103
|
+
) {
|
|
104
|
+
MicroTexEquation* self = MICROTEX_EQUATION(object);
|
|
105
|
+
|
|
106
|
+
switch (prop_id) {
|
|
107
|
+
case PROP_EQUATION: microtex_equation_set_equation(self, g_value_get_string(value)); break;
|
|
108
|
+
case PROP_WIDTH: microtex_equation_set_width(self, g_value_get_float(value)); break;
|
|
109
|
+
case PROP_TEXT_SIZE: microtex_equation_set_text_size(self, g_value_get_float(value)); break;
|
|
110
|
+
case PROP_COLOR: microtex_equation_set_color(self, g_value_get_uint(value)); break;
|
|
111
|
+
default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static void microtex_equation_dispose(GObject* object) {
|
|
116
|
+
MicroTexEquationPrivate* priv = MICROTEX_EQUATION_GET_PRIVATE(object);
|
|
117
|
+
|
|
118
|
+
if (priv->microtex) delete priv->microtex;
|
|
119
|
+
if (priv->error) delete priv->error;
|
|
120
|
+
if (priv->equation) g_free(priv->equation);
|
|
121
|
+
|
|
122
|
+
G_OBJECT_CLASS(microtex_equation_parent_class)->dispose(object);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static GtkSizeRequestMode microtex_equation_get_request_mode(GtkWidget* widget) {
|
|
126
|
+
return GTK_SIZE_REQUEST_CONSTANT_SIZE;
|
|
127
|
+
}
|
|
128
|
+
static void microtex_equation_measure(
|
|
129
|
+
GtkWidget* widget,
|
|
130
|
+
GtkOrientation orientation,
|
|
131
|
+
int for_size,
|
|
132
|
+
int* min,
|
|
133
|
+
int* nat,
|
|
134
|
+
int* min_baseline,
|
|
135
|
+
int* nat_baseline
|
|
136
|
+
) {
|
|
137
|
+
MicroTexEquationPrivate* priv = MICROTEX_EQUATION_GET_PRIVATE(widget);
|
|
138
|
+
if (!priv->microtex) {
|
|
139
|
+
g_info("uninitialized microtex\n");
|
|
140
|
+
if (!priv->error) {
|
|
141
|
+
g_critical("uninitialized microtex and error state\n");
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
|
|
146
|
+
*min = priv->error->width;
|
|
147
|
+
*nat = priv->error->width;
|
|
148
|
+
}
|
|
149
|
+
if (orientation == GTK_ORIENTATION_VERTICAL) {
|
|
150
|
+
*min = priv->error->height;
|
|
151
|
+
*nat = priv->error->height;
|
|
152
|
+
*min_baseline = priv->error->baseline;
|
|
153
|
+
*nat_baseline = priv->error->baseline;
|
|
154
|
+
}
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
|
|
159
|
+
*min = priv->microtex->getWidth() + 1;
|
|
160
|
+
*nat = priv->microtex->getWidth() + 1;
|
|
161
|
+
}
|
|
162
|
+
if (orientation == GTK_ORIENTATION_VERTICAL) {
|
|
163
|
+
*min = priv->microtex->getHeight() + 1;
|
|
164
|
+
*nat = priv->microtex->getHeight() + 1;
|
|
165
|
+
if (priv->microtex->getBaseline() == microtex::F_MIN || std::isnan(priv->microtex->getBaseline()))
|
|
166
|
+
return;
|
|
167
|
+
/* *min_baseline = priv->microtex->getBaseline();
|
|
168
|
+
*nat_baseline = priv->microtex->getBaseline();
|
|
169
|
+
// when there is no rendered LaTeX, µTeX sets baseline to -F_MAX
|
|
170
|
+
if (*min_baseline == G_MININT32)
|
|
171
|
+
*min_baseline = 0;
|
|
172
|
+
if (*nat_baseline == G_MININT32)
|
|
173
|
+
*nat_baseline = 0;*/
|
|
174
|
+
gint baseline = (gint)round(0 + *min * (1.0f - priv->microtex->getBaseline()));
|
|
175
|
+
*min_baseline = baseline;
|
|
176
|
+
*nat_baseline = baseline;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
static void microtex_equation_snapshot(GtkWidget* widget, GtkSnapshot* snapshot) {
|
|
180
|
+
MicroTexEquationPrivate* priv = MICROTEX_EQUATION_GET_PRIVATE(widget);
|
|
181
|
+
|
|
182
|
+
gdouble width = gtk_widget_get_allocated_width(widget),
|
|
183
|
+
height = gtk_widget_get_allocated_height(widget);
|
|
184
|
+
|
|
185
|
+
graphene_rect_t rectangle;
|
|
186
|
+
graphene_rect_t* rect = graphene_rect_init(&rectangle, 0, 0, width, height);
|
|
187
|
+
// do I have to free this?
|
|
188
|
+
|
|
189
|
+
cairo_t* ctx = gtk_snapshot_append_cairo(snapshot, rect);
|
|
190
|
+
|
|
191
|
+
if (!priv->microtex) {
|
|
192
|
+
g_info("uninitialized microtex\n");
|
|
193
|
+
if (!priv->error) {
|
|
194
|
+
g_critical("uninitialized microtex and error state\n");
|
|
195
|
+
goto cairo_ctx_free;
|
|
196
|
+
}
|
|
197
|
+
priv->error->ui_handler(ctx);
|
|
198
|
+
} else {
|
|
199
|
+
microtex::Graphics2D_cairo g2(ctx);
|
|
200
|
+
priv->microtex->draw(g2, 0, 0);
|
|
201
|
+
}
|
|
202
|
+
cairo_ctx_free:
|
|
203
|
+
cairo_destroy(ctx);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
static void microtex_equation_create_render(MicroTexEquation* self) {
|
|
207
|
+
MicroTexEquationPrivate* priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
208
|
+
GtkWidget* widget = GTK_WIDGET(self);
|
|
209
|
+
|
|
210
|
+
if (!priv->shown) return;
|
|
211
|
+
|
|
212
|
+
if (priv->microtex) delete priv->microtex;
|
|
213
|
+
|
|
214
|
+
if (priv->error) {
|
|
215
|
+
delete priv->error;
|
|
216
|
+
priv->error = NULL;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (priv->equation) try {
|
|
220
|
+
priv->microtex = tex::MicroTeX::parse(
|
|
221
|
+
std::string(priv->equation),
|
|
222
|
+
microtex_equation_get_width(self),
|
|
223
|
+
microtex_equation_get_text_size(self),
|
|
224
|
+
microtex_equation_get_text_size(self) / 3.f,
|
|
225
|
+
microtex_equation_get_color(self)
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
if (gtk_widget_get_has_tooltip(widget)) gtk_widget_set_has_tooltip(widget, FALSE);
|
|
229
|
+
|
|
230
|
+
} catch (tex::ex_parse& e) {
|
|
231
|
+
g_warning("MicroTeX parsing error: %s\n", e.what());
|
|
232
|
+
|
|
233
|
+
gtk_widget_set_tooltip_text(widget, e.what());
|
|
234
|
+
|
|
235
|
+
priv->error = new MicroTeXErrorState(
|
|
236
|
+
e,
|
|
237
|
+
+[](cairo_t* ctx) {
|
|
238
|
+
cairo_set_source_rgb(ctx, 1, 0, 0);
|
|
239
|
+
cairo_set_font_size(ctx, 10);
|
|
240
|
+
cairo_move_to(ctx, 0, 14);
|
|
241
|
+
cairo_show_text(ctx, "LaTeX parse failed");
|
|
242
|
+
|
|
243
|
+
cairo_fill(ctx);
|
|
244
|
+
}
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
priv->microtex = NULL;
|
|
248
|
+
} catch (tex::ex_invalid_state& e) {
|
|
249
|
+
g_warning("MicroTeX rendering error: %s\n", e.what());
|
|
250
|
+
|
|
251
|
+
gtk_widget_set_tooltip_text(widget, e.what());
|
|
252
|
+
|
|
253
|
+
priv->error = new MicroTeXErrorState(
|
|
254
|
+
e,
|
|
255
|
+
+[](cairo_t* ctx) {
|
|
256
|
+
cairo_set_source_rgb(ctx, 1, 0, 0);
|
|
257
|
+
cairo_set_font_size(ctx, 10);
|
|
258
|
+
cairo_move_to(ctx, 0, 14);
|
|
259
|
+
cairo_show_text(ctx, "LaTeX render failed");
|
|
260
|
+
|
|
261
|
+
cairo_fill(ctx);
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
priv->microtex = NULL;
|
|
266
|
+
} catch (tex::ex_tex& e) {
|
|
267
|
+
g_warning("Unknown MicroTeX error: %s\n", e.what());
|
|
268
|
+
|
|
269
|
+
gtk_widget_set_tooltip_text(widget, e.what());
|
|
270
|
+
|
|
271
|
+
priv->error = new MicroTeXErrorState(
|
|
272
|
+
e,
|
|
273
|
+
+[](cairo_t* ctx) {
|
|
274
|
+
cairo_set_source_rgb(ctx, 1, 0, 0);
|
|
275
|
+
cairo_set_font_size(ctx, 10);
|
|
276
|
+
cairo_move_to(ctx, 0, 14);
|
|
277
|
+
cairo_show_text(ctx, "Unknown MicroTeX error");
|
|
278
|
+
|
|
279
|
+
cairo_fill(ctx);
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
priv->microtex = NULL;
|
|
284
|
+
}
|
|
285
|
+
else
|
|
286
|
+
priv->microtex = NULL;
|
|
287
|
+
|
|
288
|
+
gtk_widget_queue_resize(GTK_WIDGET(self));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
void microtex_equation_show(GtkWidget* widget) {
|
|
292
|
+
MicroTexEquationPrivate* priv = MICROTEX_EQUATION_GET_PRIVATE(widget);
|
|
293
|
+
priv->shown = TRUE;
|
|
294
|
+
microtex_equation_create_render(MICROTEX_EQUATION(widget));
|
|
295
|
+
GTK_WIDGET_CLASS(microtex_equation_parent_class)->show(widget);
|
|
296
|
+
}
|
|
297
|
+
void microtex_equation_hide(GtkWidget* widget) {
|
|
298
|
+
MicroTexEquationPrivate* priv = MICROTEX_EQUATION_GET_PRIVATE(widget);
|
|
299
|
+
priv->shown = FALSE;
|
|
300
|
+
GTK_WIDGET_CLASS(microtex_equation_parent_class)->hide(widget);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
static void microtex_equation_class_init(MicroTexEquationClass* klass) {
|
|
304
|
+
GObjectClass* object_class = G_OBJECT_CLASS(klass);
|
|
305
|
+
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(klass);
|
|
306
|
+
|
|
307
|
+
object_class->get_property = microtex_equation_get_property;
|
|
308
|
+
object_class->set_property = microtex_equation_set_property;
|
|
309
|
+
object_class->dispose = microtex_equation_dispose;
|
|
310
|
+
|
|
311
|
+
widget_class->get_request_mode = microtex_equation_get_request_mode;
|
|
312
|
+
widget_class->measure = microtex_equation_measure;
|
|
313
|
+
widget_class->snapshot = microtex_equation_snapshot;
|
|
314
|
+
|
|
315
|
+
widget_class->show = microtex_equation_show;
|
|
316
|
+
widget_class->hide = microtex_equation_hide;
|
|
317
|
+
|
|
318
|
+
// clang-format off
|
|
319
|
+
/**
|
|
320
|
+
* MicroTexEquation:latex: (attributes org.gtk.Property.get=microtex_equation_get_equation org.gtk.Property.set=microtex_equation_set_equation)
|
|
321
|
+
*
|
|
322
|
+
* The (La)TeX string that the widget will render and display.
|
|
323
|
+
*/
|
|
324
|
+
// clang-format on
|
|
325
|
+
obj_properties[PROP_EQUATION] = g_param_spec_string(
|
|
326
|
+
"latex",
|
|
327
|
+
"LaTeX",
|
|
328
|
+
"LaTeX equation",
|
|
329
|
+
"",
|
|
330
|
+
(GParamFlags)(G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
|
|
331
|
+
);
|
|
332
|
+
// clang-format off
|
|
333
|
+
/**
|
|
334
|
+
* MicroTexEquation:width: (attributes org.gtk.Property.get=microtex_equation_get_width org.gtk.Property.set=microtex_equation_set_width)
|
|
335
|
+
*
|
|
336
|
+
* the width of the 2D graphics context (in pixel) to limit the
|
|
337
|
+
* formula layout, the engine will trying to wrap the layout if it
|
|
338
|
+
* overflows the width, but will fails if formula cannot be split.
|
|
339
|
+
*/
|
|
340
|
+
// clang-format on
|
|
341
|
+
obj_properties[PROP_WIDTH] = g_param_spec_float(
|
|
342
|
+
"width",
|
|
343
|
+
"Width",
|
|
344
|
+
"The maximal width the LaTeX equation may use horizontally",
|
|
345
|
+
-1,
|
|
346
|
+
G_MAXFLOAT,
|
|
347
|
+
-1,
|
|
348
|
+
(GParamFlags)(G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
|
|
349
|
+
);
|
|
350
|
+
// clang-format off
|
|
351
|
+
/**
|
|
352
|
+
* MicroTexEquation:text-size: (attributes org.gtk.Property.get=microtex_equation_get_text_size org.gtk.Property.set=microtex_equation_set_text_size)
|
|
353
|
+
*
|
|
354
|
+
* the text size that the widget will be rendered with.
|
|
355
|
+
*/
|
|
356
|
+
// clang-format on
|
|
357
|
+
obj_properties[PROP_TEXT_SIZE] = g_param_spec_float(
|
|
358
|
+
"text-size",
|
|
359
|
+
"Textsize",
|
|
360
|
+
"The text size to draw",
|
|
361
|
+
6,
|
|
362
|
+
G_MAXFLOAT,
|
|
363
|
+
18,
|
|
364
|
+
(GParamFlags)(G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
|
|
365
|
+
);
|
|
366
|
+
// clang-format off
|
|
367
|
+
/**
|
|
368
|
+
* MicroTexEquation:color: (attributes org.gtk.Property.get=microtex_equation_get_color org.gtk.Property.set=microtex_equation_set_color)
|
|
369
|
+
*
|
|
370
|
+
* the foreground color, in which the equation (unless specifically
|
|
371
|
+
* set otherweise) will be rendered with.
|
|
372
|
+
*
|
|
373
|
+
* The color is saved in an unsigned 32bit (4 bytes) integer in the following format:
|
|
374
|
+
* ```c
|
|
375
|
+
* struct Color {
|
|
376
|
+
* guint8 alpha;
|
|
377
|
+
* guint8 red;
|
|
378
|
+
* guint8 green;
|
|
379
|
+
* guint8 blue;
|
|
380
|
+
* };
|
|
381
|
+
* ```
|
|
382
|
+
* with `0xFF` representing the full channel and `0x00` none.
|
|
383
|
+
* Converting from GdkRGBA could look like this:
|
|
384
|
+
* ```c
|
|
385
|
+
* guint32 color_from_rgba(GdkRGBA color) {
|
|
386
|
+
* return
|
|
387
|
+
* (guint8)(color.alpha*255)<<24|(guint8)(color.red*255)<<16|(guint8)(color.green*255)<<8|(guint8)(color.blue*255);
|
|
388
|
+
* }
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
// clang-format on
|
|
392
|
+
obj_properties[PROP_COLOR] = g_param_spec_uint(
|
|
393
|
+
"color",
|
|
394
|
+
"Color",
|
|
395
|
+
"The foreground color to draw",
|
|
396
|
+
0,
|
|
397
|
+
G_MAXUINT32,
|
|
398
|
+
0xff000000,
|
|
399
|
+
(GParamFlags)(G_PARAM_READWRITE | G_PARAM_CONSTRUCT)
|
|
400
|
+
);
|
|
401
|
+
g_object_class_install_properties(object_class, N_PROPERTIES, obj_properties);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
static void microtex_equation_init(MicroTexEquation* self) {
|
|
405
|
+
MicroTexEquationPrivate* priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
406
|
+
priv->shown = TRUE;
|
|
407
|
+
priv->equation = NULL;
|
|
408
|
+
priv->microtex = NULL;
|
|
409
|
+
priv->width = -1;
|
|
410
|
+
priv->text_size = 18;
|
|
411
|
+
priv->color = 0xff000000;
|
|
412
|
+
|
|
413
|
+
microtex_equation_init_tex();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
extern "C" {
|
|
417
|
+
/**
|
|
418
|
+
* microtex_equation_new:
|
|
419
|
+
*
|
|
420
|
+
* Creates a new `MicroTexEquation` widget.
|
|
421
|
+
*
|
|
422
|
+
* Returns (transfer full): a new `MicroTexEquation`
|
|
423
|
+
*/
|
|
424
|
+
GtkWidget* microtex_equation_new(void) {
|
|
425
|
+
return static_cast<GtkWidget*>(g_object_new(MICROTEX_TYPE_EQUATION, NULL));
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* microtex_equation_get_equation: (attributes org.gtk.Method.get_property=latex)
|
|
430
|
+
* @self: a `MicroTexEquation`
|
|
431
|
+
*
|
|
432
|
+
* Returns the equation (La)TeX string being displayed by this widget.
|
|
433
|
+
*
|
|
434
|
+
* The reference count on the buffer is not incremented; the caller
|
|
435
|
+
* of this function won’t own a new reference.
|
|
436
|
+
*
|
|
437
|
+
* Returns: (nullable) (transfer none): an UTF-8 string. This string is
|
|
438
|
+
* owned by the widget and must not be modified or freed.
|
|
439
|
+
*/
|
|
440
|
+
const gchar* microtex_equation_get_equation(MicroTexEquation* self) {
|
|
441
|
+
MicroTexEquationPrivate* priv;
|
|
442
|
+
g_return_val_if_fail(MICROTEX_IS_EQUATION(self), NULL);
|
|
443
|
+
priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
444
|
+
|
|
445
|
+
return priv->equation;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* microtex_equation_set_equation: (attributes org.gtk.Method.set_property=latex)
|
|
449
|
+
* @self: a `MicroTexEquation`
|
|
450
|
+
* @equation: a valid (La)TeX equation as UTF-8 string
|
|
451
|
+
*
|
|
452
|
+
* Sets the rendered equation of the widget to @equation.
|
|
453
|
+
*
|
|
454
|
+
* This will override any previously set equations.
|
|
455
|
+
*/
|
|
456
|
+
void microtex_equation_set_equation(MicroTexEquation* self, const gchar* equation) {
|
|
457
|
+
MicroTexEquationPrivate* priv;
|
|
458
|
+
g_return_if_fail(MICROTEX_IS_EQUATION(self));
|
|
459
|
+
priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
460
|
+
|
|
461
|
+
if (priv->equation == equation) return;
|
|
462
|
+
|
|
463
|
+
if (g_strcmp0(priv->equation, equation) == 0) return;
|
|
464
|
+
|
|
465
|
+
if (priv->equation) g_free(priv->equation);
|
|
466
|
+
|
|
467
|
+
priv->equation = g_strdup(equation);
|
|
468
|
+
|
|
469
|
+
microtex_equation_create_render(self);
|
|
470
|
+
|
|
471
|
+
g_object_notify_by_pspec(G_OBJECT(self), obj_properties[PROP_EQUATION]);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* microtex_equation_get_width: (attributes org.gtk.Method.get_property=width)
|
|
476
|
+
* @self: a `MicroTexEquation`
|
|
477
|
+
*
|
|
478
|
+
* Returns the width that the graphic context uses to determine when to
|
|
479
|
+
* break the line within the equation.
|
|
480
|
+
*
|
|
481
|
+
* See [property@MicroTex.Equation:width].
|
|
482
|
+
*
|
|
483
|
+
* Returns: an IEEE 764 floating point number. `0` when infinitly long
|
|
484
|
+
*/
|
|
485
|
+
gfloat microtex_equation_get_width(MicroTexEquation* self) {
|
|
486
|
+
MicroTexEquationPrivate* priv;
|
|
487
|
+
g_return_val_if_fail(MICROTEX_IS_EQUATION(self), NAN);
|
|
488
|
+
priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
489
|
+
|
|
490
|
+
return priv->width;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* microtex_equation_set_width: (attributes org.gtk.Method.set_property=width)
|
|
495
|
+
* @self: a `MicroTexEquation`
|
|
496
|
+
* @width: width in IEEE 754 floating point format
|
|
497
|
+
*
|
|
498
|
+
* Sets the width that the context uses to determine when to linebreak.
|
|
499
|
+
*
|
|
500
|
+
* See [property@MicroTex.Equation:width].
|
|
501
|
+
*/
|
|
502
|
+
void microtex_equation_set_width(MicroTexEquation* self, gfloat width) {
|
|
503
|
+
MicroTexEquationPrivate* priv;
|
|
504
|
+
g_return_if_fail(MICROTEX_IS_EQUATION(self));
|
|
505
|
+
priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
506
|
+
|
|
507
|
+
if (priv->width == width) return;
|
|
508
|
+
|
|
509
|
+
priv->width = width;
|
|
510
|
+
|
|
511
|
+
microtex_equation_create_render(self);
|
|
512
|
+
|
|
513
|
+
g_object_notify_by_pspec(G_OBJECT(self), obj_properties[PROP_WIDTH]);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* microtex_equation_get_text_size: (attributes org.gtk.Method.get_property=text-size)
|
|
518
|
+
* @self: a `MicroTexEquation`
|
|
519
|
+
*
|
|
520
|
+
* Returns the current text size.
|
|
521
|
+
*
|
|
522
|
+
* See [property@MicroTex.Equation:text-size].
|
|
523
|
+
*
|
|
524
|
+
* Returns: an IEEE 764 floating point number representing the text
|
|
525
|
+
* size
|
|
526
|
+
*/
|
|
527
|
+
gfloat microtex_equation_get_text_size(MicroTexEquation* self) {
|
|
528
|
+
MicroTexEquationPrivate* priv;
|
|
529
|
+
g_return_val_if_fail(MICROTEX_IS_EQUATION(self), NAN);
|
|
530
|
+
priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
531
|
+
|
|
532
|
+
return priv->text_size;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* microtex_equation_set_text_size: (attributes org.gtk.Method.set_property=text-size)
|
|
537
|
+
* @self: a `MicroTexEquation`
|
|
538
|
+
* @text_size: text size in IEEE 754 floating point format
|
|
539
|
+
*
|
|
540
|
+
* Sets the text size
|
|
541
|
+
*
|
|
542
|
+
* See [property@MicroTex.Equation:text-size].
|
|
543
|
+
*/
|
|
544
|
+
void microtex_equation_set_text_size(MicroTexEquation* self, gfloat text_size) {
|
|
545
|
+
MicroTexEquationPrivate* priv;
|
|
546
|
+
g_return_if_fail(MICROTEX_IS_EQUATION(self));
|
|
547
|
+
priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
548
|
+
|
|
549
|
+
if (priv->text_size == text_size) return;
|
|
550
|
+
|
|
551
|
+
priv->text_size = text_size;
|
|
552
|
+
|
|
553
|
+
if (priv->microtex) {
|
|
554
|
+
priv->microtex->setTextSize(priv->text_size);
|
|
555
|
+
gtk_widget_queue_resize(GTK_WIDGET(self));
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
g_object_notify_by_pspec(G_OBJECT(self), obj_properties[PROP_TEXT_SIZE]);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* microtex_equation_get_color: (attributes org.gtk.Method.get_property=color)
|
|
563
|
+
* @self: a `MicroTexEquation`
|
|
564
|
+
*
|
|
565
|
+
* Returns the current color of the equation.
|
|
566
|
+
*
|
|
567
|
+
* See [property@MicroTex.Equation:color] for the format.
|
|
568
|
+
*
|
|
569
|
+
* Returns: an unsigned 32bit integer. The format is defined in
|
|
570
|
+
* [property@MicroTex.Equation:color].
|
|
571
|
+
*/
|
|
572
|
+
guint32 microtex_equation_get_color(MicroTexEquation* self) {
|
|
573
|
+
MicroTexEquationPrivate* priv;
|
|
574
|
+
g_return_val_if_fail(MICROTEX_IS_EQUATION(self), 0xff000000);
|
|
575
|
+
priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
576
|
+
|
|
577
|
+
return priv->color;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* microtex_equation_set_color: (attributes org.gtk.Method.set_property=color)
|
|
582
|
+
* @self: a `MicroTexEquation`
|
|
583
|
+
* @color: color in the format specified in [property@MicroTex.Equation:color]
|
|
584
|
+
*
|
|
585
|
+
* Sets the color
|
|
586
|
+
*
|
|
587
|
+
* See [property@MicroTex.Equation:color].
|
|
588
|
+
*/
|
|
589
|
+
void microtex_equation_set_color(MicroTexEquation* self, guint32 color) {
|
|
590
|
+
MicroTexEquationPrivate* priv;
|
|
591
|
+
g_return_if_fail(MICROTEX_IS_EQUATION(self));
|
|
592
|
+
priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
593
|
+
|
|
594
|
+
if (priv->color == color) return;
|
|
595
|
+
|
|
596
|
+
priv->color = color;
|
|
597
|
+
|
|
598
|
+
if (priv->microtex) {
|
|
599
|
+
priv->microtex->setForeground(priv->color);
|
|
600
|
+
gtk_widget_queue_draw(GTK_WIDGET(self));
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
g_object_notify_by_pspec(G_OBJECT(self), obj_properties[PROP_COLOR]);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* microtex_equation_get_baseline:
|
|
608
|
+
* @self: a `MicroTexEquation`
|
|
609
|
+
*
|
|
610
|
+
* Gets the baseline of the rendered Equation in GTK format
|
|
611
|
+
*
|
|
612
|
+
* Returns: the baseline as signed 64bit integer
|
|
613
|
+
*/
|
|
614
|
+
gint64 microtex_equation_get_baseline(MicroTexEquation* self) {
|
|
615
|
+
MicroTexEquationPrivate* priv;
|
|
616
|
+
g_return_val_if_fail(MICROTEX_IS_EQUATION(self), -1);
|
|
617
|
+
priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
618
|
+
|
|
619
|
+
if (!priv->microtex) return -1;
|
|
620
|
+
|
|
621
|
+
int height = priv->microtex->getHeight();
|
|
622
|
+
gint64 baseline = (gint64)round(0 + height * (1.0f - priv->microtex->getBaseline()));
|
|
623
|
+
|
|
624
|
+
// workaround for not entirely correct baseline arithmetic
|
|
625
|
+
if (height > 12) baseline += 1;
|
|
626
|
+
|
|
627
|
+
return baseline;
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
static cairo_status_t array_writer_fun(GArray** array, const guint8* data, uint len) {
|
|
631
|
+
*array = g_array_append_vals(*array, data, len);
|
|
632
|
+
return CAIRO_STATUS_SUCCESS;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* microtex_equation_to_svg:
|
|
636
|
+
* @self: a `MicroTexEquation`
|
|
637
|
+
* @success (nullable): stores %TRUE if the rendered equation was valid
|
|
638
|
+
*
|
|
639
|
+
* Converts the equation to svg format.
|
|
640
|
+
*
|
|
641
|
+
* Keep in mind, that this method can store %FALSE in `@success` and
|
|
642
|
+
* still return a `GBytes`. In these cases the svg will contain the
|
|
643
|
+
* same error message that the widget itself also renders.
|
|
644
|
+
* It is up to the discretion of the implementor whether to continue
|
|
645
|
+
* working with the image or to discard (and free) it.
|
|
646
|
+
*
|
|
647
|
+
* Returns (nullable) (transfer full): the SVG as `GBytes` for future consumption
|
|
648
|
+
*/
|
|
649
|
+
GBytes* microtex_equation_to_svg(MicroTexEquation* self, gboolean* success) {
|
|
650
|
+
MicroTexEquationPrivate* priv;
|
|
651
|
+
g_return_val_if_fail(MICROTEX_IS_EQUATION(self), NULL);
|
|
652
|
+
priv = MICROTEX_EQUATION_GET_PRIVATE(self);
|
|
653
|
+
|
|
654
|
+
GByteArray* array = g_byte_array_new();
|
|
655
|
+
cairo_surface_t* svg = cairo_svg_surface_create_for_stream(
|
|
656
|
+
(cairo_write_func_t)array_writer_fun,
|
|
657
|
+
&array,
|
|
658
|
+
(double)priv->microtex->getWidth(),
|
|
659
|
+
(double)priv->microtex->getHeight()
|
|
660
|
+
);
|
|
661
|
+
cairo_t* ctx = cairo_create(svg);
|
|
662
|
+
|
|
663
|
+
if (!priv->microtex) {
|
|
664
|
+
g_info("uninitialized microtex\n");
|
|
665
|
+
if (success) *success = FALSE;
|
|
666
|
+
if (!priv->error) {
|
|
667
|
+
g_critical("uninitialized microtex and error state\n");
|
|
668
|
+
cairo_destroy(ctx);
|
|
669
|
+
cairo_surface_destroy(svg);
|
|
670
|
+
g_byte_array_unref(array);
|
|
671
|
+
return NULL;
|
|
672
|
+
}
|
|
673
|
+
priv->error->ui_handler(ctx);
|
|
674
|
+
} else {
|
|
675
|
+
microtex::Graphics2D_cairo g2(ctx);
|
|
676
|
+
priv->microtex->draw(g2, 0, 0);
|
|
677
|
+
if (success) *success = TRUE;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
cairo_destroy(ctx);
|
|
681
|
+
cairo_surface_destroy(svg);
|
|
682
|
+
|
|
683
|
+
return g_byte_array_free_to_bytes(array);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* microtex_equation_init_tex:
|
|
688
|
+
*
|
|
689
|
+
* Initializes the µTeX renderer
|
|
690
|
+
*
|
|
691
|
+
* `MicroTexEquation` will call this function during init, so you
|
|
692
|
+
* typically don't need to call this function yourself.
|
|
693
|
+
*/
|
|
694
|
+
gboolean microtex_equation_init_tex() {
|
|
695
|
+
if (tex::MicroTeX::isInited()) {
|
|
696
|
+
g_info("MicroTeX already initialized\n");
|
|
697
|
+
return FALSE;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
tex::InitFontSenseAuto autoinit;
|
|
701
|
+
tex::MicroTeX::init(autoinit);
|
|
702
|
+
tex::PlatformFactory::registerFactory("gtk", std::make_unique<tex::PlatformFactory_cairo>());
|
|
703
|
+
tex::PlatformFactory::activate("gtk");
|
|
704
|
+
tex::MicroTeX::overrideTexStyle(true, tex::TexStyle::display);
|
|
705
|
+
|
|
706
|
+
return TRUE;
|
|
707
|
+
}
|
|
708
|
+
}
|