@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,807 @@
|
|
|
1
|
+
#!/usr/bin/python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
# Parse open-type font file and convert to `clm` format file
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
from functools import reduce, partial
|
|
8
|
+
import fontforge
|
|
9
|
+
import xml.dom.minidom as dom
|
|
10
|
+
import tempfile
|
|
11
|
+
import struct
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def chain(*fs):
|
|
15
|
+
def _chain(f, g):
|
|
16
|
+
return lambda x: g(f(x))
|
|
17
|
+
|
|
18
|
+
return reduce(_chain, fs, lambda x: x)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def fmap(f, it):
|
|
22
|
+
return [j for i in it for j in f(i)]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def do(f, x):
|
|
26
|
+
f(x)
|
|
27
|
+
return x
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def do_loop(f, xs):
|
|
31
|
+
for x in xs:
|
|
32
|
+
f(x)
|
|
33
|
+
return xs
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def find_first(xs, predicate):
|
|
37
|
+
for x in xs:
|
|
38
|
+
if predicate(x):
|
|
39
|
+
return x
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def read_math_consts(font):
|
|
44
|
+
m = font.math
|
|
45
|
+
return [
|
|
46
|
+
m.ScriptPercentScaleDown,
|
|
47
|
+
m.ScriptScriptPercentScaleDown,
|
|
48
|
+
m.DelimitedSubFormulaMinHeight,
|
|
49
|
+
m.DisplayOperatorMinHeight,
|
|
50
|
+
m.MathLeading,
|
|
51
|
+
m.AxisHeight,
|
|
52
|
+
m.AccentBaseHeight,
|
|
53
|
+
m.FlattenedAccentBaseHeight,
|
|
54
|
+
m.SubscriptShiftDown,
|
|
55
|
+
m.SubscriptTopMax,
|
|
56
|
+
m.SubscriptBaselineDropMin,
|
|
57
|
+
m.SuperscriptShiftUp,
|
|
58
|
+
m.SuperscriptShiftUpCramped,
|
|
59
|
+
m.SuperscriptBottomMin,
|
|
60
|
+
m.SuperscriptBaselineDropMax,
|
|
61
|
+
m.SubSuperscriptGapMin,
|
|
62
|
+
m.SuperscriptBottomMaxWithSubscript,
|
|
63
|
+
m.SpaceAfterScript,
|
|
64
|
+
m.UpperLimitGapMin,
|
|
65
|
+
m.UpperLimitBaselineRiseMin,
|
|
66
|
+
m.LowerLimitGapMin,
|
|
67
|
+
m.LowerLimitBaselineDropMin,
|
|
68
|
+
m.StackTopShiftUp,
|
|
69
|
+
m.StackTopDisplayStyleShiftUp,
|
|
70
|
+
m.StackBottomShiftDown,
|
|
71
|
+
m.StackBottomDisplayStyleShiftDown,
|
|
72
|
+
m.StackGapMin,
|
|
73
|
+
m.StackDisplayStyleGapMin,
|
|
74
|
+
m.StretchStackTopShiftUp,
|
|
75
|
+
m.StretchStackBottomShiftDown,
|
|
76
|
+
m.StretchStackGapAboveMin,
|
|
77
|
+
m.StretchStackGapBelowMin,
|
|
78
|
+
m.FractionNumeratorShiftUp,
|
|
79
|
+
m.FractionNumeratorDisplayStyleShiftUp,
|
|
80
|
+
m.FractionDenominatorShiftDown,
|
|
81
|
+
m.FractionDenominatorDisplayStyleShiftDown,
|
|
82
|
+
m.FractionNumeratorGapMin,
|
|
83
|
+
m.FractionNumeratorDisplayStyleGapMin,
|
|
84
|
+
m.FractionRuleThickness,
|
|
85
|
+
m.FractionDenominatorGapMin,
|
|
86
|
+
m.FractionDenominatorDisplayStyleGapMin,
|
|
87
|
+
m.SkewedFractionHorizontalGap,
|
|
88
|
+
m.SkewedFractionVerticalGap,
|
|
89
|
+
m.OverbarVerticalGap,
|
|
90
|
+
m.OverbarRuleThickness,
|
|
91
|
+
m.OverbarExtraAscender,
|
|
92
|
+
m.UnderbarVerticalGap,
|
|
93
|
+
m.UnderbarRuleThickness,
|
|
94
|
+
m.UnderbarExtraDescender,
|
|
95
|
+
m.RadicalVerticalGap,
|
|
96
|
+
m.RadicalDisplayStyleVerticalGap,
|
|
97
|
+
m.RadicalRuleThickness,
|
|
98
|
+
m.RadicalExtraAscender,
|
|
99
|
+
m.RadicalKernBeforeDegree,
|
|
100
|
+
m.RadicalKernAfterDegree,
|
|
101
|
+
m.RadicalDegreeBottomRaisePercent,
|
|
102
|
+
m.MinConnectorOverlap
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def read_metrics(glyph):
|
|
107
|
+
'''
|
|
108
|
+
Return a tuple to represents metrics, in (width, height, depth) order
|
|
109
|
+
'''
|
|
110
|
+
# [xmin, ymin, xmax, ymax]
|
|
111
|
+
# 0 is the baseline
|
|
112
|
+
bounding_box = glyph.boundingBox()
|
|
113
|
+
return (
|
|
114
|
+
# width
|
|
115
|
+
glyph.width,
|
|
116
|
+
# height = max(0, ymax)
|
|
117
|
+
max(0, bounding_box[3]),
|
|
118
|
+
# depth = -min(0, ymin)
|
|
119
|
+
-min(0, bounding_box[1])
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def read_variants(get_variants):
|
|
124
|
+
'''
|
|
125
|
+
Return an array of glyph names to represents variants
|
|
126
|
+
'''
|
|
127
|
+
variants = get_variants()
|
|
128
|
+
if not variants:
|
|
129
|
+
return []
|
|
130
|
+
return variants.split(' ')
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def read_scripts(glyph, subtable_names):
|
|
134
|
+
'''
|
|
135
|
+
Return an array of glyph names to represents scripts variants
|
|
136
|
+
'''
|
|
137
|
+
scripts = chain(
|
|
138
|
+
partial(fmap, lambda subtable_name: glyph.getPosSub(subtable_name)),
|
|
139
|
+
partial(fmap, lambda infos: infos[2:])
|
|
140
|
+
)(subtable_names)
|
|
141
|
+
return list(scripts)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def read_glyph_assembly(get_assembly):
|
|
145
|
+
'''
|
|
146
|
+
Return a tuple
|
|
147
|
+
(
|
|
148
|
+
italics_correction,
|
|
149
|
+
(
|
|
150
|
+
(glyph_name, flag, start_connector_length, end_connector_length, full_advance),
|
|
151
|
+
...
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
'''
|
|
155
|
+
return get_assembly()
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def read_math_kern_record(glyph):
|
|
159
|
+
'''
|
|
160
|
+
Return a tuple contains 4 elements in clockwise direction, None means not represent
|
|
161
|
+
(
|
|
162
|
+
((correction_height, kerning), ...),
|
|
163
|
+
None,
|
|
164
|
+
...
|
|
165
|
+
)
|
|
166
|
+
'''
|
|
167
|
+
return (
|
|
168
|
+
glyph.mathKern.topLeft,
|
|
169
|
+
glyph.mathKern.topRight,
|
|
170
|
+
glyph.mathKern.bottomLeft,
|
|
171
|
+
glyph.mathKern.bottomRight,
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def read_math(glyph, scripts_subtable_names):
|
|
176
|
+
return (
|
|
177
|
+
glyph.italicCorrection,
|
|
178
|
+
# if no top accent attachment, the value == 32767 (undefined math value)
|
|
179
|
+
glyph.topaccent,
|
|
180
|
+
read_variants(lambda: glyph.horizontalVariants),
|
|
181
|
+
read_variants(lambda: glyph.verticalVariants),
|
|
182
|
+
read_scripts(glyph, scripts_subtable_names),
|
|
183
|
+
read_glyph_assembly(lambda: (
|
|
184
|
+
glyph.horizontalComponentItalicCorrection,
|
|
185
|
+
glyph.horizontalComponents,
|
|
186
|
+
)),
|
|
187
|
+
read_glyph_assembly(lambda: (
|
|
188
|
+
glyph.verticalComponentItalicCorrection,
|
|
189
|
+
glyph.verticalComponents,
|
|
190
|
+
)),
|
|
191
|
+
read_math_kern_record(glyph),
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def read_kern(glyph, kern_subtable_names):
|
|
196
|
+
'''
|
|
197
|
+
Return array of tuples represents kerning
|
|
198
|
+
[
|
|
199
|
+
(glyph_name, kerning),
|
|
200
|
+
...
|
|
201
|
+
]
|
|
202
|
+
'''
|
|
203
|
+
ks = []
|
|
204
|
+
for sn in kern_subtable_names:
|
|
205
|
+
kerns = glyph.getPosSub(sn)
|
|
206
|
+
for k in kerns:
|
|
207
|
+
if k[5] != 0:
|
|
208
|
+
ks.append((k[2], k[5],))
|
|
209
|
+
return ks
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def path_cmd_arg_cnt(x):
|
|
213
|
+
if x == 'M' or x == 'm' or x == 'L' or x == 'l' or x == 'T' or x == 't':
|
|
214
|
+
return 2
|
|
215
|
+
if x == 'H' or x == 'h' or x == 'V' or x == 'v':
|
|
216
|
+
return 1
|
|
217
|
+
if x == 'C' or x == 'c':
|
|
218
|
+
return 6
|
|
219
|
+
if x == 'S' or x == 's' or x == 'Q' or x == 'q':
|
|
220
|
+
return 4
|
|
221
|
+
if x == 'Z' or x == 'z':
|
|
222
|
+
return -1
|
|
223
|
+
return 0
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def is_valid_digit(c):
|
|
227
|
+
return c == '.' or c == '-' or c.isdigit()
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def mirror_cmd(t):
|
|
231
|
+
x = t[0]
|
|
232
|
+
if x == 'M' or x == 'm' or x == 'L' or x == 'l' or x == 'T' or x == 't':
|
|
233
|
+
t[2] = -t[2]
|
|
234
|
+
elif x == 'V' or x == 'v':
|
|
235
|
+
t[1] = -t[1]
|
|
236
|
+
elif x == 'C' or x == 'c':
|
|
237
|
+
t[2] = -t[2]
|
|
238
|
+
t[4] = -t[4]
|
|
239
|
+
t[6] = -t[6]
|
|
240
|
+
elif x == 'S' or x == 's' or x == 'Q' or x == 'q':
|
|
241
|
+
t[2] = -t[2]
|
|
242
|
+
t[4] = -t[4]
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def mirror(data):
|
|
246
|
+
for t in data:
|
|
247
|
+
mirror_cmd(t)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def read_glyph_path(glyph):
|
|
251
|
+
tf = tempfile.NamedTemporaryFile(suffix='.svg', mode='w+')
|
|
252
|
+
# keep font coordinate-system, thus increase y from bottom to up
|
|
253
|
+
glyph.export(tf.name, usetransform=True)
|
|
254
|
+
string = tf.read()
|
|
255
|
+
tf.close()
|
|
256
|
+
|
|
257
|
+
svg = dom.parseString(string).documentElement
|
|
258
|
+
g = svg.getElementsByTagName('g')
|
|
259
|
+
paths = g[0].getElementsByTagName('path')
|
|
260
|
+
|
|
261
|
+
path = None
|
|
262
|
+
if paths:
|
|
263
|
+
path = paths[0]
|
|
264
|
+
if not path:
|
|
265
|
+
return []
|
|
266
|
+
|
|
267
|
+
v = path.attributes.get('d').value
|
|
268
|
+
data = []
|
|
269
|
+
|
|
270
|
+
def digits(i):
|
|
271
|
+
j = i
|
|
272
|
+
while is_valid_digit(v[j]):
|
|
273
|
+
j += 1
|
|
274
|
+
return (v[i:j], j,)
|
|
275
|
+
|
|
276
|
+
i = 0
|
|
277
|
+
while i < len(v):
|
|
278
|
+
x = v[i]
|
|
279
|
+
cnt = path_cmd_arg_cnt(x)
|
|
280
|
+
if not cnt:
|
|
281
|
+
i += 1
|
|
282
|
+
continue
|
|
283
|
+
i += 1
|
|
284
|
+
cmd = [x]
|
|
285
|
+
for j in range(0, cnt):
|
|
286
|
+
while not is_valid_digit(v[i]):
|
|
287
|
+
i += 1
|
|
288
|
+
r = digits(i)
|
|
289
|
+
cmd.append(int(r[0]))
|
|
290
|
+
i = r[1]
|
|
291
|
+
data.append(cmd)
|
|
292
|
+
|
|
293
|
+
mirror(data)
|
|
294
|
+
return data
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def read_glyph(glyph, is_math_font, parse_path, kern_subtable_names, scripts_subtable_names):
|
|
298
|
+
'''
|
|
299
|
+
Return a tuple
|
|
300
|
+
(
|
|
301
|
+
metrics,
|
|
302
|
+
kerning,
|
|
303
|
+
math,
|
|
304
|
+
path_cmds,
|
|
305
|
+
glyph_name
|
|
306
|
+
)
|
|
307
|
+
'''
|
|
308
|
+
return (
|
|
309
|
+
read_metrics(glyph),
|
|
310
|
+
read_kern(glyph, kern_subtable_names),
|
|
311
|
+
None if not is_math_font else read_math(glyph, scripts_subtable_names),
|
|
312
|
+
None if not parse_path else read_glyph_path(glyph),
|
|
313
|
+
glyph.glyphname,
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def _read_lookup_subtables(
|
|
318
|
+
font, is_target_lookup=lambda x: True, is_target_subtable=lambda x: True):
|
|
319
|
+
'''
|
|
320
|
+
Return a function to get the subtable names
|
|
321
|
+
'''
|
|
322
|
+
|
|
323
|
+
def _is_target_lookup(lookup_name):
|
|
324
|
+
lookup_info = font.getLookupInfo(lookup_name)
|
|
325
|
+
return lookup_info and is_target_lookup(lookup_info)
|
|
326
|
+
|
|
327
|
+
return chain(
|
|
328
|
+
partial(filter, _is_target_lookup),
|
|
329
|
+
partial(fmap, lambda lookup_name: font.getLookupSubtables(lookup_name)),
|
|
330
|
+
partial(filter, is_target_subtable)
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def read_scripts_subtables(font):
|
|
335
|
+
'''
|
|
336
|
+
Return array of scripts variants subtable name
|
|
337
|
+
The feature tag is 'ssty'
|
|
338
|
+
'''
|
|
339
|
+
subtables = _read_lookup_subtables(
|
|
340
|
+
font,
|
|
341
|
+
lambda info: info[0] == 'gsub_alternate' and any(
|
|
342
|
+
t[0] == 'ssty' for t in info[2])
|
|
343
|
+
)(font.gsub_lookups)
|
|
344
|
+
return list(subtables)
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
def read_kern_subtables(font):
|
|
348
|
+
'''
|
|
349
|
+
Return array of kerning subtable name
|
|
350
|
+
'''
|
|
351
|
+
tables = []
|
|
352
|
+
lookups = font.gpos_lookups
|
|
353
|
+
for lookup_name in lookups:
|
|
354
|
+
lookup_info = font.getLookupInfo(lookup_name)
|
|
355
|
+
if lookup_info and lookup_info[0] == 'gpos_pair':
|
|
356
|
+
subtable_names = font.getLookupSubtables(lookup_name)
|
|
357
|
+
for sn in subtable_names:
|
|
358
|
+
if not font.isKerningClass(sn):
|
|
359
|
+
tables.append(sn)
|
|
360
|
+
return tables
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def read_ligature_subtables(font):
|
|
364
|
+
'''
|
|
365
|
+
Return array of ligture subtable name
|
|
366
|
+
'''
|
|
367
|
+
tables = []
|
|
368
|
+
lookups = font.gsub_lookups
|
|
369
|
+
for lookup_name in lookups:
|
|
370
|
+
lookup_info = font.getLookupInfo(lookup_name)
|
|
371
|
+
if lookup_info and lookup_info[0] == 'gsub_ligature':
|
|
372
|
+
subtable_names = font.getLookupSubtables(lookup_name)
|
|
373
|
+
for sn in subtable_names:
|
|
374
|
+
tables.append(sn)
|
|
375
|
+
return tables
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def read_ligatures(glyph, liga_subtable_names):
|
|
379
|
+
'''
|
|
380
|
+
Return array of ligatures info represents by this glyph,
|
|
381
|
+
the glyph id is the ligature
|
|
382
|
+
[
|
|
383
|
+
((glyph_name, glyph_name, ...), glyph_id),
|
|
384
|
+
...
|
|
385
|
+
]
|
|
386
|
+
'''
|
|
387
|
+
ligs = []
|
|
388
|
+
for sn in liga_subtable_names:
|
|
389
|
+
liga_infos = glyph.getPosSub(sn)
|
|
390
|
+
for info in liga_infos:
|
|
391
|
+
ligs.append((info[2:], glyph.originalgid,))
|
|
392
|
+
return ligs
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def read_kerning_class(font):
|
|
396
|
+
'''
|
|
397
|
+
Return array of kerning class table:
|
|
398
|
+
(
|
|
399
|
+
# glyphs on left
|
|
400
|
+
(
|
|
401
|
+
None, # first is None
|
|
402
|
+
(glyph_name, glyph_name, ...),
|
|
403
|
+
...
|
|
404
|
+
),
|
|
405
|
+
# glyphs on right
|
|
406
|
+
(
|
|
407
|
+
None, # first is None
|
|
408
|
+
(glyph_name, glyph_name, ...),
|
|
409
|
+
...
|
|
410
|
+
),
|
|
411
|
+
# kerning value
|
|
412
|
+
(
|
|
413
|
+
kerning_value,
|
|
414
|
+
...
|
|
415
|
+
)
|
|
416
|
+
)
|
|
417
|
+
'''
|
|
418
|
+
kerns = []
|
|
419
|
+
lookups = font.gpos_lookups
|
|
420
|
+
for ln in lookups:
|
|
421
|
+
li = font.getLookupInfo(ln)
|
|
422
|
+
if li and li[0] == 'gpos_pair':
|
|
423
|
+
subtables = font.getLookupSubtables(ln)
|
|
424
|
+
for sn in subtables:
|
|
425
|
+
if font.isKerningClass(sn):
|
|
426
|
+
kerns.append(font.getKerningClass(sn))
|
|
427
|
+
return kerns
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
def write_clm_unicode_glyph_map(f, unicode_glyph_map):
|
|
431
|
+
length = len(unicode_glyph_map)
|
|
432
|
+
f.write(struct.pack('!H', length))
|
|
433
|
+
sort_map = sorted(unicode_glyph_map, key=lambda x: x[0])
|
|
434
|
+
for (codepoint, glyph_id,) in sort_map:
|
|
435
|
+
f.write(struct.pack('!IH', codepoint, glyph_id))
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
def write_clm_kerning_class(f, kerning_classes, glyph_name_id_map):
|
|
439
|
+
length = len(list(kerning_classes))
|
|
440
|
+
f.write(struct.pack('!H', length))
|
|
441
|
+
|
|
442
|
+
def write_group(g):
|
|
443
|
+
"""
|
|
444
|
+
row format:
|
|
445
|
+
(index, (glyph_name, glyph_name, ...))
|
|
446
|
+
convert to:
|
|
447
|
+
[{index, glyph_id}, ...]
|
|
448
|
+
"""
|
|
449
|
+
# write the group length
|
|
450
|
+
f.write(struct.pack('!H', len(g)))
|
|
451
|
+
m = []
|
|
452
|
+
for (index, glyph_names,) in g:
|
|
453
|
+
for name in glyph_names:
|
|
454
|
+
m.append({'index': index, 'glyph_id': glyph_name_id_map[name]})
|
|
455
|
+
# sort the array by glyph id
|
|
456
|
+
m = sorted(m, key=lambda item: item['glyph_id'])
|
|
457
|
+
# write the count of the glyphs
|
|
458
|
+
f.write(struct.pack('!H', len(m)))
|
|
459
|
+
# write glyph id and its index in this group
|
|
460
|
+
for item in m:
|
|
461
|
+
f.write(struct.pack('!HH', item['glyph_id'], item['index']))
|
|
462
|
+
|
|
463
|
+
for (left, right, value,) in kerning_classes:
|
|
464
|
+
write_group(list(enumerate(left[1:])))
|
|
465
|
+
write_group(list(enumerate(right[1:])))
|
|
466
|
+
column_count = len(right)
|
|
467
|
+
for i, v in enumerate(value):
|
|
468
|
+
if i < column_count or i % column_count == 0:
|
|
469
|
+
continue
|
|
470
|
+
f.write(struct.pack('!h', v))
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
def write_ligas(f, ligas, glyph_name_id_map):
|
|
474
|
+
forest = []
|
|
475
|
+
|
|
476
|
+
def add_node(glyphs, liga):
|
|
477
|
+
children = forest
|
|
478
|
+
child = None
|
|
479
|
+
for (glyph, char,) in glyphs:
|
|
480
|
+
child = find_first(children, lambda x: x['glyph'] == glyph)
|
|
481
|
+
if not child:
|
|
482
|
+
child = {'glyph': glyph, 'char': char,
|
|
483
|
+
'liga': -1, 'children': []}
|
|
484
|
+
children.append(child)
|
|
485
|
+
children = child['children']
|
|
486
|
+
child['liga'] = liga
|
|
487
|
+
|
|
488
|
+
for (chars, liga,) in ligas:
|
|
489
|
+
add_node(
|
|
490
|
+
map(lambda char: (glyph_name_id_map[char], char,), chars), liga)
|
|
491
|
+
|
|
492
|
+
def sort_children(children):
|
|
493
|
+
for child in children:
|
|
494
|
+
child['children'] = sort_children(child['children'])
|
|
495
|
+
return sorted(children, key=lambda x: x['glyph'])
|
|
496
|
+
|
|
497
|
+
forest = sort_children(forest)
|
|
498
|
+
|
|
499
|
+
def write_node(node):
|
|
500
|
+
f.write(struct.pack('!H', node['glyph']))
|
|
501
|
+
f.write(struct.pack('!i', node['liga']))
|
|
502
|
+
f.write(struct.pack('!H', len(node['children'])))
|
|
503
|
+
for child in node['children']:
|
|
504
|
+
write_node(child)
|
|
505
|
+
|
|
506
|
+
root = {'glyph': 0, 'char': 0, 'liga': -1, 'children': forest}
|
|
507
|
+
write_node(root)
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
def write_math_consts(f, consts):
|
|
511
|
+
for v in consts:
|
|
512
|
+
f.write(struct.pack('!h', v))
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
def write_glyphs(f, glyphs, glyph_name_id_map, is_math_font, have_glyph_path):
|
|
516
|
+
f.write(struct.pack('!H', len(glyphs)))
|
|
517
|
+
|
|
518
|
+
def write_metrics(metrics):
|
|
519
|
+
for v in metrics:
|
|
520
|
+
f.write(struct.pack('!h', int(v)))
|
|
521
|
+
|
|
522
|
+
def write_kerns(g, kerns):
|
|
523
|
+
if not kerns:
|
|
524
|
+
f.write(struct.pack('!H', 0))
|
|
525
|
+
return
|
|
526
|
+
f.write(struct.pack('!H', len(list(kerns))))
|
|
527
|
+
sorted_kerns = chain(
|
|
528
|
+
partial(map, lambda x: (glyph_name_id_map[x[0]], x[1],)),
|
|
529
|
+
partial(sorted, key=lambda x: x[0])
|
|
530
|
+
)(kerns)
|
|
531
|
+
for (glyph, value,) in sorted_kerns:
|
|
532
|
+
f.write(struct.pack('!Hh', glyph, value))
|
|
533
|
+
|
|
534
|
+
def write_variants(variants):
|
|
535
|
+
length = 0 if not variants else len(variants)
|
|
536
|
+
f.write(struct.pack('!H', length))
|
|
537
|
+
if length == 0:
|
|
538
|
+
return
|
|
539
|
+
for v in variants:
|
|
540
|
+
gid = glyph_name_id_map[v]
|
|
541
|
+
f.write(struct.pack('!H', gid))
|
|
542
|
+
|
|
543
|
+
def write_glyph_assembly(assembly):
|
|
544
|
+
if not assembly or not assembly[1]:
|
|
545
|
+
f.write(struct.pack('?', False))
|
|
546
|
+
return
|
|
547
|
+
f.write(struct.pack('?', True))
|
|
548
|
+
f.write(struct.pack('!H', len(assembly[1])))
|
|
549
|
+
f.write(struct.pack('!h', assembly[0])) # italics correction
|
|
550
|
+
for part in assembly[1]:
|
|
551
|
+
f.write(struct.pack('!H', glyph_name_id_map[part[0]]))
|
|
552
|
+
for v in part[1:]:
|
|
553
|
+
f.write(struct.pack('!H', v))
|
|
554
|
+
|
|
555
|
+
def write_math_kern(math_kerns):
|
|
556
|
+
for i in math_kerns:
|
|
557
|
+
if not i:
|
|
558
|
+
f.write(struct.pack('!H', 0))
|
|
559
|
+
continue
|
|
560
|
+
f.write(struct.pack('!H', len(i)))
|
|
561
|
+
for (correction_height, value,) in i:
|
|
562
|
+
f.write(struct.pack('!hh', correction_height, value))
|
|
563
|
+
|
|
564
|
+
def write_math(math):
|
|
565
|
+
f.write(struct.pack('!h', math[0])) # italics correction
|
|
566
|
+
f.write(struct.pack('!h', math[1])) # topaccent attachment
|
|
567
|
+
write_variants(math[2]) # horizontal variants
|
|
568
|
+
write_variants(math[3]) # vertical variants
|
|
569
|
+
write_variants(math[4]) # scripts variants
|
|
570
|
+
write_glyph_assembly(math[5]) # horizontal assembly
|
|
571
|
+
write_glyph_assembly(math[6]) # vertical assembly
|
|
572
|
+
write_math_kern(math[7]) # math kern
|
|
573
|
+
|
|
574
|
+
def write_path(path):
|
|
575
|
+
f.write(struct.pack('!H', len(path)))
|
|
576
|
+
if not path:
|
|
577
|
+
return
|
|
578
|
+
for cmd in path:
|
|
579
|
+
f.write(struct.pack('c', bytes(cmd[0], 'ascii')))
|
|
580
|
+
for param in cmd[1:]:
|
|
581
|
+
f.write(struct.pack('!h', param))
|
|
582
|
+
|
|
583
|
+
for glyph in glyphs:
|
|
584
|
+
write_metrics(glyph[0])
|
|
585
|
+
write_kerns(glyph[4], glyph[1])
|
|
586
|
+
if is_math_font:
|
|
587
|
+
write_math(glyph[2])
|
|
588
|
+
if have_glyph_path:
|
|
589
|
+
write_path(glyph[3])
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
def parse_fontstyle(font, userstyle):
|
|
593
|
+
NONE = 0b00000000
|
|
594
|
+
RM = 0b00000001
|
|
595
|
+
BF = 0b00000010
|
|
596
|
+
IT = 0b00000100
|
|
597
|
+
CAL = 0b00001000
|
|
598
|
+
FRAK = 0b00010000
|
|
599
|
+
BB = 0b00100000
|
|
600
|
+
SF = 0b01000000
|
|
601
|
+
TT = 0b10000000
|
|
602
|
+
|
|
603
|
+
style = NONE
|
|
604
|
+
|
|
605
|
+
if userstyle is None or userstyle == "":
|
|
606
|
+
if font.os2_weight >= 700:
|
|
607
|
+
style |= BF
|
|
608
|
+
|
|
609
|
+
if font.os2_stylemap == 0x40:
|
|
610
|
+
style |= RM
|
|
611
|
+
if font.os2_stylemap == 0x21:
|
|
612
|
+
style |= (BF | IT)
|
|
613
|
+
if font.os2_stylemap == 0x20:
|
|
614
|
+
style |= BF
|
|
615
|
+
if font.os2_stylemap == 0x01:
|
|
616
|
+
style |= IT
|
|
617
|
+
|
|
618
|
+
if font.macstyle != -1:
|
|
619
|
+
if font.macstyle & 0b01 == 0b01:
|
|
620
|
+
style |= BF
|
|
621
|
+
if font.macstyle & 0b10 == 0b10:
|
|
622
|
+
style |= IT
|
|
623
|
+
|
|
624
|
+
if font.fullname.upper().__contains__("MONO"):
|
|
625
|
+
style |= TT
|
|
626
|
+
else:
|
|
627
|
+
userstyles = userstyle.split(",")
|
|
628
|
+
if "rm" in userstyles:
|
|
629
|
+
style |= RM
|
|
630
|
+
if "bf" in userstyles:
|
|
631
|
+
style |= BF
|
|
632
|
+
if "it" in userstyles:
|
|
633
|
+
style |= IT
|
|
634
|
+
if "cal" in userstyles:
|
|
635
|
+
style |= CAL
|
|
636
|
+
if "frak" in userstyles:
|
|
637
|
+
style |= FRAK
|
|
638
|
+
if "bb" in userstyles:
|
|
639
|
+
style |= BB
|
|
640
|
+
if "sf" in userstyles:
|
|
641
|
+
style |= SF
|
|
642
|
+
if "tt" in userstyles:
|
|
643
|
+
style |= TT
|
|
644
|
+
|
|
645
|
+
return style
|
|
646
|
+
|
|
647
|
+
|
|
648
|
+
def parse_otf(file_path, have_glyph_path, output_file_path, userstyle=""):
|
|
649
|
+
print("parsing font " + file_path + ", please wait...")
|
|
650
|
+
font = fontforge.open(file_path)
|
|
651
|
+
|
|
652
|
+
is_math_font = font.math.exists()
|
|
653
|
+
# read math constants
|
|
654
|
+
math_consts = []
|
|
655
|
+
if is_math_font:
|
|
656
|
+
math_consts = read_math_consts(font)
|
|
657
|
+
|
|
658
|
+
# read kern subtables
|
|
659
|
+
kern_subtable_names = read_kern_subtables(font)
|
|
660
|
+
# read ligature subtables
|
|
661
|
+
liga_subtable_names = read_ligature_subtables(font)
|
|
662
|
+
# read kern class tables
|
|
663
|
+
kern_class_tables = read_kerning_class(font)
|
|
664
|
+
# read scripts subtables
|
|
665
|
+
scripts_subtable_names = read_scripts_subtables(font)
|
|
666
|
+
|
|
667
|
+
unicode_glyph_map = []
|
|
668
|
+
glyph_name_id_map = {}
|
|
669
|
+
glyphs = []
|
|
670
|
+
ligas = []
|
|
671
|
+
|
|
672
|
+
# read glyphs in GID order
|
|
673
|
+
for glyph_name in font:
|
|
674
|
+
glyph = font[glyph_name]
|
|
675
|
+
|
|
676
|
+
# unicode-glyph map
|
|
677
|
+
if glyph.unicode != -1:
|
|
678
|
+
unicode_glyph_map.append((glyph.unicode, glyph.originalgid,))
|
|
679
|
+
|
|
680
|
+
glyph_name_id_map[glyph_name] = glyph.originalgid
|
|
681
|
+
# glyph info
|
|
682
|
+
glyphs.append(read_glyph(
|
|
683
|
+
glyph, is_math_font, have_glyph_path,
|
|
684
|
+
kern_subtable_names, scripts_subtable_names
|
|
685
|
+
))
|
|
686
|
+
|
|
687
|
+
# read ligature
|
|
688
|
+
liga_info = read_ligatures(glyph, liga_subtable_names)
|
|
689
|
+
for l in liga_info:
|
|
690
|
+
ligas.append(l)
|
|
691
|
+
|
|
692
|
+
name = font.fullname
|
|
693
|
+
family = font.familyname
|
|
694
|
+
style = parse_fontstyle(font, userstyle)
|
|
695
|
+
em = font.em
|
|
696
|
+
xheight = font.xHeight
|
|
697
|
+
ascent = font.ascent
|
|
698
|
+
descent = font.descent
|
|
699
|
+
|
|
700
|
+
with open(output_file_path, 'wb') as f:
|
|
701
|
+
f.write(struct.pack('c', bytes('c', 'ascii')))
|
|
702
|
+
f.write(struct.pack('c', bytes('l', 'ascii')))
|
|
703
|
+
f.write(struct.pack('c', bytes('m', 'ascii')))
|
|
704
|
+
# current major version 5
|
|
705
|
+
f.write(struct.pack('!H', 5))
|
|
706
|
+
# minor version, if support glyph path
|
|
707
|
+
f.write(struct.pack('B', 2 if have_glyph_path else 1))
|
|
708
|
+
f.write(struct.pack(str(len(name) + 1) + 's', bytes(name, 'utf-8')))
|
|
709
|
+
f.write(struct.pack(str(len(family) + 1) + 's', bytes(family, 'utf-8')))
|
|
710
|
+
f.write(struct.pack('?', is_math_font))
|
|
711
|
+
f.write(struct.pack('!H', style))
|
|
712
|
+
f.write(struct.pack('!H', em))
|
|
713
|
+
f.write(struct.pack('!H', int(xheight)))
|
|
714
|
+
f.write(struct.pack('!H', ascent))
|
|
715
|
+
f.write(struct.pack('!H', descent))
|
|
716
|
+
write_clm_unicode_glyph_map(f, unicode_glyph_map)
|
|
717
|
+
write_clm_kerning_class(f, kern_class_tables, glyph_name_id_map)
|
|
718
|
+
write_ligas(f, ligas, glyph_name_id_map)
|
|
719
|
+
if is_math_font:
|
|
720
|
+
write_math_consts(f, math_consts)
|
|
721
|
+
write_glyphs(f, glyphs, glyph_name_id_map,
|
|
722
|
+
is_math_font, have_glyph_path)
|
|
723
|
+
|
|
724
|
+
font.close()
|
|
725
|
+
|
|
726
|
+
|
|
727
|
+
def batch_parse(input_dir, have_glyph_path, output_dir):
|
|
728
|
+
import os
|
|
729
|
+
fs = os.listdir(input_dir)
|
|
730
|
+
if not os.path.isdir(output_dir):
|
|
731
|
+
os.makedirs(output_dir)
|
|
732
|
+
for f in fs:
|
|
733
|
+
if f.endswith('.otf'):
|
|
734
|
+
name = os.path.basename(f)[0:-4]
|
|
735
|
+
save_name = name + ".clm2" if have_glyph_path else name + ".clm1"
|
|
736
|
+
save_path = os.path.join(output_dir, save_name)
|
|
737
|
+
input_file = os.path.join(input_dir, f)
|
|
738
|
+
parse_otf(input_file, have_glyph_path, save_path)
|
|
739
|
+
print("The generated clm data files were saved into directory: " + output_dir)
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
def single_parse(input_file, have_glyph_path, output_dir, user_style):
|
|
743
|
+
import os
|
|
744
|
+
name = os.path.basename(input_file)[0:-4]
|
|
745
|
+
save_name = name + ".clm2" if have_glyph_path else name + ".clm1"
|
|
746
|
+
save_path = os.path.join(output_dir, save_name)
|
|
747
|
+
parse_otf(input_file, have_glyph_path, save_path, user_style)
|
|
748
|
+
print("The generated clm data file was saved into directory: " + output_dir);
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
usage = """
|
|
752
|
+
Generate clm data from OTF font file.
|
|
753
|
+
|
|
754
|
+
Usage:
|
|
755
|
+
with single mode:
|
|
756
|
+
--single \\
|
|
757
|
+
<path/to/OTF-font> \\
|
|
758
|
+
<if_parse_glyph_path: true | false> \\
|
|
759
|
+
<dir/to/save/clm_file> \\
|
|
760
|
+
<font-style list, split by ','>
|
|
761
|
+
|
|
762
|
+
or with batch mode:
|
|
763
|
+
--batch \\
|
|
764
|
+
<dir/to/OTF-fonts> \\
|
|
765
|
+
<if_parse_glyph_path: true | false> \\
|
|
766
|
+
<dir/to/save/clm_files>
|
|
767
|
+
|
|
768
|
+
The batch mode will not run in recursive, allowed font styles are:
|
|
769
|
+
rm: roman
|
|
770
|
+
bf: bold
|
|
771
|
+
it: italic
|
|
772
|
+
cal: calligraphic
|
|
773
|
+
frak: fraktur
|
|
774
|
+
bb: double struck
|
|
775
|
+
sf: sans-serif
|
|
776
|
+
tt: type-writer
|
|
777
|
+
|
|
778
|
+
If no font styles are given, trying to read it from font, but only
|
|
779
|
+
the following styles will be taken into account:
|
|
780
|
+
rm, bf, it, tt
|
|
781
|
+
"""
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
def main():
|
|
785
|
+
if len(sys.argv) < 4:
|
|
786
|
+
print(usage)
|
|
787
|
+
return
|
|
788
|
+
if sys.argv[1] == '--batch':
|
|
789
|
+
batch_parse(
|
|
790
|
+
sys.argv[2],
|
|
791
|
+
sys.argv[3] == 'true',
|
|
792
|
+
sys.argv[4]
|
|
793
|
+
)
|
|
794
|
+
else:
|
|
795
|
+
userstyle = ""
|
|
796
|
+
if (len(sys.argv) > 5):
|
|
797
|
+
userstyle = sys.argv[5]
|
|
798
|
+
single_parse(
|
|
799
|
+
sys.argv[2],
|
|
800
|
+
sys.argv[3] == 'true',
|
|
801
|
+
sys.argv[4],
|
|
802
|
+
userstyle
|
|
803
|
+
)
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
if __name__ == "__main__":
|
|
807
|
+
main()
|