libstb 0.6.0__tar.gz → 0.8.0__tar.gz

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.
Files changed (241) hide show
  1. {libstb-0.6.0 → libstb-0.8.0}/.github/workflows/cmake.yml +9 -9
  2. {libstb-0.6.0 → libstb-0.8.0}/CHANGELOG.md +110 -2
  3. {libstb-0.6.0 → libstb-0.8.0}/CMakeLists.txt +22 -13
  4. libstb-0.8.0/PKG-INFO +176 -0
  5. libstb-0.8.0/README.md +144 -0
  6. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/CMakeLists.txt +4 -4
  7. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/README.md +21 -21
  8. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/outputs/benchmark.json +1 -1
  9. libstb-0.8.0/benchmarks/outputs/index.html +1501 -0
  10. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/outputs/results/sizes.json +1 -1
  11. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/CMakeLists.txt +16 -16
  12. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/bench_sizes.py +1 -1
  13. libstb-0.8.0/benchmarks/report/CMakeLists.txt +36 -0
  14. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/report/generate_report.py +34 -93
  15. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/report/template.html.jinja2 +114 -307
  16. libstb-0.8.0/checklist.md +139 -0
  17. {libstb-0.6.0 → libstb-0.8.0}/cmake/coverage_iframe.html.in +1 -1
  18. {libstb-0.6.0 → libstb-0.8.0}/docs/CMakeLists.txt +16 -10
  19. {libstb-0.6.0 → libstb-0.8.0}/docs/CreateDocs.cmake +8 -3
  20. {libstb-0.6.0 → libstb-0.8.0}/docs/assets/libstb-docs.css +130 -78
  21. {libstb-0.6.0 → libstb-0.8.0}/docs/cpp/CreateDocs.cmake +1 -1
  22. {libstb-0.6.0 → libstb-0.8.0}/docs/cpp/Doxyfile.in +1 -1
  23. {libstb-0.6.0 → libstb-0.8.0}/docs/cpp/footer.html.in +1 -1
  24. {libstb-0.6.0 → libstb-0.8.0}/docs/cpp/index-docs.json +1 -1
  25. {libstb-0.6.0 → libstb-0.8.0}/docs/cpp/index-install.txt +1 -1
  26. {libstb-0.6.0 → libstb-0.8.0}/docs/cpp/libstb-doxygen.css +7 -7
  27. {libstb-0.6.0 → libstb-0.8.0}/docs/cpp/mainpage.md +17 -3
  28. {libstb-0.6.0 → libstb-0.8.0}/docs/generate_index.py +37 -30
  29. libstb-0.6.0/PKG-INFO → libstb-0.8.0/docs/guide.md +57 -54
  30. {libstb-0.6.0 → libstb-0.8.0}/docs/index.html.in +115 -92
  31. {libstb-0.6.0 → libstb-0.8.0}/docs/initial_comment.in +1 -1
  32. {libstb-0.6.0 → libstb-0.8.0}/docs/make_showcase.py +27 -2
  33. libstb-0.8.0/docs/python/index-install.txt +2 -0
  34. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/_themes/libstb/layout.html +8 -6
  35. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/_themes/libstb/static/libstb-sphinx.css +12 -12
  36. libstb-0.8.0/docs/python/source/font.rst +61 -0
  37. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/index.rst +3 -2
  38. libstb-0.8.0/docs/python/source/zlib.rst +30 -0
  39. {libstb-0.6.0 → libstb-0.8.0}/docs/supported_langs.json +13 -13
  40. libstb-0.8.0/examples/cpp/canvas.cpp +53 -0
  41. {libstb-0.6.0 → libstb-0.8.0}/examples/python/05_font_render.py +9 -0
  42. libstb-0.8.0/include/stb/canvas.hpp +304 -0
  43. libstb-0.8.0/include/stb/color.hpp +1051 -0
  44. {libstb-0.6.0 → libstb-0.8.0}/include/stb/font.hpp +51 -1
  45. {libstb-0.6.0 → libstb-0.8.0}/include/stb/image.hpp +5 -1
  46. libstb-0.8.0/include/stb/shape.hpp +67 -0
  47. libstb-0.8.0/include/stb/shaping.hpp +49 -0
  48. libstb-0.8.0/include/stb/zlib.hpp +59 -0
  49. {libstb-0.6.0 → libstb-0.8.0}/include/stb.h +6 -1
  50. {libstb-0.6.0 → libstb-0.8.0}/pyproject.toml +4 -4
  51. {libstb-0.6.0 → libstb-0.8.0}/requirements-dev.txt +2 -2
  52. {libstb-0.6.0 → libstb-0.8.0}/src/bindings/python/CMakeLists.txt +1 -1
  53. libstb-0.8.0/src/bindings/python/bind_font.cpp +353 -0
  54. {libstb-0.6.0 → libstb-0.8.0}/src/bindings/python/bind_image.cpp +1 -33
  55. libstb-0.8.0/src/bindings/python/bind_zlib.cpp +34 -0
  56. {libstb-0.6.0 → libstb-0.8.0}/src/bindings/python/binding.cpp +1 -0
  57. libstb-0.8.0/src/bindings/python/binding.hpp +59 -0
  58. {libstb-0.6.0 → libstb-0.8.0}/src/bindings/python/libstb/__init__.py +8 -4
  59. libstb-0.8.0/src/bindings/python/libstb/compress.py +50 -0
  60. {libstb-0.6.0 → libstb-0.8.0}/src/bindings/python/libstb/font.py +30 -0
  61. libstb-0.8.0/src/core/arabic.cpp +220 -0
  62. libstb-0.8.0/src/core/arabic.hpp +39 -0
  63. libstb-0.8.0/src/core/bidi.cpp +225 -0
  64. libstb-0.8.0/src/core/bidi.hpp +30 -0
  65. libstb-0.8.0/src/core/font.cpp +610 -0
  66. libstb-0.8.0/src/core/gsub.cpp +544 -0
  67. libstb-0.8.0/src/core/gsub.hpp +148 -0
  68. {libstb-0.6.0 → libstb-0.8.0}/src/core/image.cpp +53 -0
  69. {libstb-0.6.0 → libstb-0.8.0}/src/core/image_ops.cpp +8 -4
  70. libstb-0.8.0/src/core/otl.cpp +109 -0
  71. libstb-0.8.0/src/core/otl.hpp +130 -0
  72. libstb-0.8.0/src/core/shape.cpp +117 -0
  73. libstb-0.8.0/src/core/shaping.cpp +38 -0
  74. libstb-0.8.0/src/core/text_shaper.cpp +185 -0
  75. libstb-0.8.0/src/core/text_shaper.hpp +68 -0
  76. libstb-0.8.0/src/core/zlib.cpp +137 -0
  77. libstb-0.8.0/src/core/zlib_bridge.hpp +23 -0
  78. {libstb-0.6.0 → libstb-0.8.0}/tests/CMakeLists.txt +11 -11
  79. {libstb-0.6.0 → libstb-0.8.0}/tests/cmake/CMakeLists.txt +4 -4
  80. {libstb-0.6.0 → libstb-0.8.0}/tests/cpp/CMakeLists.txt +27 -20
  81. libstb-0.8.0/tests/cpp/test_color.cpp +384 -0
  82. libstb-0.8.0/tests/cpp/test_font.cpp +838 -0
  83. libstb-0.8.0/tests/cpp/test_gsub.cpp +456 -0
  84. {libstb-0.6.0 → libstb-0.8.0}/tests/cpp/test_image.cpp +25 -0
  85. libstb-0.8.0/tests/cpp/test_zlib.cpp +141 -0
  86. libstb-0.8.0/tests/data/OFL-Vazirmatn.txt +93 -0
  87. libstb-0.8.0/tests/data/libstb-fa-gsub-test.ttf +0 -0
  88. libstb-0.8.0/tests/data/libstb-fa-test.ttf +0 -0
  89. libstb-0.8.0/tests/data/make_persian_font.py +67 -0
  90. {libstb-0.6.0 → libstb-0.8.0}/tests/genhtml.css +20 -20
  91. {libstb-0.6.0 → libstb-0.8.0}/tests/python/CMakeLists.txt +9 -9
  92. libstb-0.8.0/tests/python/pngbomb.py +46 -0
  93. libstb-0.8.0/tests/python/test_font.py +652 -0
  94. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_memory.py +58 -0
  95. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_oop.py +24 -0
  96. libstb-0.8.0/tests/python/test_png_bomb.py +72 -0
  97. libstb-0.8.0/tests/python/test_zlib.py +162 -0
  98. libstb-0.8.0/tools/gen_arabic_shaping.py +91 -0
  99. libstb-0.8.0/tools/gen_font_metrics.py +76 -0
  100. libstb-0.6.0/README.md +0 -360
  101. libstb-0.6.0/benchmarks/outputs/index.html +0 -7726
  102. libstb-0.6.0/benchmarks/report/CMakeLists.txt +0 -94
  103. libstb-0.6.0/docs/python/index-install.txt +0 -2
  104. libstb-0.6.0/docs/python/source/_themes/libstb/static/libstb-docs.css +0 -418
  105. libstb-0.6.0/docs/python/source/font.rst +0 -30
  106. libstb-0.6.0/src/bindings/python/bind_font.cpp +0 -118
  107. libstb-0.6.0/src/bindings/python/binding.hpp +0 -13
  108. libstb-0.6.0/src/core/font.cpp +0 -347
  109. libstb-0.6.0/tests/cpp/test_font.cpp +0 -190
  110. libstb-0.6.0/tests/python/test_font.py +0 -145
  111. {libstb-0.6.0 → libstb-0.8.0}/.github/workflows/orchestrator.yml +0 -0
  112. {libstb-0.6.0 → libstb-0.8.0}/.github/workflows/release_template.md +0 -0
  113. {libstb-0.6.0 → libstb-0.8.0}/.github/workflows/wheels.yml +0 -0
  114. {libstb-0.6.0 → libstb-0.8.0}/.gitignore +0 -0
  115. {libstb-0.6.0 → libstb-0.8.0}/LICENSE.txt +0 -0
  116. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/.gitignore +0 -0
  117. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/cmake/Download.cmake +0 -0
  118. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/cmake/FetchRealCorpus.cmake +0 -0
  119. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/corpus/.gitignore +0 -0
  120. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/outputs/results/fonts.json +0 -0
  121. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/outputs/results/scaling.json +0 -0
  122. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/outputs/results/system_info.json +0 -0
  123. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/outputs/results/throughput.json +0 -0
  124. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/outputs/results/throughput_memory.json +0 -0
  125. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/outputs/results/verify.json +0 -0
  126. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/bench_fonts.py +0 -0
  127. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/bench_op_memory_driver.py +0 -0
  128. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/bench_op_memory_one.py +0 -0
  129. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/bench_scaling.py +0 -0
  130. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/bench_throughput.py +0 -0
  131. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/corpus.py +0 -0
  132. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/real_corpus_manifest.py +0 -0
  133. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/requirements.txt +0 -0
  134. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/runners.py +0 -0
  135. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/system_info.py +0 -0
  136. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/python/verify.py +0 -0
  137. {libstb-0.6.0 → libstb-0.8.0}/benchmarks/report/gather.py +0 -0
  138. {libstb-0.6.0 → libstb-0.8.0}/cmake/DynamicVersion.cmake +0 -0
  139. {libstb-0.6.0 → libstb-0.8.0}/cmake/FixLCovPaths.cmake +0 -0
  140. {libstb-0.6.0 → libstb-0.8.0}/cmake/GenerateIframe.cmake +0 -0
  141. {libstb-0.6.0 → libstb-0.8.0}/cmake/Optimize.cmake +0 -0
  142. {libstb-0.6.0 → libstb-0.8.0}/cmake/Startup.cmake +0 -0
  143. {libstb-0.6.0 → libstb-0.8.0}/cmake/libstbConfig.cmake.in +0 -0
  144. {libstb-0.6.0 → libstb-0.8.0}/docs/InjectComment.cmake +0 -0
  145. {libstb-0.6.0 → libstb-0.8.0}/docs/assets/bench-teaser.js +0 -0
  146. {libstb-0.6.0 → libstb-0.8.0}/docs/cpp/index-example.txt +0 -0
  147. {libstb-0.6.0 → libstb-0.8.0}/docs/cpp/topbar.html.in +0 -0
  148. {libstb-0.6.0 → libstb-0.8.0}/docs/images/libstb-logo.png +0 -0
  149. {libstb-0.6.0 → libstb-0.8.0}/docs/images/libstb-sq.png +0 -0
  150. {libstb-0.6.0 → libstb-0.8.0}/docs/images/libstb-sq.svg +0 -0
  151. {libstb-0.6.0 → libstb-0.8.0}/docs/images/libstb-sq.txt +0 -0
  152. {libstb-0.6.0 → libstb-0.8.0}/docs/images/libstb-theme.svg +0 -0
  153. {libstb-0.6.0 → libstb-0.8.0}/docs/python/CreateDocs.cmake +0 -0
  154. {libstb-0.6.0 → libstb-0.8.0}/docs/python/index-docs.json +0 -0
  155. {libstb-0.6.0 → libstb-0.8.0}/docs/python/index-example.txt +0 -0
  156. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/_themes/libstb/libstb-nav.html +0 -0
  157. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/_themes/libstb/page.html +0 -0
  158. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/_themes/libstb/theme.toml +0 -0
  159. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/conf.py +0 -0
  160. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/errors.rst +0 -0
  161. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/image.rst +0 -0
  162. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/resizer.rst +0 -0
  163. {libstb-0.6.0 → libstb-0.8.0}/docs/python/source/simd.rst +0 -0
  164. {libstb-0.6.0 → libstb-0.8.0}/examples/cpp/.gitignore +0 -0
  165. {libstb-0.6.0 → libstb-0.8.0}/examples/notebooks/.gitignore +0 -0
  166. {libstb-0.6.0 → libstb-0.8.0}/examples/notebooks/01_getting_started.ipynb +0 -0
  167. {libstb-0.6.0 → libstb-0.8.0}/examples/notebooks/02_resize_filters.ipynb +0 -0
  168. {libstb-0.6.0 → libstb-0.8.0}/examples/notebooks/03_font_rendering.ipynb +0 -0
  169. {libstb-0.6.0 → libstb-0.8.0}/examples/notebooks/04_edit_and_orient.ipynb +0 -0
  170. {libstb-0.6.0 → libstb-0.8.0}/examples/notebooks/requirements.txt +0 -0
  171. {libstb-0.6.0 → libstb-0.8.0}/examples/python/.gitignore +0 -0
  172. {libstb-0.6.0 → libstb-0.8.0}/examples/python/01_open_and_inspect.py +0 -0
  173. {libstb-0.6.0 → libstb-0.8.0}/examples/python/02_encode_formats.py +0 -0
  174. {libstb-0.6.0 → libstb-0.8.0}/examples/python/03_resize_filters.py +0 -0
  175. {libstb-0.6.0 → libstb-0.8.0}/examples/python/04_numpy_interop.py +0 -0
  176. {libstb-0.6.0 → libstb-0.8.0}/examples/python/06_imread_imwrite.py +0 -0
  177. {libstb-0.6.0 → libstb-0.8.0}/examples/python/07_dlpack.py +0 -0
  178. {libstb-0.6.0 → libstb-0.8.0}/examples/python/08_geometry.py +0 -0
  179. {libstb-0.6.0 → libstb-0.8.0}/examples/python/09_channels_and_alpha.py +0 -0
  180. {libstb-0.6.0 → libstb-0.8.0}/examples/python/10_exif_orientation.py +0 -0
  181. {libstb-0.6.0 → libstb-0.8.0}/examples/python/11_pillow.py +0 -0
  182. {libstb-0.6.0 → libstb-0.8.0}/examples/python/requirements.txt +0 -0
  183. {libstb-0.6.0 → libstb-0.8.0}/include/stb/env.hpp +0 -0
  184. {libstb-0.6.0 → libstb-0.8.0}/include/stb/error.hpp +0 -0
  185. {libstb-0.6.0 → libstb-0.8.0}/include/stb/resizer.hpp +0 -0
  186. {libstb-0.6.0 → libstb-0.8.0}/include/stb/utf8.hpp +0 -0
  187. {libstb-0.6.0 → libstb-0.8.0}/src/bindings/python/bind_resizer.cpp +0 -0
  188. {libstb-0.6.0 → libstb-0.8.0}/src/bindings/python/libstb/image.py +0 -0
  189. {libstb-0.6.0 → libstb-0.8.0}/src/core/exif.cpp +0 -0
  190. {libstb-0.6.0 → libstb-0.8.0}/src/core/file.hpp +0 -0
  191. {libstb-0.6.0 → libstb-0.8.0}/src/core/image_kernels.hpp +0 -0
  192. {libstb-0.6.0 → libstb-0.8.0}/src/core/image_kernels_scalar.cpp +0 -0
  193. {libstb-0.6.0 → libstb-0.8.0}/src/core/image_kernels_sse2.cpp +0 -0
  194. {libstb-0.6.0 → libstb-0.8.0}/src/core/resizer.cpp +0 -0
  195. {libstb-0.6.0 → libstb-0.8.0}/src/core/simd.cpp +0 -0
  196. {libstb-0.6.0 → libstb-0.8.0}/src/core/simd.hpp +0 -0
  197. {libstb-0.6.0 → libstb-0.8.0}/src/core/utf8.cpp +0 -0
  198. {libstb-0.6.0 → libstb-0.8.0}/src/third_party/README.md +0 -0
  199. {libstb-0.6.0 → libstb-0.8.0}/src/third_party/stb/stb_image.h +0 -0
  200. {libstb-0.6.0 → libstb-0.8.0}/src/third_party/stb/stb_image_resize2.h +0 -0
  201. {libstb-0.6.0 → libstb-0.8.0}/src/third_party/stb/stb_image_write.h +0 -0
  202. {libstb-0.6.0 → libstb-0.8.0}/src/third_party/stb/stb_rect_pack.h +0 -0
  203. {libstb-0.6.0 → libstb-0.8.0}/src/third_party/stb/stb_truetype.h +0 -0
  204. {libstb-0.6.0 → libstb-0.8.0}/tests/cmake/consumer_project/CMakeLists.txt +0 -0
  205. {libstb-0.6.0 → libstb-0.8.0}/tests/cmake/consumer_project/main.cpp +0 -0
  206. {libstb-0.6.0 → libstb-0.8.0}/tests/cmake/run_consumer_test.cmake +0 -0
  207. {libstb-0.6.0 → libstb-0.8.0}/tests/coverage_dashboard.html.in +0 -0
  208. {libstb-0.6.0 → libstb-0.8.0}/tests/cpp/test_common.hpp +0 -0
  209. {libstb-0.6.0 → libstb-0.8.0}/tests/cpp/test_edit.cpp +0 -0
  210. {libstb-0.6.0 → libstb-0.8.0}/tests/cpp/test_encode.cpp +0 -0
  211. {libstb-0.6.0 → libstb-0.8.0}/tests/cpp/test_env.cpp +0 -0
  212. {libstb-0.6.0 → libstb-0.8.0}/tests/cpp/test_exif.cpp +0 -0
  213. {libstb-0.6.0 → libstb-0.8.0}/tests/cpp/test_resizer.cpp +0 -0
  214. {libstb-0.6.0 → libstb-0.8.0}/tests/cpp/test_utf8.cpp +0 -0
  215. {libstb-0.6.0 → libstb-0.8.0}/tests/data/libstb-test.ttf +0 -0
  216. {libstb-0.6.0 → libstb-0.8.0}/tests/data/make_test_font.py +0 -0
  217. {libstb-0.6.0 → libstb-0.8.0}/tests/python/conftest.py +0 -0
  218. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_array_interface.py +0 -0
  219. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_channels.py +0 -0
  220. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_dlpack.py +0 -0
  221. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_encode.py +0 -0
  222. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_errors.py +0 -0
  223. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_exif.py +0 -0
  224. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_functional.py +0 -0
  225. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_gc.py +0 -0
  226. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_geometry.py +0 -0
  227. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_image.py +0 -0
  228. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_lossless_exact.py +0 -0
  229. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_lossy_tolerance.py +0 -0
  230. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_no_numpy.py +0 -0
  231. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_pillow_convert.py +0 -0
  232. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_pillow_parity.py +0 -0
  233. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_resizer.py +0 -0
  234. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_simd.py +0 -0
  235. {libstb-0.6.0 → libstb-0.8.0}/tests/python/test_torch.py +0 -0
  236. {libstb-0.6.0 → libstb-0.8.0}/tests/python/tolerances.py +0 -0
  237. {libstb-0.6.0 → libstb-0.8.0}/tests/tools/jpeg_vs_upstream.py +0 -0
  238. {libstb-0.6.0 → libstb-0.8.0}/tests/tools/zlib_fuzz.py +0 -0
  239. {libstb-0.6.0 → libstb-0.8.0}/tests/utest/utest.h +0 -0
  240. {libstb-0.6.0 → libstb-0.8.0}/tests/utest/utest_main.cxx +0 -0
  241. {libstb-0.6.0 → libstb-0.8.0}/version.py +0 -0
