@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,405 @@
|
|
|
1
|
+
#include "otf/clm.h"
|
|
2
|
+
|
|
3
|
+
#include <cstring>
|
|
4
|
+
|
|
5
|
+
#include "utils/exceptions.h"
|
|
6
|
+
#include "utils/string_utils.h"
|
|
7
|
+
|
|
8
|
+
namespace microtex {
|
|
9
|
+
|
|
10
|
+
class BinaryReader {
|
|
11
|
+
public:
|
|
12
|
+
virtual ~BinaryReader() = default;
|
|
13
|
+
|
|
14
|
+
virtual const u8* readBytes(size_t bytes) = 0;
|
|
15
|
+
|
|
16
|
+
virtual size_t lookfwd(u8 until) = 0;
|
|
17
|
+
|
|
18
|
+
template <typename T>
|
|
19
|
+
T read() {
|
|
20
|
+
const auto bytes = sizeof(T);
|
|
21
|
+
const u8* p = readBytes(bytes);
|
|
22
|
+
auto shift = bytes - 1;
|
|
23
|
+
T t = 0;
|
|
24
|
+
for (std::size_t i = 0; i < bytes; i++) {
|
|
25
|
+
t |= static_cast<T>(*(p + i)) << ((shift - i) * 8);
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const char* readString() {
|
|
31
|
+
size_t len = lookfwd(0x00);
|
|
32
|
+
const char* ret = (const char*)readBytes(len);
|
|
33
|
+
return ret;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
class BinaryFileReader : public BinaryReader {
|
|
38
|
+
private:
|
|
39
|
+
constexpr static const u32 CHUNK_SIZE = 10 * 1024;
|
|
40
|
+
FILE* _file;
|
|
41
|
+
u8 _buff[CHUNK_SIZE]{};
|
|
42
|
+
u32 _currentSize = 0;
|
|
43
|
+
u32 _index = 0;
|
|
44
|
+
bool _eof = false;
|
|
45
|
+
|
|
46
|
+
void readChunk(u32 remain = 0) {
|
|
47
|
+
if (_eof) return;
|
|
48
|
+
const auto size = CHUNK_SIZE - remain;
|
|
49
|
+
memcpy(_buff, _buff + size, remain);
|
|
50
|
+
auto read = fread(_buff + remain, 1, size, _file);
|
|
51
|
+
if (read < size) _eof = true;
|
|
52
|
+
_currentSize = read + remain;
|
|
53
|
+
_index = 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
explicit BinaryFileReader(const char* filePath) {
|
|
58
|
+
_file = fopen(filePath, "rb");
|
|
59
|
+
if (_file == nullptr) {
|
|
60
|
+
throw ex_file_not_found(std::string(filePath) + " cannot be opened.");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const u8* readBytes(size_t bytes) override {
|
|
65
|
+
const auto remain = _currentSize - _index;
|
|
66
|
+
if (remain < bytes) readChunk(remain);
|
|
67
|
+
if (_index >= _currentSize) throw ex_eof("end of data");
|
|
68
|
+
const u8* p = _buff + _index;
|
|
69
|
+
_index += bytes;
|
|
70
|
+
return p;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
size_t lookfwd(u8 until) override {
|
|
74
|
+
size_t len = 0;
|
|
75
|
+
u8 active = 0x00;
|
|
76
|
+
while (active != until || len == 0) {
|
|
77
|
+
const auto remain = _currentSize - (_index + len);
|
|
78
|
+
if (remain < 32) readChunk(32);
|
|
79
|
+
|
|
80
|
+
if (_index + len >= _currentSize) throw ex_eof("end of data");
|
|
81
|
+
active = _buff[_index + len];
|
|
82
|
+
len++;
|
|
83
|
+
}
|
|
84
|
+
return len;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
~BinaryFileReader() override {
|
|
88
|
+
if (_file != nullptr) fclose(_file);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
class BinaryDataReader : public BinaryReader {
|
|
93
|
+
private:
|
|
94
|
+
const u8* _data;
|
|
95
|
+
const size_t _len;
|
|
96
|
+
u32 _index = 0;
|
|
97
|
+
|
|
98
|
+
public:
|
|
99
|
+
explicit BinaryDataReader(size_t len, const u8* data) : _len(len), _data(data) {}
|
|
100
|
+
|
|
101
|
+
const u8* readBytes(size_t bytes) override {
|
|
102
|
+
if (_index >= _len) throw ex_eof("end of data");
|
|
103
|
+
const u8* p = _data + _index;
|
|
104
|
+
_index += bytes;
|
|
105
|
+
return p;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
size_t lookfwd(u8 until) override {
|
|
109
|
+
size_t len = 0;
|
|
110
|
+
u8 active = 0x00;
|
|
111
|
+
while (active != until || len == 0) {
|
|
112
|
+
if (_index + len >= _len) throw ex_eof("end of data");
|
|
113
|
+
active = _data[_index + len];
|
|
114
|
+
len++;
|
|
115
|
+
}
|
|
116
|
+
return len;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
void CLMReader::readMeta(Otf& font, BinaryReader& reader) {
|
|
121
|
+
font._name = std::string(reader.readString());
|
|
122
|
+
font._family = std::string(reader.readString());
|
|
123
|
+
font._isMathFont = reader.read<u8>();
|
|
124
|
+
font._style = reader.read<u16>();
|
|
125
|
+
font._em = reader.read<u16>();
|
|
126
|
+
font._xHeight = reader.read<u16>();
|
|
127
|
+
font._ascent = reader.read<u16>();
|
|
128
|
+
font._descent = reader.read<u16>();
|
|
129
|
+
u16 count = reader.read<u16>();
|
|
130
|
+
u32* unicodes = new u32[count];
|
|
131
|
+
u16* glyphs = new u16[count];
|
|
132
|
+
for (u16 i = 0; i < count; i++) {
|
|
133
|
+
unicodes[i] = reader.read<u32>();
|
|
134
|
+
glyphs[i] = reader.read<u16>();
|
|
135
|
+
}
|
|
136
|
+
font._unicodeCount = count;
|
|
137
|
+
font._unicodes = unicodes;
|
|
138
|
+
font._unicodeGlyphs = glyphs;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
std::pair<u16, u16*> CLMReader::readClassKerningGlyphs(BinaryReader& reader) {
|
|
142
|
+
const u16 count = reader.read<u16>();
|
|
143
|
+
u16* glyphs = new u16[count * 2];
|
|
144
|
+
for (u16 i = 0; i < count; i++) {
|
|
145
|
+
glyphs[i << 1] = reader.read<u16>();
|
|
146
|
+
glyphs[(i << 1) + 1] = reader.read<u16>();
|
|
147
|
+
}
|
|
148
|
+
return std::make_pair(count, glyphs);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
ClassKerning* CLMReader::readClassKerning(BinaryReader& reader) {
|
|
152
|
+
auto* ptr = new ClassKerning();
|
|
153
|
+
ClassKerning& ck = *ptr;
|
|
154
|
+
// read left glyphs
|
|
155
|
+
ck._rowLength = reader.read<u16>();
|
|
156
|
+
auto [lc, lg] = readClassKerningGlyphs(reader);
|
|
157
|
+
ck._leftCount = lc;
|
|
158
|
+
ck._lefts = lg;
|
|
159
|
+
// read right glyphs
|
|
160
|
+
ck._columnLength = reader.read<u16>();
|
|
161
|
+
auto [rc, rg] = readClassKerningGlyphs(reader);
|
|
162
|
+
ck._rightCount = rc;
|
|
163
|
+
ck._rights = rg;
|
|
164
|
+
// read table
|
|
165
|
+
const u32 size = (u32)ck._rowLength * (u32)ck._columnLength;
|
|
166
|
+
i16* table = new i16[size];
|
|
167
|
+
for (u32 i = 0; i < size; i++) {
|
|
168
|
+
table[i] = reader.read<i16>();
|
|
169
|
+
}
|
|
170
|
+
ck._table = table;
|
|
171
|
+
return ptr;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
void CLMReader::readClassKernings(Otf& font, BinaryReader& reader) {
|
|
175
|
+
const u16 count = reader.read<u16>();
|
|
176
|
+
font._classKerningCount = count;
|
|
177
|
+
if (count == 0) {
|
|
178
|
+
font._classKernings = nullptr;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
font._classKernings = new ClassKerning*[count];
|
|
182
|
+
for (u16 i = 0; i < count; i++) {
|
|
183
|
+
font._classKernings[i] = readClassKerning(reader);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
LigaTable* CLMReader::readLigatures(BinaryReader& reader) {
|
|
188
|
+
const u16 glyph = reader.read<u16>();
|
|
189
|
+
const i32 liga = reader.read<i32>();
|
|
190
|
+
const u16 childCount = reader.read<u16>();
|
|
191
|
+
auto* t = new LigaTable(glyph, liga, childCount);
|
|
192
|
+
for (u16 i = 0; i < childCount; i++) {
|
|
193
|
+
t->child(i) = readLigatures(reader);
|
|
194
|
+
}
|
|
195
|
+
return t;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
MathConsts* CLMReader::readMathConsts(BinaryReader& reader) {
|
|
199
|
+
auto* consts = new MathConsts();
|
|
200
|
+
for (i16& _field : consts->_fields) {
|
|
201
|
+
_field = reader.read<i16>();
|
|
202
|
+
}
|
|
203
|
+
return consts;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
KernRecord* CLMReader::readKerns(BinaryReader& reader) {
|
|
207
|
+
const u16 count = reader.read<u16>();
|
|
208
|
+
if (count == 0) return nullptr;
|
|
209
|
+
auto* record = new KernRecord(count);
|
|
210
|
+
for (u16 i = 0; i < count; i++) {
|
|
211
|
+
record->_fields[i << 1] = reader.read<u16>();
|
|
212
|
+
record->_fields[(i << 1) + 1] = reader.read<i16>();
|
|
213
|
+
}
|
|
214
|
+
return record;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
Variants* CLMReader::readVariants(BinaryReader& reader) {
|
|
218
|
+
const u16 count = reader.read<u16>();
|
|
219
|
+
if (count == 0) return nullptr;
|
|
220
|
+
auto* variants = new Variants(count);
|
|
221
|
+
for (u16 i = 0; i < count; i++) {
|
|
222
|
+
variants->_glyphs[i] = reader.read<u16>();
|
|
223
|
+
}
|
|
224
|
+
return variants;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
GlyphAssembly* CLMReader::readGlyphAssembly(BinaryReader& reader) {
|
|
228
|
+
const bool isPresent = reader.read<u8>();
|
|
229
|
+
if (!isPresent) return nullptr;
|
|
230
|
+
const u16 partCount = reader.read<u16>();
|
|
231
|
+
auto* assembly = new GlyphAssembly(partCount);
|
|
232
|
+
assembly->_italicsCorrection = reader.read<i16>();
|
|
233
|
+
for (u16 i = 0; i < partCount; i++) {
|
|
234
|
+
GlyphPart& part = assembly->_parts[i];
|
|
235
|
+
part._glyph = reader.read<u16>();
|
|
236
|
+
part._flags = reader.read<u16>();
|
|
237
|
+
part._startConnectorLength = reader.read<u16>();
|
|
238
|
+
part._endConnectorLength = reader.read<u16>();
|
|
239
|
+
part._fullAdvance = reader.read<u16>();
|
|
240
|
+
}
|
|
241
|
+
return assembly;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
Math* CLMReader::readMath(BinaryReader& reader) {
|
|
245
|
+
Math* ptr = new Math(0);
|
|
246
|
+
Math& math = *ptr;
|
|
247
|
+
math._italicsCorrection = reader.read<i16>();
|
|
248
|
+
math._topAccentAttachment = reader.read<i16>();
|
|
249
|
+
// variants
|
|
250
|
+
Variants* hv = readVariants(reader);
|
|
251
|
+
math._horizontalVariants = hv == nullptr ? &Variants::empty : hv;
|
|
252
|
+
Variants* vv = readVariants(reader);
|
|
253
|
+
math._verticalVariants = vv == nullptr ? &Variants::empty : vv;
|
|
254
|
+
Variants* ss = readVariants(reader);
|
|
255
|
+
math._scriptsVariants = ss == nullptr ? &Variants::empty : ss;
|
|
256
|
+
// glyph assembly
|
|
257
|
+
GlyphAssembly* hg = readGlyphAssembly(reader);
|
|
258
|
+
math._horizontalAssembly = hg == nullptr ? &GlyphAssembly::empty : hg;
|
|
259
|
+
GlyphAssembly* vg = readGlyphAssembly(reader);
|
|
260
|
+
math._verticalAssembly = vg == nullptr ? &GlyphAssembly::empty : vg;
|
|
261
|
+
// kern record
|
|
262
|
+
auto* record = new MathKernRecord(0);
|
|
263
|
+
for (auto& field : record->_fields) {
|
|
264
|
+
const u16 count = reader.read<u16>();
|
|
265
|
+
if (count == 0) {
|
|
266
|
+
field = &MathKern::empty;
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
auto* kern = new MathKern(count);
|
|
270
|
+
for (u16 i = 0; i < count; i++) {
|
|
271
|
+
kern->_fields[i << 1] = reader.read<i16>();
|
|
272
|
+
kern->_fields[(i << 1) + 1] = reader.read<i16>();
|
|
273
|
+
}
|
|
274
|
+
field = kern;
|
|
275
|
+
}
|
|
276
|
+
math._kernRecord = record;
|
|
277
|
+
return ptr;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
#ifdef HAVE_GLYPH_RENDER_PATH
|
|
281
|
+
|
|
282
|
+
Path* CLMReader::readPath(BinaryReader& reader) {
|
|
283
|
+
// !NOT THREAD SAFE
|
|
284
|
+
static i32 id = 0;
|
|
285
|
+
|
|
286
|
+
const auto len = reader.read<u16>();
|
|
287
|
+
if (len == 0) return nullptr;
|
|
288
|
+
auto cmds = new PathCmd*[len];
|
|
289
|
+
for (u16 i = 0; i < len; i++) {
|
|
290
|
+
const auto cmd = reader.read<char>();
|
|
291
|
+
const auto cnt = microtex::pathCmdArgsCount(cmd);
|
|
292
|
+
auto args = new i16[cnt];
|
|
293
|
+
for (u16 j = 0; j < cnt; j++) {
|
|
294
|
+
args[j] = reader.read<i16>();
|
|
295
|
+
}
|
|
296
|
+
cmds[i] = new PathCmd(cmd, args);
|
|
297
|
+
}
|
|
298
|
+
return new Path(++id, len, cmds);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
#else
|
|
302
|
+
|
|
303
|
+
void CLMReader::skipGlyphPath(BinaryReader& reader) {
|
|
304
|
+
const auto len = reader.read<u16>();
|
|
305
|
+
if (len == 0) return;
|
|
306
|
+
for (u16 i = 0; i < len; i++) {
|
|
307
|
+
const auto cmd = reader.read<char>();
|
|
308
|
+
const auto cnt = microtex::pathCmdArgsCount(cmd);
|
|
309
|
+
for (u16 j = 0; j < cnt; j++) {
|
|
310
|
+
reader.read<i16>();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
#endif // HAVE_GLYPH_RENDER_PATH
|
|
316
|
+
|
|
317
|
+
Glyph* CLMReader::readGlyph(bool isMathFont, bool hasGlyphPath, BinaryReader& reader) {
|
|
318
|
+
auto* glyph = new Glyph();
|
|
319
|
+
// Metrics is required
|
|
320
|
+
glyph->_metrics._width = reader.read<i16>();
|
|
321
|
+
glyph->_metrics._height = reader.read<i16>();
|
|
322
|
+
glyph->_metrics._depth = reader.read<i16>();
|
|
323
|
+
// read kern record, optional
|
|
324
|
+
auto kern = readKerns(reader);
|
|
325
|
+
glyph->_kernRecord = kern == nullptr ? &KernRecord::empty : kern;
|
|
326
|
+
// read math, optional
|
|
327
|
+
glyph->_math = isMathFont ? readMath(reader) : &Math::empty;
|
|
328
|
+
#ifdef HAVE_GLYPH_RENDER_PATH
|
|
329
|
+
// read path
|
|
330
|
+
if (hasGlyphPath) {
|
|
331
|
+
auto path = readPath(reader);
|
|
332
|
+
glyph->_path = path == nullptr ? &Path::empty : path;
|
|
333
|
+
} else {
|
|
334
|
+
// The font does not have glyph paths, although we have the path render
|
|
335
|
+
// capability
|
|
336
|
+
glyph->_path = &Path::empty;
|
|
337
|
+
}
|
|
338
|
+
#else
|
|
339
|
+
// Need to skip the glyph paths, because we don't have the path render
|
|
340
|
+
// capability
|
|
341
|
+
if (hasGlyphPath) skipGlyphPath(reader);
|
|
342
|
+
#endif
|
|
343
|
+
return glyph;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
void CLMReader::readGlyphs(Otf& font, bool hasGlyphPath, BinaryReader& reader) {
|
|
347
|
+
const u16 count = reader.read<u16>();
|
|
348
|
+
auto** glyphs = new Glyph*[count];
|
|
349
|
+
for (u16 i = 0; i < count; i++) {
|
|
350
|
+
glyphs[i] = readGlyph(font._isMathFont, hasGlyphPath, reader);
|
|
351
|
+
}
|
|
352
|
+
font._glyphCount = count;
|
|
353
|
+
font._glyphs = glyphs;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
Otf* CLMReader::read(BinaryReader& reader) {
|
|
357
|
+
// read format
|
|
358
|
+
const auto c = reader.read<u8>();
|
|
359
|
+
const auto l = reader.read<u8>();
|
|
360
|
+
const auto m = reader.read<u8>();
|
|
361
|
+
if (c != 'c' || l != 'l' || m != 'm') {
|
|
362
|
+
throw ex_invalid_param("invalid clm data format");
|
|
363
|
+
}
|
|
364
|
+
const auto ver = reader.read<u16>();
|
|
365
|
+
if (ver != CLM_VER_MAJOR) {
|
|
366
|
+
throw ex_invalid_param(
|
|
367
|
+
"clm data (with version: " + toString(ver) + ") does not match the required version ("
|
|
368
|
+
+ toString(CLM_VER_MAJOR) + ")!"
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
const auto minor = reader.read<u8>();
|
|
372
|
+
const bool hasGlyphPath = CLM_SUPPORT_GLYPH_PATH(minor);
|
|
373
|
+
#if GLYPH_RENDER_TYPE == GLYPH_RENDER_TYPE_PATH
|
|
374
|
+
if (!hasGlyphPath) {
|
|
375
|
+
throw ex_invalid_param("The given clm data does not have glyph paths.");
|
|
376
|
+
}
|
|
377
|
+
#endif
|
|
378
|
+
// read otf-spec
|
|
379
|
+
Otf* font = new Otf();
|
|
380
|
+
font->_hasGlyphPath = hasGlyphPath;
|
|
381
|
+
#ifdef HAVE_GLYPH_RENDER_PATH
|
|
382
|
+
font->_hasGlyphPath = hasGlyphPath;
|
|
383
|
+
#else
|
|
384
|
+
// We don't have the path render capability
|
|
385
|
+
font->_hasGlyphPath = false;
|
|
386
|
+
#endif
|
|
387
|
+
readMeta(*font, reader);
|
|
388
|
+
readClassKernings(*font, reader);
|
|
389
|
+
font->_ligatures = readLigatures(reader);
|
|
390
|
+
font->_mathConsts = font->_isMathFont ? readMathConsts(reader) : nullptr;
|
|
391
|
+
readGlyphs(*font, hasGlyphPath, reader);
|
|
392
|
+
return font;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
Otf* CLMReader::read(const char* clmFilePath) const {
|
|
396
|
+
BinaryFileReader reader(clmFilePath);
|
|
397
|
+
return read(reader);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
Otf* CLMReader::read(size_t len, const u8* bytes) const {
|
|
401
|
+
BinaryDataReader reader(len, bytes);
|
|
402
|
+
return read(reader);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
} // namespace microtex
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#ifndef MICROTEX_CLM_H
|
|
2
|
+
#define MICROTEX_CLM_H
|
|
3
|
+
|
|
4
|
+
#include "otf/otf.h"
|
|
5
|
+
|
|
6
|
+
namespace microtex {
|
|
7
|
+
|
|
8
|
+
class BinaryReader;
|
|
9
|
+
|
|
10
|
+
/** Read an Otf from `.clm` file. A class wrapper to read/write private fields of glyph. */
|
|
11
|
+
class CLMReader final {
|
|
12
|
+
private:
|
|
13
|
+
static void readMeta(Otf& font, BinaryReader& reader);
|
|
14
|
+
|
|
15
|
+
static void readClassKernings(Otf& font, BinaryReader& reader);
|
|
16
|
+
|
|
17
|
+
static ClassKerning* readClassKerning(BinaryReader& reader);
|
|
18
|
+
|
|
19
|
+
static std::pair<u16, u16*> readClassKerningGlyphs(BinaryReader& reader);
|
|
20
|
+
|
|
21
|
+
static LigaTable* readLigatures(BinaryReader& reader);
|
|
22
|
+
|
|
23
|
+
static MathConsts* readMathConsts(BinaryReader& reader);
|
|
24
|
+
|
|
25
|
+
static KernRecord* readKerns(BinaryReader& reader);
|
|
26
|
+
|
|
27
|
+
static Variants* readVariants(BinaryReader& reader);
|
|
28
|
+
|
|
29
|
+
static GlyphAssembly* readGlyphAssembly(BinaryReader& reader);
|
|
30
|
+
|
|
31
|
+
static Math* readMath(BinaryReader& reader);
|
|
32
|
+
|
|
33
|
+
#ifdef HAVE_GLYPH_RENDER_PATH
|
|
34
|
+
|
|
35
|
+
static Path* readPath(BinaryReader& reader);
|
|
36
|
+
|
|
37
|
+
#else
|
|
38
|
+
|
|
39
|
+
static void skipGlyphPath(BinaryReader& reader);
|
|
40
|
+
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
static Glyph* readGlyph(bool isMathFont, bool hasGlyphPath, BinaryReader& reader);
|
|
44
|
+
|
|
45
|
+
static void readGlyphs(Otf& font, bool hasGlyphPath, BinaryReader& reader);
|
|
46
|
+
|
|
47
|
+
static Otf* read(BinaryReader& reader);
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
no_copy_assign(CLMReader);
|
|
51
|
+
|
|
52
|
+
CLMReader() = default;
|
|
53
|
+
|
|
54
|
+
Otf* read(const char* clmFilePath) const;
|
|
55
|
+
|
|
56
|
+
Otf* read(size_t len, const u8* bytes) const;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
} // namespace microtex
|
|
60
|
+
|
|
61
|
+
#endif
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
#include "fontsense.h"
|
|
2
|
+
|
|
3
|
+
#ifdef HAVE_AUTO_FONT_FIND
|
|
4
|
+
|
|
5
|
+
#include <cstdlib>
|
|
6
|
+
#include <cstring>
|
|
7
|
+
#include <queue>
|
|
8
|
+
#include <sstream>
|
|
9
|
+
|
|
10
|
+
#include "microtex.h"
|
|
11
|
+
#include "unimath/uni_font.h"
|
|
12
|
+
|
|
13
|
+
#ifdef USE_BOOST_FILESYSTEM
|
|
14
|
+
#include <boost/filesystem.hpp>
|
|
15
|
+
namespace fs = boost::filesystem;
|
|
16
|
+
#elif USE_EXPERIMENTAL_FILESYSTEM
|
|
17
|
+
#include <experimental/filesystem>
|
|
18
|
+
namespace fs = std::experimental::filesystem;
|
|
19
|
+
#else
|
|
20
|
+
#include <filesystem>
|
|
21
|
+
namespace fs = std::filesystem;
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
#define FONTDIR "microtex"
|
|
25
|
+
|
|
26
|
+
namespace microtex {
|
|
27
|
+
|
|
28
|
+
class FontSrcSense : public FontSrc {
|
|
29
|
+
public:
|
|
30
|
+
Otf* otf;
|
|
31
|
+
|
|
32
|
+
explicit FontSrcSense(Otf* otf, std::string fontFile = "")
|
|
33
|
+
: FontSrc(std::move(fontFile)), otf(otf) {}
|
|
34
|
+
|
|
35
|
+
sptr<Otf> loadOtf() const override { return sptr<Otf>(otf); }
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Map<FileStem, <OTF File, CLM File>>
|
|
39
|
+
typedef std::map<std::string, std::pair<char*, char*>> font_paths_t;
|
|
40
|
+
|
|
41
|
+
font_paths_t getFontPaths();
|
|
42
|
+
|
|
43
|
+
std::string clmExt() {
|
|
44
|
+
#ifdef HAVE_GLYPH_RENDER_PATH
|
|
45
|
+
return ".clm2";
|
|
46
|
+
#else
|
|
47
|
+
return ".clm1";
|
|
48
|
+
#endif
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void fontPathsFree(const font_paths_t& font_paths);
|
|
52
|
+
|
|
53
|
+
#ifdef _WIN32
|
|
54
|
+
#include <windows.h>
|
|
55
|
+
// Get dir of executable
|
|
56
|
+
// For example, the full path is c:\x\y\z\a.exe
|
|
57
|
+
// return c:\x\y\z\
|
|
58
|
+
//
|
|
59
|
+
std::string getDirOfExecutable() {
|
|
60
|
+
char szBuff[MAX_PATH] = {0};
|
|
61
|
+
// WIN API: GetModuleFileNameA
|
|
62
|
+
// retrieves the path of the executable file of the current process
|
|
63
|
+
// see
|
|
64
|
+
// https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamea
|
|
65
|
+
GetModuleFileNameA(nullptr, szBuff, MAX_PATH);
|
|
66
|
+
std::string exePath(szBuff);
|
|
67
|
+
auto pos = exePath.find_last_of('\\');
|
|
68
|
+
// pos + 1 for adding last \ to path
|
|
69
|
+
return exePath.substr(0, pos + 1);
|
|
70
|
+
}
|
|
71
|
+
#endif
|
|
72
|
+
|
|
73
|
+
font_paths_t getFontPaths() {
|
|
74
|
+
std::queue<std::string> paths;
|
|
75
|
+
// checks if MICROTEX_FONTDIR exists. If it does, it pushes it to potential paths.
|
|
76
|
+
char* devdir = getenv("MICROTEX_FONTDIR");
|
|
77
|
+
if (devdir && *devdir) paths.push(std::string(devdir));
|
|
78
|
+
|
|
79
|
+
// checks if XDG_DATA_HOME exists. If it does, it pushes it to potential paths.
|
|
80
|
+
char* userdata = getenv("XDG_DATA_HOME");
|
|
81
|
+
if (userdata && *userdata) paths.push(std::string(userdata) + "/" + FONTDIR);
|
|
82
|
+
|
|
83
|
+
// checks if XDG_DATA_DIRS is set. If it is, it splits XDG_DATA_DIRS at : and
|
|
84
|
+
// pushes each part of it to potential paths.
|
|
85
|
+
char* data_dirs = getenv("XDG_DATA_DIRS");
|
|
86
|
+
if (data_dirs && *data_dirs) {
|
|
87
|
+
std::stringstream data_dir_paths(data_dirs);
|
|
88
|
+
std::string data_dir_path;
|
|
89
|
+
while (getline(data_dir_paths, data_dir_path, ':')) paths.push(data_dir_path + "/" + FONTDIR);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
#ifndef _WIN32
|
|
93
|
+
char* home = getenv("HOME");
|
|
94
|
+
if (home != nullptr && *home != '\0') {
|
|
95
|
+
char* userdata_fallback;
|
|
96
|
+
auto n = asprintf(&userdata_fallback, "%s/.local/share/%s/", home, FONTDIR);
|
|
97
|
+
if (n > 0) {
|
|
98
|
+
paths.push(std::string(userdata_fallback));
|
|
99
|
+
free(userdata_fallback);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
paths.push("/usr/local/share/" FONTDIR);
|
|
104
|
+
paths.push("/usr/share/" FONTDIR);
|
|
105
|
+
#else
|
|
106
|
+
auto exeDir = getDirOfExecutable();
|
|
107
|
+
paths.push(exeDir + std::string("share/" FONTDIR));
|
|
108
|
+
#endif
|
|
109
|
+
|
|
110
|
+
font_paths_t font_paths;
|
|
111
|
+
|
|
112
|
+
/*
|
|
113
|
+
* Iterate over all found data dirs. For each dir iterate over
|
|
114
|
+
* all files in it. For each font there should be a stem.otf and
|
|
115
|
+
* stem.clm file available. This function checks if the filestem
|
|
116
|
+
* is already in the font map and if it is, looks at the current
|
|
117
|
+
* file extension and sets the current path to it it if is unset.
|
|
118
|
+
* If the stem is not currently in the map it adds it together
|
|
119
|
+
* with the current file as clm or otf.
|
|
120
|
+
*/
|
|
121
|
+
while (!paths.empty()) {
|
|
122
|
+
fs::path p = paths.front();
|
|
123
|
+
if (fs::exists(p))
|
|
124
|
+
for (const auto& entry : fs::directory_iterator(p)) {
|
|
125
|
+
const fs::path& path = entry.path();
|
|
126
|
+
std::string stem = path.stem().string();
|
|
127
|
+
std::string ext = path.extension().string();
|
|
128
|
+
auto it = font_paths.find(stem);
|
|
129
|
+
if (it != font_paths.end()) {
|
|
130
|
+
if (ext == ".otf" && !it->second.first) {
|
|
131
|
+
it->second.first = strdup(path.string().c_str());
|
|
132
|
+
}
|
|
133
|
+
if (ext == clmExt() && !it->second.second) {
|
|
134
|
+
it->second.second = strdup(path.string().c_str());
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
font_paths.emplace(
|
|
138
|
+
stem,
|
|
139
|
+
std::pair(
|
|
140
|
+
ext == ".otf" ? strdup(path.string().c_str()) : nullptr,
|
|
141
|
+
ext == clmExt() ? strdup(path.string().c_str()) : nullptr
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
paths.pop();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
* Iterate over all font paths in map and remove all of them
|
|
151
|
+
* where either the oth or clm path is NULL.
|
|
152
|
+
*/
|
|
153
|
+
for (auto it = font_paths.begin(); it != font_paths.end();) {
|
|
154
|
+
if (!it->second.first || !it->second.second) {
|
|
155
|
+
font_paths.erase(it++);
|
|
156
|
+
} else {
|
|
157
|
+
it++;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return font_paths;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
void fontPathsFree(const font_paths_t& font_paths) {
|
|
165
|
+
for (auto [_stem, files] : font_paths) {
|
|
166
|
+
free(files.first);
|
|
167
|
+
free(files.second);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
std::optional<FontMeta> fontsenseLookup() {
|
|
172
|
+
std::optional<FontMeta> mathfont;
|
|
173
|
+
|
|
174
|
+
font_paths_t font_paths = getFontPaths();
|
|
175
|
+
|
|
176
|
+
for (const auto& [_stem, files] : font_paths) {
|
|
177
|
+
Otf* font = Otf::fromFile(files.second);
|
|
178
|
+
auto meta = MicroTeX::addFont(FontSrcSense(font, files.first));
|
|
179
|
+
if (font->isMathFont()) {
|
|
180
|
+
if (!mathfont) mathfont = meta;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
fontPathsFree(font_paths);
|
|
185
|
+
|
|
186
|
+
return mathfont;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
} // namespace microtex
|
|
190
|
+
|
|
191
|
+
#endif // HAVE_AUTO_FONT_FIND
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include "microtexconfig.h"
|
|
2
|
+
|
|
3
|
+
#ifdef HAVE_AUTO_FONT_FIND
|
|
4
|
+
#ifndef MICROTEX_FONTSENSE_H
|
|
5
|
+
#define MICROTEX_FONTSENSE_H
|
|
6
|
+
|
|
7
|
+
#include <optional>
|
|
8
|
+
#include <string>
|
|
9
|
+
|
|
10
|
+
#include "unimath/font_meta.h"
|
|
11
|
+
|
|
12
|
+
namespace microtex {
|
|
13
|
+
|
|
14
|
+
/** Find font resources auto. Return the first found math font name. */
|
|
15
|
+
std::optional<FontMeta> fontsenseLookup();
|
|
16
|
+
|
|
17
|
+
} // namespace microtex
|
|
18
|
+
|
|
19
|
+
#endif // MICROTEX_FONTSENSE_H
|
|
20
|
+
#endif // HAVE_AUTO_FONT_FIND
|