@@ -28,7 +28,7 @@ jobs:
28
28
  run: pip install -r requirements-dev.txt
29
29
 
30
30
  - name: Configure Project
31
- run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DLIBSTB_BUILD_TESTS=ON -DLIBSTB_BUILD_PYTHON=ON
31
+ run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DSTB_BUILD_TESTS=ON -DSTB_BUILD_PYTHON=ON
32
32
 
33
33
  - name: Build
34
34
  run: cmake --build build -j4 --config Release
@@ -66,12 +66,12 @@ jobs:
66
66
  run: |
67
67
  cmake -S . -B build \
68
68
  -DCMAKE_BUILD_TYPE=Release \
69
- -DLIBSTB_BUILD_TESTS=OFF \
70
- -DLIBSTB_BUILD_PYTHON=ON \
71
- -DLIBSTB_BUILD_DOCS=ON
69
+ -DSTB_BUILD_TESTS=OFF \
70
+ -DSTB_BUILD_PYTHON=ON \
71
+ -DSTB_BUILD_DOCS=ON
72
72
 
73
73
  - name: Build documentation
74
- run: cmake --build build --target libstb_docs
74
+ run: cmake --build build --target stb_docs
75
75
 
76
76
  - name: List docs directory
77
77
  run: tree --du -shaC build/docs/out
@@ -113,13 +113,13 @@ jobs:
113
113
  - name: Configure CMake
114
114
  run: |
115
115
  cmake -S . -B build \
116
- -DLIBSTB_BUILD_TESTS=ON \
117
- -DLIBSTB_BUILD_PYTHON=ON \
118
- -DLIBSTB_BUILD_DOCS=OFF
116
+ -DSTB_BUILD_TESTS=ON \
117
+ -DSTB_BUILD_PYTHON=ON \
118
+ -DSTB_BUILD_DOCS=OFF
119
119
 
120
120
  # C++ (lcov), Python (coverage.py) and the merged total.
121
121
  - name: Generate coverage report
122
- run: cmake --build build --target libstb_coverage
122
+ run: cmake --build build --target stb_coverage
123
123
 
124
124
  - name: Upload coverage to Codecov
125
125
  uses: codecov/codecov-action@v5
@@ -3,9 +3,117 @@
3
3
  All notable changes to libstb are listed here, newest first. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Dates are commit dates.
5
5
 
6
- This file was generated from the git history (42 commits, tags `v0.3.0`, `v0.4.0`, `v0.5.0`).
6
+ This file was generated from the git history (61 commits, tags `v0.3.0`, `v0.4.0`, `v0.5.0`, `v0.6.0`, `v0.7.0`); 0.8.0 was written by hand from the 26 commits after `v0.7.0`.
7
7
 
8
- ## [Unreleased] (after 0.5.0)
8
+ ## [0.8.0] - 2026-10-22
9
+
10
+ ### Added
11
+ - Drawing text (`4ab53e3`, `15ad30c`): `stb::font::draw_text` and `Image.draw_text` write multi-line
12
+ UTF-8 text onto a 1 to 4 channel image with alpha blending. `text_align` (`left`, `center`,
13
+ `right`) aligns every line to the x you give.
14
+ - `stb::color` (`<stb/color.hpp>`, `ededbef`): colours from names, `#hex`, `{r, g, b[, a]}` and
15
+ string literals, and `color::from_value(0xRRGGBB)`. Used by `draw_text` and the canvas.
16
+ - Canvas (`stb::canvas`, `Image.canvas`, `1fc491a`, `4201852`, `bcc2e39`): collect texts and
17
+ shapes, drawn together by `finish()`. `add_text` returns an item with its own `.font()`,
18
+ `.size()`, `.color()`, `.align()`, `.bg_color()` and `.padding()`. `add_rect` (with `.radius()`),
19
+ `add_ellipse` and `add_line` return a shape with `.fill()`, `.no_fill()` and `.stroke()`, with
20
+ smooth edges (`6243481`). The API is the same in C++ and Python, and golden-hash tests keep
21
+ their output byte-identical.
22
+ - Right-to-left text (Persian, Arabic, Urdu, Hebrew) in `draw_text`, `measure`, `render` and the
23
+ canvas: pass the text as typed, with no `arabic-reshaper` or `python-bidi`. The line is
24
+ ordered with the Unicode bidirectional algorithm (UAX #9, without explicit embeddings and
25
+ isolates), ZWNJ and ZWJ are honoured and brackets are mirrored.
26
+ - Letter shapes and ligatures come from the font's GSUB table for Arabic script: `isol`,
27
+ `init`, `medi`, `fina`, `ccmp`, `rlig` (lam-alef), `calt` and `liga` (so "الله" is the one
28
+ glyph the font draws for it). Lookup types 1 to 7 are read (single, multiple, alternate,
29
+ ligature, context, chaining context in all three formats, extension), with lookup flags and
30
+ GDEF. A font without GSUB but with the Arabic Presentation Forms in its `cmap` is shaped
31
+ through those, and a form it lacks falls back to the plain letter (`cea22ba`, `79fce16`).
32
+ - Marks (harakat) sit over or under their letter by a simple rule, with no room of their own
33
+ (`7c301be`).
34
+ - Checked against HarfBuzz: identical glyph ids on 3,000 random strings, with and without
35
+ marks, on each of Vazirmatn, Noto Naskh Arabic and Noto Sans Arabic. About 0.2 microseconds
36
+ per character, 2.4 times faster than Pillow with raqm for the layout of a 438-character
37
+ paragraph. The GSUB table is parsed the first time right-to-left text is drawn with a font
38
+ (about 0.1 ms); opening a font is as fast as before.
39
+ - The font is untrusted input. Every read is range-checked, the growth of the glyph run and
40
+ the work of the lookups are limited in proportion to the text, and 50,000 damaged fonts
41
+ shaped under AddressSanitizer and UBSan without a crash.
42
+ - Not done: GPOS (kerning is the `kern` table only, marks are not placed by the font's
43
+ anchors, so fonts that depend on GPOS for their shapes, some Nastaliq fonts, look wrong),
44
+ GSUB lookup type 8, `locl` per language, and the Syriac features. Not checked: Hebrew,
45
+ Urdu-specific letters, OpenType-CFF (`.otf`) fonts and B Nazanin.
46
+ - `stb::font::shape_glyphs` / `Font.shape_glyphs(text)`: the glyph indices shaping chose, in
47
+ visual order, for diagnostics and tests.
48
+ - `<stb/shaping.hpp>`: `stb::shape_for_display`, `stb::has_rtl`, `stb::is_arabic_mark` and
49
+ `stb::is_arabic_mark_below`, the code-point level steps behind the above.
50
+ - Tests: white-box tests of the GSUB engine with hand-made tables (every lookup type and
51
+ format, a stage mask, truncated and damaged tables), HarfBuzz reference glyph ids in C++ and
52
+ Python, a live HarfBuzz comparison in Python when `uharfbuzz` is installed (now in the `test`
53
+ extra), a Persian golden hash shared by C++ and Python, and two Vazirmatn subsets under the
54
+ SIL OFL 1.1 in `tests/data` (`make_persian_font.py` rebuilds them).
55
+
56
+ ### Changed
57
+ - `Image.canvas` and `Image.draw_text` are nanobind methods, and a font argument of the wrong
58
+ type raises `TypeError` (`fc3aaff`, `402153d`).
59
+ - `stb::color` converts implicitly from string literals and brace lists.
60
+ - Benchmark report and docs: Chart.js and KaTeX load from cdnjs, brand colours, download buttons
61
+ for the benchmark data, and zero Doxygen and Sphinx warnings (`641561c`, `054ea1f`, `ee3af4f`).
62
+
63
+ ### Fixed
64
+ - Windows: a test variable named `small` collided with an `rpcndr.h` macro, and the canvas box
65
+ arithmetic is 64-bit with parenthesized `min`/`max` (`3145a8a`).
66
+ - Windows (MSVC): the C++ tests are built with `/utf-8`, so Persian and Arabic text written as
67
+ `"\u0633"` in a narrow string literal stays UTF-8 instead of becoming `?` in the ANSI code page,
68
+ and the shaping tests parenthesize `std::min`/`std::max` against the `windows.h` macros.
69
+
70
+ ## [0.7.0] - 2026-10-17
71
+
72
+ ### Breaking
73
+ - CMake names changed (`016551c`, `c76d406`, `3b02769`). Targets `libstb_*` are now `stb_*`:
74
+ `stb_core` (the library; still exported as `libstb::core`), `stb_test`, `stb_test_cpp`,
75
+ `stb_test_python`, `stb_test_cmake`, `stb_docs` (`_cpp`, `_python`, `_index`), `stb_coverage`
76
+ (`_cpp`, `_python`, `_total`), `stb_benchmark` and `stb_bench_*`; the C++ test executable
77
+ `test_libstb_cpp` is now `test_stb_cpp`. The options `LIBSTB_BUILD_TESTS`, `LIBSTB_BUILD_PYTHON`
78
+ and `LIBSTB_BUILD_DOCS` are now `STB_BUILD_TESTS`, `STB_BUILD_PYTHON` and `STB_BUILD_DOCS`.
79
+ Scripts and CI that call the old names must be updated. Not renamed: the package and project
80
+ name `libstb`, `find_package(libstb CONFIG)`, `libstb::core`, `import libstb`, the extension
81
+ module `libstb_py`, and environment variables such as `LIBSTB_SIMD`.
82
+
83
+ ### Added
84
+ - `stb::zlib_compress` / `stb::zlib_decompress` (`<stb/zlib.hpp>`; Python: `libstb.zlib_compress`,
85
+ `libstb.zlib_decompress`, `DEFAULT_ZLIB_LEVEL`, `DEFAULT_ZLIB_MAX_BYTES`) (`0088cb8`): zlib streams
86
+ with the PNG compressor and stb_image's inflate. `level` uses zlib's numbering (0 stores, 1 to 9,
87
+ -1 default 6). The output of `zlib_decompress` is bounded by `max_bytes` (a zip bomb is a
88
+ `limit_error` / `LimitError`, never an out-of-memory), the Adler-32 is verified, and both
89
+ directions interoperate with zlib. Compression was 1.2x to 1.9x faster than zlib level 6 with
90
+ 0.4% to 3.3% larger output on our samples; decompression is **not** faster than zlib (about
91
+ 2.5x slower on very compressible text). Any bytes-like object is accepted in Python and the GIL
92
+ is released.
93
+ - `stb::estimate_text` / `stb::estimate_metrics` (Python: `libstb.estimate_text`,
94
+ `libstb.estimate_metrics`): rough text size without a font file, from fixed width tables for
95
+ `sans`, `serif` and `mono` (Liberation metrics, generated by `tools/gen_font_metrics.py`, no font
96
+ bundled). No kerning; CJK and emoji count as 1 em and other non-Latin text is approximated.
97
+ - Tests: a real PNG decompression bomb (a valid 0.5 MB file that declares 576 MB), generated on
98
+ demand by `tests/python/pngbomb.py`, checked from Python (`test_png_bomb.py`, with a memray bound)
99
+ and C++ (`test_a_real_png_bomb_is_refused_from_its_header`) (`83226ea`); zlib tests against
100
+ python's `zlib` in both directions, zip bombs and exact `max_bytes` bounds; font estimator
101
+ tests, including agreement with the real Liberation fonts when they are installed.
102
+ - `docs/guide.md`: the complete reference that used to be the README (`ec879bb`).
103
+ - Documentation pages for the zlib and estimator APIs (Sphinx and Doxygen).
104
+
105
+ ### Changed
106
+ - README rewritten as a short landing page: Python first, then C++ with CMake, then which stb
107
+ modules are used and how libstb differs from plain stb in API and performance (`ec879bb`).
108
+ - Internal: stb's headers are still compiled in one translation unit (`src/core/image.cpp`); the
109
+ zlib API reaches them through `src/core/zlib_bridge.hpp`, so the compressor and inflater exist
110
+ once. The Python bindings share one `py_buffer` helper (`binding.hpp`).
111
+
112
+ ### Fixed
113
+ - The C++ install snippets (`docs/cpp/index-install.txt`, `docs/cpp/mainpage.md`) used
114
+ `GIT_TAG main`, but the default branch is `master`.
115
+
116
+ ## [0.6.0] - 2026-10-16
9
117
 
10
118
  ### Breaking
11
119
  - `Image.rotate90(turns=1)` (C++: `stb::image::rotate90`) now turns **counter-clockwise**, like
@@ -19,9 +19,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)
19
19
 
20
20
  include(Optimize)
21
21
 
22
- option(LIBSTB_BUILD_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL})
23
- option(LIBSTB_BUILD_PYTHON "Build Python bindings" ${PROJECT_IS_TOP_LEVEL})
24
- option(LIBSTB_BUILD_DOCS "Build documentation (Doxygen + Sphinx)" OFF)
22
+ option(STB_BUILD_TESTS "Build tests" ${PROJECT_IS_TOP_LEVEL})
23
+ option(STB_BUILD_PYTHON "Build Python bindings" ${PROJECT_IS_TOP_LEVEL})
24
+ option(STB_BUILD_DOCS "Build documentation (Doxygen + Sphinx)" OFF)
25
25
 
26
26
  # --- libstb C++ core ---
27
27
  # stb headers are vendored (committed) under src/third_party/stb and are only
@@ -31,10 +31,10 @@ option(LIBSTB_BUILD_DOCS "Build documentation (Doxygen + Sphinx)" OFF)
31
31
  # stbi_* symbol leaks out to consumers.
32
32
  file(GLOB LIBSTB_CORE_SOURCES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/src/core/*.cpp)
33
33
 
34
- add_library(libstb_core STATIC ${LIBSTB_CORE_SOURCES})
35
- add_library(libstb::core ALIAS libstb_core)
34
+ add_library(stb_core STATIC ${LIBSTB_CORE_SOURCES})
35
+ add_library(libstb::core ALIAS stb_core)
36
36
 
37
- set_target_properties(libstb_core PROPERTIES
37
+ set_target_properties(stb_core PROPERTIES
38
38
  POSITION_INDEPENDENT_CODE ON # linked into the Python extension
39
39
  CXX_VISIBILITY_PRESET hidden
40
40
  VISIBILITY_INLINES_HIDDEN ON
@@ -55,14 +55,14 @@ else()
55
55
  set(_libstb_cmake_dest lib/cmake/libstb)
56
56
  endif()
57
57
 
58
- target_include_directories(libstb_core
58
+ target_include_directories(stb_core
59
59
  PUBLIC
60
60
  $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
61
61
  $<INSTALL_INTERFACE:${_libstb_inc_dest}>
62
62
  )
63
63
  # Everything that decides how the core sources are compiled lives in this function, so a target
64
64
  # that compiles them itself (tests/cpp does, to attach coverage flags) gets exactly the same
65
- # settings as libstb_core.
65
+ # settings as stb_core.
66
66
  function(libstb_apply_core_build_settings target)
67
67
  # SYSTEM: vendored headers we don't control - their internal warnings are not
68
68
  # ours to fix under our own -Wall/-Wextra/-W4.
@@ -80,6 +80,15 @@ function(libstb_apply_core_build_settings target)
80
80
  )
81
81
  apply_optimization_flags(${target})
82
82
 
83
+ # shape.cpp draws with floating point and the result must be the same on every platform
84
+ # (the C++ and Python canvas tests compare against one fixed hash), so no fused multiply-add
85
+ # contraction: GCC and Clang would otherwise use FMA on ARM and give last-bit differences.
86
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
87
+ set_source_files_properties(${PROJECT_SOURCE_DIR}/src/core/shape.cpp
88
+ TARGET_DIRECTORY ${target}
89
+ PROPERTIES COMPILE_OPTIONS "-ffp-contract=off")
90
+ endif()
91
+
83
92
  # image_kernels_scalar.cpp is the "scalar" SIMD backend: the same pixel loops with the
84
93
  # compiler's auto-vectoriser off. (MSVC has no such switch: there it may still vectorise,
85
94
  # with identical results.) TARGET_DIRECTORY: source file properties are per directory scope.
@@ -94,11 +103,11 @@ function(libstb_apply_core_build_settings target)
94
103
  endif()
95
104
  endfunction()
96
105
 
97
- libstb_apply_core_build_settings(libstb_core)
106
+ libstb_apply_core_build_settings(stb_core)
98
107
 
99
108
  # --- install (find_package(libstb) -> libstb::core) ---
100
109
  include(CMakePackageConfigHelpers)
101
- install(TARGETS libstb_core EXPORT libstbTargets ARCHIVE DESTINATION ${_libstb_lib_dest})
110
+ install(TARGETS stb_core EXPORT libstbTargets ARCHIVE DESTINATION ${_libstb_lib_dest})
102
111
  install(DIRECTORY include/ DESTINATION ${_libstb_inc_dest})
103
112
  install(EXPORT libstbTargets FILE libstbTargets.cmake NAMESPACE libstb:: DESTINATION ${_libstb_cmake_dest})
104
113
  configure_package_config_file(
@@ -117,7 +126,7 @@ install(FILES
117
126
  DESTINATION ${_libstb_cmake_dest}
118
127
  )
119
128
 
120
- if(LIBSTB_BUILD_PYTHON OR DEFINED SKBUILD)
129
+ if(STB_BUILD_PYTHON OR DEFINED SKBUILD)
121
130
  set(PYTHON_INSTALL_DIR ${CMAKE_BINARY_DIR}/python/install)
122
131
  add_subdirectory(${PROJECT_SOURCE_DIR}/src/bindings/python)
123
132
  if(DEFINED SKBUILD)
@@ -125,13 +134,13 @@ if(LIBSTB_BUILD_PYTHON OR DEFINED SKBUILD)
125
134
  endif()
126
135
  endif()
127
136
 
128
- if(LIBSTB_BUILD_TESTS)
137
+ if(STB_BUILD_TESTS)
129
138
  enable_testing()
130
139
  set(CMAKE_CTEST_ARGUMENTS "--output-on-failure" "-V")
131
140
  add_subdirectory(${PROJECT_SOURCE_DIR}/tests)
132
141
  endif()
133
142
 
134
143
  # Documentation (Doxygen + Sphinx). Needs the Python extension: the Sphinx build imports it.
135
- if(LIBSTB_BUILD_DOCS)
144
+ if(STB_BUILD_DOCS)
136
145
  add_subdirectory(${PROJECT_SOURCE_DIR}/docs)
137
146
  endif()
libstb-0.8.0/PKG-INFO ADDED
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.2
2
+ Name: libstb
3
+ Version: 0.8.0
4
+ Summary: Images, fonts and zlib on top of the stb single-header libraries: decode, encode, resize, edit, draw text and compress. Zero system dependencies.
5
+ Author-Email: Mohammad Raziei <mohammadraziei1375@gmail.com>
6
+ License: MIT
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: C++
11
+ Classifier: Programming Language :: Python :: Implementation :: CPython
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Project-URL: Homepage, https://github.com/MohammadRaziei/libstb
19
+ Project-URL: Bug Tracker, https://github.com/MohammadRaziei/libstb/issues
20
+ Requires-Python: >=3.9
21
+ Provides-Extra: numpy
22
+ Requires-Dist: numpy; extra == "numpy"
23
+ Provides-Extra: pillow
24
+ Requires-Dist: pillow; extra == "pillow"
25
+ Provides-Extra: test
26
+ Requires-Dist: pytest; extra == "test"
27
+ Requires-Dist: uharfbuzz; extra == "test"
28
+ Requires-Dist: numpy; (sys_platform != "win32" or platform_machine != "ARM64" or python_version >= "3.11") and extra == "test"
29
+ Requires-Dist: pillow; extra == "test"
30
+ Requires-Dist: pytest-memray; sys_platform != "win32" and (platform_machine == "x86_64" or platform_machine == "arm64") and extra == "test"
31
+ Description-Content-Type: text/markdown
32
+
33
+ # libstb
34
+
35
+ Fast image, font and zlib processing for **Python and C++**, with no system dependencies and no
36
+ Python dependencies: decode, encode, resize, edit, draw text and compress with one small library.
37
+
38
+ libstb is highly powered by [stb](https://github.com/nothings/stb), and that is where the name
39
+ comes from. It is not a thin wrapper, though. The API is our own (typed, with explicit
40
+ ownership and errors), and several parts are rewritten or patched for speed, so both the API
41
+ and the performance differ from plain stb. See [what is from stb](#what-is-from-stb-and-what-is-not).
42
+
43
+ ## Python
44
+
45
+ ```sh
46
+ pip install libstb # numpy and Pillow are optional: "libstb[numpy]", "libstb[pillow]"
47
+ ```
48
+
49
+ ```python
50
+ import libstb as stb
51
+
52
+ img = stb.Image.open("photo.jpg") # PNG, JPEG, BMP, TGA, GIF, ... (or bytes)
53
+ img.width, img.height, img.channels # 640, 480, 3
54
+
55
+ small = img.resize(320, 240, "cubic") # filter by name: nearest, linear, cubic, mitchell, box...
56
+ small.write("small.png") # format from the extension (png, jpg, bmp, tga)
57
+ small.write_jpg("small.jpg", quality=80) # or choose the format and its settings
58
+ data = small.to_png(compression=9) # -> bytes
59
+
60
+ thumb = img.thumbnail(256, 256) # fits the box, never enlarges
61
+ img.crop(10, 10, 200, 100).rotate90().convert(1) # every edit returns a new Image
62
+
63
+ pixels = img.numpy() # zero-copy view (needs numpy); DLPack works too
64
+ photo = stb.Image.open("IMG_0001.jpg", orient=True) # apply the EXIF rotation while decoding
65
+
66
+ font = stb.Font.open("font.ttf") # trusted fonts only
67
+ labeled = img.draw_text("Hello", font, 32, 10, 10, color=(255, 255, 255)) # text onto a copy
68
+ centred = img.draw_text("Hello", font, 32, img.width // 2, 10, align="center") # x is the centre of the line
69
+ font.render("Hello", 32).bitmap.write("hello.png")
70
+ # Persian / Arabic text works as typed: the font's GSUB shapes and ligates it, the line is reordered (no GPOS, see docs/guide.md)
71
+ stb.estimate_text("Hello", 16) # text size with no font file at all
72
+
73
+ packed = stb.zlib_compress(data) # zlib streams: the compressor that writes PNG
74
+ data = stb.zlib_decompress(packed, max_bytes=64 << 20) # output is bounded: a zip bomb is a LimitError
75
+ ```
76
+
77
+ ## C++ with CMake
78
+
79
+ ```cmake
80
+ include(FetchContent)
81
+ FetchContent_Declare(libstb GIT_REPOSITORY https://github.com/MohammadRaziei/libstb.git GIT_TAG master)
82
+ FetchContent_MakeAvailable(libstb)
83
+
84
+ target_link_libraries(my_app PRIVATE libstb::core) # CMake 3.21+, C++17
85
+ ```
86
+
87
+ `find_package(libstb CONFIG)` works too, after `cmake --install` or after `pip install libstb`
88
+ (`stb.get_cmake_dir()` gives the config directory).
89
+
90
+ ```cpp
91
+ #include <stb.h>
92
+
93
+ stb::image img = stb::image::open("photo.jpg"); // throws stb::error subclasses
94
+ stb::image small = img.resize(320, 240, "cubic"); // or stb::resize_filter::mitchell
95
+ small.write("small.png"); // format from the extension
96
+ small.write_jpg("small.jpg", 80);
97
+ std::vector<std::uint8_t> bytes = small.to_png(9);
98
+
99
+ stb::font f = stb::font::open("font.ttf"); // cheap to copy, thread-safe
100
+ stb::image labeled = f.draw_text(img, "Hello", 32, 10, 10, stb::color("white"));
101
+ stb::image centred = f.draw_text(img, "Hello", 32, img.width() / 2, 10, stb::color(), stb::text_align::center);
102
+ stb::text_bitmap t = f.render("Hello", 32);
103
+ stb::text_size est = stb::estimate_text("Hello", 16); // no font file needed
104
+
105
+ std::vector<std::uint8_t> z = stb::zlib_compress(bytes); // <stb/zlib.hpp>, level 0..9 like zlib
106
+ std::vector<std::uint8_t> back = stb::zlib_decompress(z, 64u << 20); // throws limit_error past max_bytes
107
+ ```
108
+
109
+ The namespace and headers are `stb` (`<stb.h>`, `<stb/*.hpp>`); the CMake target
110
+ (`libstb::core`) and the Python package (`libstb`) keep the project name. No stb header is
111
+ ever included from a public header, and stb symbols do not leak from the library, so it links
112
+ next to your own copy of stb.
113
+
114
+ ## What is from stb, and what is not
115
+
116
+ libstb uses these stb modules, vendored in `src/third_party/` (no submodules):
117
+
118
+ | stb module | used for |
119
+ | :--- | :--- |
120
+ | `stb_image` | decoding (PNG, JPEG, BMP, TGA, GIF, ...) |
121
+ | `stb_image_write` | encoding PNG, JPEG, BMP, TGA |
122
+ | `stb_image_resize2` | resizing, all filters |
123
+ | `stb_truetype` | font metrics, glyphs, text rendering, atlases |
124
+ | `stb_rect_pack` | packing glyphs into an atlas |
125
+
126
+ What we changed on top, for speed and for a safer, more convenient API:
127
+
128
+ - **Faster encoders.** `stb_image_write.h` carries two local patches: a new PNG deflate (4-byte
129
+ hash chains, lazy matching, dynamic Huffman blocks: within about 1% of zlib level 6 in size at
130
+ roughly twice its speed) and a faster JPEG encoder (buffered bit writer, vectorisable DCT, SSE2 colour
131
+ conversion). The other stb headers are byte-for-byte upstream.
132
+ - **SIMD where it pays.** `convert`, `composite` and `flatten` have AVX2, baseline SIMD and
133
+ scalar builds that give identical results; the best one is picked at run time.
134
+ - **No hidden copies.** Decoded buffers are adopted, not copied; arrays and DLPack tensors are
135
+ shared when they can be; Python calls release the GIL.
136
+ - **zlib as an API.** The PNG compressor and stb's inflate are exposed as
137
+ `zlib_compress` and `zlib_decompress` (any bytes-like object in, bytes out), with a bounded
138
+ output so a zip bomb is a `LimitError`. They interoperate with python's `zlib`. Compression
139
+ was 1.2x to 1.9x faster than zlib level 6 at 0.4% to 3.3% larger output on our samples;
140
+ decompression is stb_image's and is **not** faster than zlib (about 2.5x slower on very
141
+ compressible text), so use zlib if inflate speed is what you need.
142
+ - **Editing stb does not have.** Crop, pad, flips, rotation, thumbnail, channel conversion,
143
+ alpha compositing, EXIF orientation, resize filters by name, and a font-free text size
144
+ estimate.
145
+ - **Safety.** Size limits are checked from the header before any pixel memory is allocated,
146
+ errors are typed (`stb.Error` with `DecodeError`, `EncodeError`, `LimitError`), and EXIF
147
+ parsing checks every offset. stb_truetype is still not safe on untrusted fonts: load only
148
+ fonts you trust.
149
+
150
+ Performance numbers against Pillow and OpenCV, including where libstb is slower (JPEG
151
+ encoding is one), are in [`benchmarks/`](benchmarks/README.md). They depend on the machine, so
152
+ run them on yours.
153
+
154
+ ## More
155
+
156
+ - [`docs/guide.md`](docs/guide.md): the full reference (every call, SIMD, EXIF, DLPack, Pillow,
157
+ errors, design and source layout).
158
+ - `docs/`: the Sphinx (Python) and Doxygen (C++) sources of the documentation site.
159
+ - [`CHANGELOG.md`](CHANGELOG.md).
160
+
161
+ ## Build and test
162
+
163
+ ```sh
164
+ pip install -r requirements-dev.txt
165
+ cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
166
+ cmake --build build
167
+ ctest --test-dir build --output-on-failure
168
+ ```
169
+
170
+ Options: `STB_BUILD_TESTS`, `STB_BUILD_PYTHON`, `STB_BUILD_DOCS`. Targets: `stb_core`,
171
+ `stb_test`, `stb_docs`, `stb_benchmark`.
172
+
173
+ ## License
174
+
175
+ MIT for libstb. The vendored stb headers are MIT / public domain (see
176
+ `src/third_party/README.md`).
libstb-0.8.0/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # libstb
2
+
3
+ Fast image, font and zlib processing for **Python and C++**, with no system dependencies and no
4
+ Python dependencies: decode, encode, resize, edit, draw text and compress with one small library.
5
+
6
+ libstb is highly powered by [stb](https://github.com/nothings/stb), and that is where the name
7
+ comes from. It is not a thin wrapper, though. The API is our own (typed, with explicit
8
+ ownership and errors), and several parts are rewritten or patched for speed, so both the API
9
+ and the performance differ from plain stb. See [what is from stb](#what-is-from-stb-and-what-is-not).
10
+
11
+ ## Python
12
+
13
+ ```sh
14
+ pip install libstb # numpy and Pillow are optional: "libstb[numpy]", "libstb[pillow]"
15
+ ```
16
+
17
+ ```python
18
+ import libstb as stb
19
+
20
+ img = stb.Image.open("photo.jpg") # PNG, JPEG, BMP, TGA, GIF, ... (or bytes)
21
+ img.width, img.height, img.channels # 640, 480, 3
22
+
23
+ small = img.resize(320, 240, "cubic") # filter by name: nearest, linear, cubic, mitchell, box...
24
+ small.write("small.png") # format from the extension (png, jpg, bmp, tga)
25
+ small.write_jpg("small.jpg", quality=80) # or choose the format and its settings
26
+ data = small.to_png(compression=9) # -> bytes
27
+
28
+ thumb = img.thumbnail(256, 256) # fits the box, never enlarges
29
+ img.crop(10, 10, 200, 100).rotate90().convert(1) # every edit returns a new Image
30
+
31
+ pixels = img.numpy() # zero-copy view (needs numpy); DLPack works too
32
+ photo = stb.Image.open("IMG_0001.jpg", orient=True) # apply the EXIF rotation while decoding
33
+
34
+ font = stb.Font.open("font.ttf") # trusted fonts only
35
+ labeled = img.draw_text("Hello", font, 32, 10, 10, color=(255, 255, 255)) # text onto a copy
36
+ centred = img.draw_text("Hello", font, 32, img.width // 2, 10, align="center") # x is the centre of the line
37
+ font.render("Hello", 32).bitmap.write("hello.png")
38
+ # Persian / Arabic text works as typed: the font's GSUB shapes and ligates it, the line is reordered (no GPOS, see docs/guide.md)
39
+ stb.estimate_text("Hello", 16) # text size with no font file at all
40
+
41
+ packed = stb.zlib_compress(data) # zlib streams: the compressor that writes PNG
42
+ data = stb.zlib_decompress(packed, max_bytes=64 << 20) # output is bounded: a zip bomb is a LimitError
43
+ ```
44
+
45
+ ## C++ with CMake
46
+
47
+ ```cmake
48
+ include(FetchContent)
49
+ FetchContent_Declare(libstb GIT_REPOSITORY https://github.com/MohammadRaziei/libstb.git GIT_TAG master)
50
+ FetchContent_MakeAvailable(libstb)
51
+
52
+ target_link_libraries(my_app PRIVATE libstb::core) # CMake 3.21+, C++17
53
+ ```
54
+
55
+ `find_package(libstb CONFIG)` works too, after `cmake --install` or after `pip install libstb`
56
+ (`stb.get_cmake_dir()` gives the config directory).
57
+
58
+ ```cpp
59
+ #include <stb.h>
60
+
61
+ stb::image img = stb::image::open("photo.jpg"); // throws stb::error subclasses
62
+ stb::image small = img.resize(320, 240, "cubic"); // or stb::resize_filter::mitchell
63
+ small.write("small.png"); // format from the extension
64
+ small.write_jpg("small.jpg", 80);
65
+ std::vector<std::uint8_t> bytes = small.to_png(9);
66
+
67
+ stb::font f = stb::font::open("font.ttf"); // cheap to copy, thread-safe
68
+ stb::image labeled = f.draw_text(img, "Hello", 32, 10, 10, stb::color("white"));
69
+ stb::image centred = f.draw_text(img, "Hello", 32, img.width() / 2, 10, stb::color(), stb::text_align::center);
70
+ stb::text_bitmap t = f.render("Hello", 32);
71
+ stb::text_size est = stb::estimate_text("Hello", 16); // no font file needed
72
+
73
+ std::vector<std::uint8_t> z = stb::zlib_compress(bytes); // <stb/zlib.hpp>, level 0..9 like zlib
74
+ std::vector<std::uint8_t> back = stb::zlib_decompress(z, 64u << 20); // throws limit_error past max_bytes
75
+ ```
76
+
77
+ The namespace and headers are `stb` (`<stb.h>`, `<stb/*.hpp>`); the CMake target
78
+ (`libstb::core`) and the Python package (`libstb`) keep the project name. No stb header is
79
+ ever included from a public header, and stb symbols do not leak from the library, so it links
80
+ next to your own copy of stb.
81
+
82
+ ## What is from stb, and what is not
83
+
84
+ libstb uses these stb modules, vendored in `src/third_party/` (no submodules):
85
+
86
+ | stb module | used for |
87
+ | :--- | :--- |
88
+ | `stb_image` | decoding (PNG, JPEG, BMP, TGA, GIF, ...) |
89
+ | `stb_image_write` | encoding PNG, JPEG, BMP, TGA |
90
+ | `stb_image_resize2` | resizing, all filters |
91
+ | `stb_truetype` | font metrics, glyphs, text rendering, atlases |
92
+ | `stb_rect_pack` | packing glyphs into an atlas |
93
+
94
+ What we changed on top, for speed and for a safer, more convenient API:
95
+
96
+ - **Faster encoders.** `stb_image_write.h` carries two local patches: a new PNG deflate (4-byte
97
+ hash chains, lazy matching, dynamic Huffman blocks: within about 1% of zlib level 6 in size at
98
+ roughly twice its speed) and a faster JPEG encoder (buffered bit writer, vectorisable DCT, SSE2 colour
99
+ conversion). The other stb headers are byte-for-byte upstream.
100
+ - **SIMD where it pays.** `convert`, `composite` and `flatten` have AVX2, baseline SIMD and
101
+ scalar builds that give identical results; the best one is picked at run time.
102
+ - **No hidden copies.** Decoded buffers are adopted, not copied; arrays and DLPack tensors are
103
+ shared when they can be; Python calls release the GIL.
104
+ - **zlib as an API.** The PNG compressor and stb's inflate are exposed as
105
+ `zlib_compress` and `zlib_decompress` (any bytes-like object in, bytes out), with a bounded
106
+ output so a zip bomb is a `LimitError`. They interoperate with python's `zlib`. Compression
107
+ was 1.2x to 1.9x faster than zlib level 6 at 0.4% to 3.3% larger output on our samples;
108
+ decompression is stb_image's and is **not** faster than zlib (about 2.5x slower on very
109
+ compressible text), so use zlib if inflate speed is what you need.
110
+ - **Editing stb does not have.** Crop, pad, flips, rotation, thumbnail, channel conversion,
111
+ alpha compositing, EXIF orientation, resize filters by name, and a font-free text size
112
+ estimate.
113
+ - **Safety.** Size limits are checked from the header before any pixel memory is allocated,
114
+ errors are typed (`stb.Error` with `DecodeError`, `EncodeError`, `LimitError`), and EXIF
115
+ parsing checks every offset. stb_truetype is still not safe on untrusted fonts: load only
116
+ fonts you trust.
117
+
118
+ Performance numbers against Pillow and OpenCV, including where libstb is slower (JPEG
119
+ encoding is one), are in [`benchmarks/`](benchmarks/README.md). They depend on the machine, so
120
+ run them on yours.
121
+
122
+ ## More
123
+
124
+ - [`docs/guide.md`](docs/guide.md): the full reference (every call, SIMD, EXIF, DLPack, Pillow,
125
+ errors, design and source layout).
126
+ - `docs/`: the Sphinx (Python) and Doxygen (C++) sources of the documentation site.
127
+ - [`CHANGELOG.md`](CHANGELOG.md).
128
+
129
+ ## Build and test
130
+
131
+ ```sh
132
+ pip install -r requirements-dev.txt
133
+ cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release
134
+ cmake --build build
135
+ ctest --test-dir build --output-on-failure
136
+ ```
137
+
138
+ Options: `STB_BUILD_TESTS`, `STB_BUILD_PYTHON`, `STB_BUILD_DOCS`. Targets: `stb_core`,
139
+ `stb_test`, `stb_docs`, `stb_benchmark`.
140
+
141
+ ## License
142
+
143
+ MIT for libstb. The vendored stb headers are MIT / public domain (see
144
+ `src/third_party/README.md`).
@@ -9,7 +9,7 @@ project(LibstbBenchmarks LANGUAGES NONE)
9
9
  # https://github.com/MohammadRaziei/novasvg/tree/master/benchmarks.
10
10
  #
11
11
  # cmake -S . -B build
12
- # cmake --build build --target libstb_benchmark
12
+ # cmake --build build --target stb_benchmark
13
13
  #
14
14
  # Two folders, nothing else is ever written:
15
15
  #
@@ -41,7 +41,7 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FetchRealCorpus.cmake")
41
41
  add_subdirectory(python)
42
42
  add_subdirectory(report)
43
43
 
44
- add_custom_target(libstb_benchmark
45
- COMMENT "libstb_benchmark: running the full benchmark suite and building the report"
44
+ add_custom_target(stb_benchmark
45
+ COMMENT "stb_benchmark: running the full benchmark suite and building the report"
46
46
  )
47
- add_dependencies(libstb_benchmark libstb_bench_report)
47
+ add_dependencies(stb_benchmark stb_bench_report)