libstb 0.3.0__tar.gz → 0.5.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 (112) hide show
  1. {libstb-0.3.0 → libstb-0.5.0}/CMakeLists.txt +6 -0
  2. {libstb-0.3.0 → libstb-0.5.0}/PKG-INFO +46 -7
  3. {libstb-0.3.0 → libstb-0.5.0}/README.md +41 -5
  4. libstb-0.5.0/benchmarks/CMakeLists.txt +40 -0
  5. libstb-0.5.0/benchmarks/README.md +306 -0
  6. libstb-0.5.0/benchmarks/cmake/Download.cmake +26 -0
  7. libstb-0.5.0/benchmarks/cmake/FetchRealCorpus.cmake +76 -0
  8. libstb-0.5.0/benchmarks/corpus/.gitignore +2 -0
  9. libstb-0.5.0/benchmarks/python/CMakeLists.txt +261 -0
  10. libstb-0.5.0/benchmarks/python/bench_fonts.py +131 -0
  11. libstb-0.5.0/benchmarks/python/bench_op_memory_driver.py +87 -0
  12. libstb-0.5.0/benchmarks/python/bench_op_memory_one.py +68 -0
  13. libstb-0.5.0/benchmarks/python/bench_scaling.py +118 -0
  14. libstb-0.5.0/benchmarks/python/bench_sizes.py +93 -0
  15. libstb-0.5.0/benchmarks/python/bench_throughput.py +122 -0
  16. libstb-0.5.0/benchmarks/python/corpus.py +231 -0
  17. libstb-0.5.0/benchmarks/python/real_corpus_manifest.py +49 -0
  18. libstb-0.5.0/benchmarks/python/requirements.txt +11 -0
  19. libstb-0.5.0/benchmarks/python/runners.py +415 -0
  20. libstb-0.5.0/benchmarks/python/system_info.py +72 -0
  21. libstb-0.5.0/benchmarks/python/verify.py +181 -0
  22. libstb-0.5.0/benchmarks/report/CMakeLists.txt +95 -0
  23. libstb-0.5.0/benchmarks/report/generate_report.py +637 -0
  24. libstb-0.5.0/benchmarks/report/template.html.jinja2 +633 -0
  25. libstb-0.5.0/examples/cpp/.gitignore +8 -0
  26. libstb-0.5.0/examples/notebooks/.gitignore +5 -0
  27. libstb-0.5.0/examples/notebooks/01_getting_started.ipynb +210 -0
  28. libstb-0.5.0/examples/notebooks/02_resize_filters.ipynb +144 -0
  29. libstb-0.5.0/examples/notebooks/03_font_rendering.ipynb +127 -0
  30. libstb-0.5.0/examples/notebooks/requirements.txt +4 -0
  31. libstb-0.5.0/examples/python/.gitignore +4 -0
  32. libstb-0.5.0/examples/python/01_open_and_inspect.py +51 -0
  33. libstb-0.5.0/examples/python/02_encode_formats.py +47 -0
  34. libstb-0.5.0/examples/python/03_resize_filters.py +48 -0
  35. libstb-0.5.0/examples/python/04_numpy_interop.py +49 -0
  36. libstb-0.5.0/examples/python/05_font_render.py +55 -0
  37. libstb-0.5.0/examples/python/06_imread_imwrite.py +37 -0
  38. libstb-0.5.0/examples/python/07_dlpack.py +76 -0
  39. libstb-0.5.0/examples/python/requirements.txt +3 -0
  40. {libstb-0.3.0 → libstb-0.5.0}/include/stb.h +1 -1
  41. {libstb-0.3.0 → libstb-0.5.0}/pyproject.toml +3 -2
  42. {libstb-0.3.0 → libstb-0.5.0}/requirements-dev.txt +1 -0
  43. {libstb-0.3.0 → libstb-0.5.0}/src/bindings/python/bind_font.cpp +7 -0
  44. {libstb-0.3.0 → libstb-0.5.0}/src/bindings/python/bind_image.cpp +122 -5
  45. libstb-0.5.0/src/bindings/python/libstb/__init__.py +100 -0
  46. {libstb-0.3.0 → libstb-0.5.0}/src/bindings/python/libstb/font.py +3 -0
  47. {libstb-0.3.0 → libstb-0.5.0}/src/core/font.cpp +84 -11
  48. libstb-0.5.0/src/third_party/README.md +36 -0
  49. {libstb-0.3.0 → libstb-0.5.0}/src/third_party/stb/stb_image_write.h +674 -287
  50. {libstb-0.3.0 → libstb-0.5.0}/tests/cpp/test_encode.cpp +53 -0
  51. {libstb-0.3.0 → libstb-0.5.0}/tests/python/CMakeLists.txt +2 -2
  52. libstb-0.5.0/tests/python/test_dlpack.py +176 -0
  53. {libstb-0.3.0 → libstb-0.5.0}/tests/python/test_encode.py +10 -10
  54. {libstb-0.3.0 → libstb-0.5.0}/tests/python/test_errors.py +2 -2
  55. {libstb-0.3.0 → libstb-0.5.0}/tests/python/test_font.py +6 -6
  56. libstb-0.5.0/tests/python/test_functional.py +101 -0
  57. {libstb-0.3.0 → libstb-0.5.0}/tests/python/test_image.py +22 -22
  58. libstb-0.5.0/tests/python/test_lossless_exact.py +144 -0
  59. libstb-0.5.0/tests/python/test_lossy_tolerance.py +206 -0
  60. libstb-0.5.0/tests/python/test_no_numpy.py +103 -0
  61. {libstb-0.3.0 → libstb-0.5.0}/tests/python/test_oop.py +32 -32
  62. libstb-0.5.0/tests/python/test_pillow_parity.py +281 -0
  63. {libstb-0.3.0 → libstb-0.5.0}/tests/python/test_resizer.py +18 -18
  64. libstb-0.5.0/tests/python/tolerances.py +14 -0
  65. libstb-0.5.0/tests/tools/jpeg_vs_upstream.py +77 -0
  66. libstb-0.5.0/tests/tools/zlib_fuzz.py +71 -0
  67. libstb-0.3.0/src/bindings/python/libstb/__init__.py +0 -62
  68. libstb-0.3.0/src/third_party/README.md +0 -16
  69. {libstb-0.3.0 → libstb-0.5.0}/.github/workflows/cmake.yml +0 -0
  70. {libstb-0.3.0 → libstb-0.5.0}/.github/workflows/orchestrator.yml +0 -0
  71. {libstb-0.3.0 → libstb-0.5.0}/.github/workflows/release_template.md +0 -0
  72. {libstb-0.3.0 → libstb-0.5.0}/.github/workflows/wheels.yml +0 -0
  73. {libstb-0.3.0 → libstb-0.5.0}/.gitignore +0 -0
  74. {libstb-0.3.0 → libstb-0.5.0}/LICENSE.txt +0 -0
  75. {libstb-0.3.0 → libstb-0.5.0}/cmake/DynamicVersion.cmake +0 -0
  76. {libstb-0.3.0 → libstb-0.5.0}/cmake/Optimize.cmake +0 -0
  77. {libstb-0.3.0 → libstb-0.5.0}/cmake/Startup.cmake +0 -0
  78. {libstb-0.3.0 → libstb-0.5.0}/cmake/libstbConfig.cmake.in +0 -0
  79. {libstb-0.3.0 → libstb-0.5.0}/include/stb/error.hpp +0 -0
  80. {libstb-0.3.0 → libstb-0.5.0}/include/stb/font.hpp +0 -0
  81. {libstb-0.3.0 → libstb-0.5.0}/include/stb/image.hpp +0 -0
  82. {libstb-0.3.0 → libstb-0.5.0}/include/stb/resizer.hpp +0 -0
  83. {libstb-0.3.0 → libstb-0.5.0}/include/stb/utf8.hpp +0 -0
  84. {libstb-0.3.0 → libstb-0.5.0}/src/bindings/python/CMakeLists.txt +0 -0
  85. {libstb-0.3.0 → libstb-0.5.0}/src/bindings/python/bind_resizer.cpp +0 -0
  86. {libstb-0.3.0 → libstb-0.5.0}/src/bindings/python/binding.cpp +0 -0
  87. {libstb-0.3.0 → libstb-0.5.0}/src/bindings/python/binding.hpp +0 -0
  88. {libstb-0.3.0 → libstb-0.5.0}/src/bindings/python/libstb/image.py +0 -0
  89. {libstb-0.3.0 → libstb-0.5.0}/src/core/file.hpp +0 -0
  90. {libstb-0.3.0 → libstb-0.5.0}/src/core/image.cpp +0 -0
  91. {libstb-0.3.0 → libstb-0.5.0}/src/core/resizer.cpp +0 -0
  92. {libstb-0.3.0 → libstb-0.5.0}/src/core/utf8.cpp +0 -0
  93. {libstb-0.3.0 → libstb-0.5.0}/src/third_party/stb/stb_image.h +0 -0
  94. {libstb-0.3.0 → libstb-0.5.0}/src/third_party/stb/stb_image_resize2.h +0 -0
  95. {libstb-0.3.0 → libstb-0.5.0}/src/third_party/stb/stb_rect_pack.h +0 -0
  96. {libstb-0.3.0 → libstb-0.5.0}/src/third_party/stb/stb_truetype.h +0 -0
  97. {libstb-0.3.0 → libstb-0.5.0}/tests/CMakeLists.txt +0 -0
  98. {libstb-0.3.0 → libstb-0.5.0}/tests/cmake/CMakeLists.txt +0 -0
  99. {libstb-0.3.0 → libstb-0.5.0}/tests/cmake/consumer_project/CMakeLists.txt +0 -0
  100. {libstb-0.3.0 → libstb-0.5.0}/tests/cmake/consumer_project/main.cpp +0 -0
  101. {libstb-0.3.0 → libstb-0.5.0}/tests/cmake/run_consumer_test.cmake +0 -0
  102. {libstb-0.3.0 → libstb-0.5.0}/tests/cpp/CMakeLists.txt +0 -0
  103. {libstb-0.3.0 → libstb-0.5.0}/tests/cpp/test_common.hpp +0 -0
  104. {libstb-0.3.0 → libstb-0.5.0}/tests/cpp/test_font.cpp +0 -0
  105. {libstb-0.3.0 → libstb-0.5.0}/tests/cpp/test_image.cpp +0 -0
  106. {libstb-0.3.0 → libstb-0.5.0}/tests/cpp/test_resizer.cpp +0 -0
  107. {libstb-0.3.0 → libstb-0.5.0}/tests/cpp/test_utf8.cpp +0 -0
  108. {libstb-0.3.0 → libstb-0.5.0}/tests/data/libstb-test.ttf +0 -0
  109. {libstb-0.3.0 → libstb-0.5.0}/tests/data/make_test_font.py +0 -0
  110. {libstb-0.3.0 → libstb-0.5.0}/tests/utest/utest.h +0 -0
  111. {libstb-0.3.0 → libstb-0.5.0}/tests/utest/utest_main.cxx +0 -0
  112. {libstb-0.3.0 → libstb-0.5.0}/version.py +0 -0
@@ -67,6 +67,12 @@ target_compile_options(libstb_core PRIVATE
67
67
  $<$<CXX_COMPILER_ID:MSVC>:/W4 /EHsc>
68
68
  $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic>
69
69
  )
70
+ # -fno-trapping-math: lets GCC/Clang vectorize float->int conversions in the JPEG encoder's
71
+ # quantization (about 2x faster JPEG). It only means FP operations are not required to
72
+ # raise hardware traps (nothing here enables or reads them); results are unchanged.
73
+ target_compile_options(libstb_core PRIVATE
74
+ $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-fno-trapping-math>
75
+ )
70
76
  apply_optimization_flags(libstb_core)
71
77
 
72
78
  # --- install (find_package(libstb) -> libstb::core) ---
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: libstb
3
- Version: 0.3.0
3
+ Version: 0.5.0
4
4
  Summary: Python bindings for the stb single-header libraries (image io, resize, fonts). Zero system dependencies.
5
5
  Author-Email: Mohammad Raziei <mohammadraziei1375@gmail.com>
6
6
  License: MIT
@@ -18,16 +18,27 @@ Classifier: Programming Language :: Python :: 3.13
18
18
  Project-URL: Homepage, https://github.com/MohammadRaziei/libstb
19
19
  Project-URL: Bug Tracker, https://github.com/MohammadRaziei/libstb/issues
20
20
  Requires-Python: >=3.9
21
- Requires-Dist: numpy
21
+ Provides-Extra: numpy
22
+ Requires-Dist: numpy; extra == "numpy"
22
23
  Provides-Extra: test
23
24
  Requires-Dist: pytest; extra == "test"
25
+ Requires-Dist: numpy; extra == "test"
26
+ Requires-Dist: pillow; extra == "test"
24
27
  Description-Content-Type: text/markdown
25
28
 
26
29
  # libstb
27
30
 
28
31
  Python bindings for the [stb](https://github.com/nothings/stb) single-header
29
32
  libraries. `pip install libstb` and you have image/font processing with **no
30
- system dependencies**. The C++ library is usable from CMake too.
33
+ system dependencies and no Python dependencies**. The C++ library is usable from
34
+ CMake too.
35
+
36
+ numpy is optional: `pip install "libstb[numpy]"` if you want `img.numpy()` /
37
+ `libstb.imread()`. It is imported only when one of those is first
38
+ used, never by `import libstb`, and without it they raise an `ImportError` that
39
+ says so. Everything else works without numpy, including `Image(array)` from any
40
+ buffer (a `memoryview`, `array.array`, a `bytearray`, a PIL-exported buffer...),
41
+ and `img.tobytes()` and `memoryview(img)` give you the pixels with no numpy at all.
31
42
 
32
43
  | module | status |
33
44
  | :--- | :--- |
@@ -46,6 +57,10 @@ import libstb
46
57
  img = libstb.Image.open("photo.png") # or bytes; also: channels=4, flip=True
47
58
  img.width, img.height, img.channels # 640, 480, 3
48
59
  img.numpy() # uint8 pixels (H, W, C), no copy; np.asarray(img) works too
60
+ np.from_dlpack(img) # DLPack: also torch/jax/cupy.from_dlpack(img), zero-copy
61
+ libstb.Image.from_dlpack(tensor) # and back: a torch/jax/cupy/numpy uint8 array -> Image
62
+ pixels = libstb.imread("photo.png") # just the ndarray (same options as Image.open)
63
+ libstb.imwrite("out.jpg", pixels, quality=80) # an ndarray or an Image; format from the extension
49
64
  libstb.ImageInfo.read("photo.png") # header only: (width, height, channels)
50
65
  libstb.Image(np.zeros((8, 8, 4), np.uint8)) # from your own uint8 array (no copy, see below)
51
66
  img.copy() # an independent image (deep copy)
@@ -67,8 +82,7 @@ font.metrics(32), font.advance("A", 32), font.kerning("A", "V", 32), font.measur
67
82
  font.render_glyph("A", 32) # Glyph(bitmap, x_offset, y_offset, advance)
68
83
  atlas = font.make_atlas("ABCabc123", 32, 256, 256) # Atlas: .image and atlas["A"] -> AtlasGlyph
69
84
 
70
- libstb.load("photo.png") # shortcut: Image.open(...).array
71
- libstb.info("photo.png") # shortcut: ImageInfo.read(...)
85
+ libstb.iminfo("photo.png") # shortcut: ImageInfo.read(...)
72
86
  ```
73
87
 
74
88
  **Encoding.** Every format has a pair of methods with its own settings, all
@@ -80,6 +94,13 @@ truncated file). `write(path)` is the shortcut: it picks the format from the
80
94
  extension (`.png .jpg .jpeg .bmp .tga`, case-insensitive; `ValueError` for
81
95
  anything else) and uses the defaults. For other settings call `write_*`.
82
96
 
97
+ `libstb.imwrite(path, image, *, quality=None, compression=None, rle=None)` is
98
+ the functional form: it takes an `Image` or a uint8 array, picks the format
99
+ from the extension, and passes the options that format has (`quality` for jpg,
100
+ `compression` for png, `rle` for tga). An option the format does not have is a
101
+ `ValueError`, not silently ignored. `libstb.imread(source, *, channels, flip,
102
+ max_bytes)` is its counterpart and returns an ndarray.
103
+
83
104
  **Resize filters by name.** `Image.resize(w, h, x)` and `Resizer(x)` accept a
84
105
  `Resizer.Filter`, or a case-insensitive name (`-` and space count as `_`). Any
85
106
  other option (`edge`, `srgb`, `max_bytes`) is a keyword of `Resizer(...)`.
@@ -112,8 +133,26 @@ exceed `max_bytes` (default 512 MiB) are rejected from the header, before any
112
133
  pixel memory is allocated.
113
134
 
114
135
  `libstb.Image` is `stb::image` itself, not a wrapper: `open`, `resize`, `to_*` and
115
- `write*` are the C++ members, run without the GIL. `img.array` / `np.asarray(img)`
116
- are numpy views of its pixels (kept alive by the view).
136
+ `write*` are the C++ members, run without the GIL. `img.numpy()` / `np.asarray(img)`
137
+ are numpy views of its pixels (kept alive by the view); `memoryview(img)` is the
138
+ same zero-copy view as a plain 3-D `memoryview` (numpy reads it too), and
139
+ `img.tobytes()` is a copy, both without numpy.
140
+
141
+ **DLPack.** `Image` implements `__dlpack__` / `__dlpack_device__`, so
142
+ `np.from_dlpack(img)`, `torch.from_dlpack(img)`, `jax.numpy.from_dlpack(img)`
143
+ and `cupy.from_dlpack(img)` share the pixels with no copy and no framework
144
+ import on libstb's side. The layout is fixed: `uint8`, shape `(height, width,
145
+ channels)`, on the CPU (`dl_device` other than the CPU is a `BufferError`).
146
+ The view keeps the image alive. It is writable with numpy 2.1 or newer (older
147
+ numpy, the last one on Python 3.9 being 2.0.2, imports every DLPack view
148
+ read-only and has no `copy=` argument; `img.numpy()` is always writable).
149
+ Asking for `copy=True` gives an independent copy. The other way round, `libstb.Image.from_dlpack(x)` takes any
150
+ DLPack object holding `uint8` pixels of shape `(H, W)` or `(H, W, 1..4)` (a
151
+ torch, jax, cupy or numpy array, another `Image`): a writable C-contiguous CPU
152
+ array is shared, anything else is copied, and `copy=True` always copies.
153
+ (`Image(x)` accepts the same objects; `from_dlpack` additionally insists on
154
+ `__dlpack__`, so a stray `bytes` is a clear `TypeError`.) For a different layout or dtype (CHW, float32), convert on
155
+ the framework side, e.g. `torch.from_dlpack(img).permute(2, 0, 1).float() / 255`.
117
156
 
118
157
  Pixels are never copied behind your back. `Image(array)` uses a writable,
119
158
  C-contiguous uint8 array in place, so the image and the array share their
@@ -2,7 +2,15 @@
2
2
 
3
3
  Python bindings for the [stb](https://github.com/nothings/stb) single-header
4
4
  libraries. `pip install libstb` and you have image/font processing with **no
5
- system dependencies**. The C++ library is usable from CMake too.
5
+ system dependencies and no Python dependencies**. The C++ library is usable from
6
+ CMake too.
7
+
8
+ numpy is optional: `pip install "libstb[numpy]"` if you want `img.numpy()` /
9
+ `libstb.imread()`. It is imported only when one of those is first
10
+ used, never by `import libstb`, and without it they raise an `ImportError` that
11
+ says so. Everything else works without numpy, including `Image(array)` from any
12
+ buffer (a `memoryview`, `array.array`, a `bytearray`, a PIL-exported buffer...),
13
+ and `img.tobytes()` and `memoryview(img)` give you the pixels with no numpy at all.
6
14
 
7
15
  | module | status |
8
16
  | :--- | :--- |
@@ -21,6 +29,10 @@ import libstb
21
29
  img = libstb.Image.open("photo.png") # or bytes; also: channels=4, flip=True
22
30
  img.width, img.height, img.channels # 640, 480, 3
23
31
  img.numpy() # uint8 pixels (H, W, C), no copy; np.asarray(img) works too
32
+ np.from_dlpack(img) # DLPack: also torch/jax/cupy.from_dlpack(img), zero-copy
33
+ libstb.Image.from_dlpack(tensor) # and back: a torch/jax/cupy/numpy uint8 array -> Image
34
+ pixels = libstb.imread("photo.png") # just the ndarray (same options as Image.open)
35
+ libstb.imwrite("out.jpg", pixels, quality=80) # an ndarray or an Image; format from the extension
24
36
  libstb.ImageInfo.read("photo.png") # header only: (width, height, channels)
25
37
  libstb.Image(np.zeros((8, 8, 4), np.uint8)) # from your own uint8 array (no copy, see below)
26
38
  img.copy() # an independent image (deep copy)
@@ -42,8 +54,7 @@ font.metrics(32), font.advance("A", 32), font.kerning("A", "V", 32), font.measur
42
54
  font.render_glyph("A", 32) # Glyph(bitmap, x_offset, y_offset, advance)
43
55
  atlas = font.make_atlas("ABCabc123", 32, 256, 256) # Atlas: .image and atlas["A"] -> AtlasGlyph
44
56
 
45
- libstb.load("photo.png") # shortcut: Image.open(...).array
46
- libstb.info("photo.png") # shortcut: ImageInfo.read(...)
57
+ libstb.iminfo("photo.png") # shortcut: ImageInfo.read(...)
47
58
  ```
48
59
 
49
60
  **Encoding.** Every format has a pair of methods with its own settings, all
@@ -55,6 +66,13 @@ truncated file). `write(path)` is the shortcut: it picks the format from the
55
66
  extension (`.png .jpg .jpeg .bmp .tga`, case-insensitive; `ValueError` for
56
67
  anything else) and uses the defaults. For other settings call `write_*`.
57
68
 
69
+ `libstb.imwrite(path, image, *, quality=None, compression=None, rle=None)` is
70
+ the functional form: it takes an `Image` or a uint8 array, picks the format
71
+ from the extension, and passes the options that format has (`quality` for jpg,
72
+ `compression` for png, `rle` for tga). An option the format does not have is a
73
+ `ValueError`, not silently ignored. `libstb.imread(source, *, channels, flip,
74
+ max_bytes)` is its counterpart and returns an ndarray.
75
+
58
76
  **Resize filters by name.** `Image.resize(w, h, x)` and `Resizer(x)` accept a
59
77
  `Resizer.Filter`, or a case-insensitive name (`-` and space count as `_`). Any
60
78
  other option (`edge`, `srgb`, `max_bytes`) is a keyword of `Resizer(...)`.
@@ -87,8 +105,26 @@ exceed `max_bytes` (default 512 MiB) are rejected from the header, before any
87
105
  pixel memory is allocated.
88
106
 
89
107
  `libstb.Image` is `stb::image` itself, not a wrapper: `open`, `resize`, `to_*` and
90
- `write*` are the C++ members, run without the GIL. `img.array` / `np.asarray(img)`
91
- are numpy views of its pixels (kept alive by the view).
108
+ `write*` are the C++ members, run without the GIL. `img.numpy()` / `np.asarray(img)`
109
+ are numpy views of its pixels (kept alive by the view); `memoryview(img)` is the
110
+ same zero-copy view as a plain 3-D `memoryview` (numpy reads it too), and
111
+ `img.tobytes()` is a copy, both without numpy.
112
+
113
+ **DLPack.** `Image` implements `__dlpack__` / `__dlpack_device__`, so
114
+ `np.from_dlpack(img)`, `torch.from_dlpack(img)`, `jax.numpy.from_dlpack(img)`
115
+ and `cupy.from_dlpack(img)` share the pixels with no copy and no framework
116
+ import on libstb's side. The layout is fixed: `uint8`, shape `(height, width,
117
+ channels)`, on the CPU (`dl_device` other than the CPU is a `BufferError`).
118
+ The view keeps the image alive. It is writable with numpy 2.1 or newer (older
119
+ numpy, the last one on Python 3.9 being 2.0.2, imports every DLPack view
120
+ read-only and has no `copy=` argument; `img.numpy()` is always writable).
121
+ Asking for `copy=True` gives an independent copy. The other way round, `libstb.Image.from_dlpack(x)` takes any
122
+ DLPack object holding `uint8` pixels of shape `(H, W)` or `(H, W, 1..4)` (a
123
+ torch, jax, cupy or numpy array, another `Image`): a writable C-contiguous CPU
124
+ array is shared, anything else is copied, and `copy=True` always copies.
125
+ (`Image(x)` accepts the same objects; `from_dlpack` additionally insists on
126
+ `__dlpack__`, so a stray `bytes` is a clear `TypeError`.) For a different layout or dtype (CHW, float32), convert on
127
+ the framework side, e.g. `torch.from_dlpack(img).permute(2, 0, 1).float() / 255`.
92
128
 
93
129
  Pixels are never copied behind your back. `Image(array)` uses a writable,
94
130
  C-contiguous uint8 array in place, so the image and the array share their
@@ -0,0 +1,40 @@
1
+ cmake_minimum_required(VERSION 3.18)
2
+ project(LibstbBenchmarks LANGUAGES NONE)
3
+
4
+ # This whole directory is self-contained and independent of the parent
5
+ # libstb source tree: it installs libstb itself from GitHub
6
+ # (pip install git+https://...), not from ../src, so it can be copied
7
+ # out and run on its own. Same convention as
8
+ # https://github.com/MohammadRaziei/pygixml/tree/main/benchmarks and
9
+ # https://github.com/MohammadRaziei/ctoon/tree/main/benchmarks.
10
+ #
11
+ # cmake -S . -B build
12
+ # cmake --build build --target libstb_benchmark
13
+ #
14
+ # See README.md in this directory for the full rundown, and every
15
+ # individual target below for what it does on its own
16
+ # (`cmake --build build --target help` lists them all). Nothing here
17
+ # writes outside of results/ (and the gitignored corpus/ cache).
18
+ #
19
+ # To benchmark a local, not-yet-published patch instead of whatever is
20
+ # on GitHub, override this at configure time rather than editing it
21
+ # here, e.g.:
22
+ # cmake -S . -B build -DLIBSTB_BENCH_GITHUB_URL=/path/to/local/checkout
23
+ set(LIBSTB_BENCH_GITHUB_URL
24
+ "git+https://github.com/MohammadRaziei/libstb.git"
25
+ CACHE STRING "Where to install libstb itself from (a fresh git checkout, not the local source tree)")
26
+
27
+ set(LIBSTB_BENCH_RESULTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/results"
28
+ CACHE PATH "Where the final standalone report.html is written: the one artifact meant to be committed")
29
+
30
+ find_package(Python3 COMPONENTS Interpreter REQUIRED)
31
+
32
+ include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/FetchRealCorpus.cmake")
33
+
34
+ add_subdirectory(python)
35
+ add_subdirectory(report)
36
+
37
+ add_custom_target(libstb_benchmark
38
+ COMMENT "libstb_benchmark: running the full benchmark suite and building the report"
39
+ )
40
+ add_dependencies(libstb_benchmark libstb_bench_report)
@@ -0,0 +1,306 @@
1
+ # libstb benchmarks
2
+
3
+ Self-contained and independent of the rest of this repository: this
4
+ directory installs libstb itself fresh from GitHub
5
+ (`pip install git+https://github.com/MohammadRaziei/libstb.git`), not
6
+ from `../src`, and manages its own virtualenv. You can copy this
7
+ `benchmarks/` directory out on its own and it will still work: same
8
+ convention as
9
+ [pygixml's benchmark suite](https://github.com/MohammadRaziei/pygixml/tree/main/benchmarks)
10
+ and [ctoon's](https://github.com/MohammadRaziei/ctoon/tree/main/benchmarks),
11
+ by the same author, which this one is modeled on.
12
+
13
+ ## Running it
14
+
15
+ ```bash
16
+ cd benchmarks
17
+ cmake -S . -B build
18
+ cmake --build build --target libstb_benchmark
19
+ ```
20
+
21
+ That's the one target you need: it pulls in every benchmark, in the
22
+ right dependency order, and finishes by writing
23
+ **`results/report.html`**: a single, standalone HTML file (Chart.js
24
+ and every raw JSON result are embedded in it) with a "download JSON"
25
+ button per dataset. Open it in a browser; nothing else is required:
26
+ no server, no network, no sibling files.
27
+
28
+ `results/` is the **only** thing meant to be committed from this whole
29
+ build: everything else (the venv, the corpus, per-run JSON) lives
30
+ under `build/` and is disposable.
31
+
32
+ The first configure creates a venv and builds libstb from source into
33
+ it (scikit-build-core + nanobind), so it needs a C++17 compiler and
34
+ takes a few minutes. Later runs reuse the venv.
35
+
36
+ ### Running one piece at a time
37
+
38
+ Every operation is its own target, independently runnable
39
+ (`cmake --build build --target <name>`):
40
+
41
+ | Target | What it does |
42
+ |---|---|
43
+ | `libstb_bench_venv` | Create the venv; install numpy/Pillow/OpenCV/imageio/scikit-image/pip-size/jinja2 + libstb itself (from git) |
44
+ | `libstb_bench_corpus` | Generate the synthetic multi-genre corpus |
45
+ | `libstb_bench_real_corpus` | Convert the real-world photographs (downloaded at configure time) into every format, same manifest shape |
46
+ | `libstb_bench_verify` | Check that every (operation, library) pair produces correct output, before anything is timed |
47
+ | `libstb_bench_sizes` | Real install footprint via `pip-size` |
48
+ | `libstb_bench_throughput` | Speed: decode / encode / resize, every library, every corpus entry |
49
+ | `libstb_bench_throughput_memory` | Peak memory for the same operations, libraries and entries |
50
+ | `libstb_bench_scaling` | Throughput vs. image size, 0.016 to 16.8 megapixels |
51
+ | `libstb_bench_fonts` | `Font` (stb_truetype) vs. Pillow's FreeType binding |
52
+ | `libstb_bench_system_info` | Record CPU / RAM / OS / Python |
53
+ | `libstb_bench_report` | Render `results/report.html` from all of the above |
54
+
55
+ The scripts also run by hand, from `python/`, on any machine that has
56
+ the requirements installed:
57
+
58
+ ```bash
59
+ python corpus.py /tmp/corpus # writes the images + manifest.json
60
+ python verify.py # exits non-zero if any output is wrong
61
+ python bench_throughput.py /tmp/corpus/manifest.json out.json --repeats 5
62
+ python bench_fonts.py DejaVuSans.ttf fonts.json
63
+ ```
64
+
65
+ ### Options
66
+
67
+ ```bash
68
+ # use a different libstb source (a branch, or a local checkout) instead
69
+ # of the default main-branch GitHub install
70
+ cmake -S benchmarks -B benchmarks/build -DLIBSTB_BENCH_GITHUB_URL=/path/to/local/checkout
71
+
72
+ # where report.html ends up
73
+ cmake -S benchmarks -B benchmarks/build -DLIBSTB_BENCH_RESULTS_DIR=/some/dir
74
+
75
+ # a noisier machine wants more repeats
76
+ cmake -S benchmarks -B benchmarks/build -DLIBSTB_BENCH_REPEATS=15
77
+ ```
78
+
79
+ ## What's benchmarked, against what
80
+
81
+ Each operation is measured on its own, against the libraries people
82
+ actually reach for, instead of being collapsed into one number.
83
+ `python/runners.py` is the single place that defines what every
84
+ (operation, library) pair does, and its module docstring is the
85
+ authoritative statement of why each pairing is fair. All four scripts
86
+ that measure something (speed, memory, scaling, verification) build
87
+ their callables there, so "decode a PNG with Pillow" means exactly one
88
+ thing across the suite.
89
+
90
+ | Operation | What it measures | Compared against |
91
+ |---|---|---|
92
+ | `info` | width / height / channels from the header, no pixel decoding | Pillow (the only other header-only API) |
93
+ | `decode` | encoded bytes in, uint8 array out | Pillow, OpenCV, imageio |
94
+ | `load_file` | path in, uint8 array out (file I/O included) | Pillow, OpenCV, imageio |
95
+ | `encode_png` / `encode_jpg` / `encode_bmp` / `encode_tga` | raw pixels in, file bytes out, at matched settings | Pillow, OpenCV, imageio |
96
+ | `resize_down_*` / `resize_up_*` | half size / double size; linear, cubic, box filters | Pillow, OpenCV, scikit-image |
97
+ | fonts: `open` / `measure` / `render` | stb_truetype text | Pillow's FreeType binding |
98
+
99
+ Formats covered: png, jpg, bmp, tga. OpenCV has no TGA codec, so it
100
+ has no TGA entries; that is a gap in the report, not a hidden zero.
101
+ scikit-image is benchmarked for resize only, and skipped above 1
102
+ megapixel (a single 2048x2048 cubic upscale takes many seconds and
103
+ hundreds of MB), which the report states rather than hides.
104
+
105
+ ### Corpus
106
+
107
+ Two sources, merged into one manifest shape so every script treats
108
+ them identically:
109
+
110
+ - **Synthetic** (`corpus.py`): four genres, each at 64, 256, 1024 and
111
+ 2048 pixels square, all seeded so every machine sees identical
112
+ pixels. `gradient` (smooth, the best case for PNG and JPEG), `photo`
113
+ (several octaves of value noise plus hard edges plus sensor noise),
114
+ `noise` (uniform random bytes: the worst case for every codec) and
115
+ `graphics` (flat colour blocks and thin lines with a real alpha
116
+ channel: the only genre that exercises the 4-channel paths). A
117
+ corpus that cannot control the *shape* of the data cannot tell why a
118
+ decoder is fast or slow, which is the reason for having genres at
119
+ all.
120
+ - **Real** (`real_corpus_manifest.py`): six real photographs from
121
+ OpenCV's sample data, downloaded at configure time into the
122
+ gitignored `corpus/` folder. They are small (roughly 0.1 to 0.5
123
+ megapixels), so they are there to keep the synthetic images honest,
124
+ not to carry the large-image results.
125
+
126
+ Every image is written in all four formats by **Pillow**, never by
127
+ stb, so the decode benchmarks cannot be biased towards files that one
128
+ specific encoder produced. JPEG and BMP files of the `graphics` genre
129
+ are RGB: neither format has portable alpha, and `verify.py` caught the
130
+ libraries disagreeing about a 32-bit BMP's fourth byte while this
131
+ suite was being written.
132
+
133
+ Nothing about the generators was tuned after seeing numbers: they were
134
+ written once, before any measurement was collected.
135
+
136
+ ### Timing
137
+
138
+ Best (minimum) wall-clock time over 7 repeats per (library, corpus
139
+ entry, operation) cell, one untimed warm-up call first: standard
140
+ practice for micro-benchmarks, since it's the closest a single run gets
141
+ to "no other process happened to interrupt this one."
142
+
143
+ Everything is single-threaded (`cv2.setNumThreads(1)`): libstb and
144
+ Pillow are single-threaded, and a benchmark where one contestant
145
+ quietly uses every core is measuring the machine, not the library.
146
+
147
+ Setup that is not the operation is never timed. `runners.prepare()`
148
+ imports the library, reads the file into memory and builds the
149
+ library's own native image object from raw pixels (for libstb that is
150
+ `Image(array)`, which shares the array's memory; for Pillow,
151
+ `Image.fromarray`, which copies), and returns a zero-argument callable.
152
+ Only that callable is measured. This is deliberate and it cuts both
153
+ ways: a workflow that starts from a NumPy array pays for `fromarray`
154
+ with Pillow and not with libstb, and the benchmark does not count
155
+ either.
156
+
157
+ ### Matched settings, and why output size is reported
158
+
159
+ Encoders are run at explicitly matched settings, never at each
160
+ library's default (the defaults differ on purpose: the PNG zlib level
161
+ is 8 in stb, 6 in Pillow, 1 in OpenCV):
162
+
163
+ - PNG: level 6 everywhere.
164
+ - JPEG: quality 90 everywhere.
165
+ - TGA: uncompressed everywhere (libstb with `rle=False`).
166
+
167
+ Matching the *setting* does not match the *output*. libstb's PNG deflate
168
+ (patched in `stb_image_write.h`) lands within about 1% of zlib's size, but
169
+ its JPEG encoder is faster than upstream stb but still about half the speed of libjpeg-turbo, and its grayscale JPEGs carry three
170
+ components. So each encode operation also records the output size in
171
+ bytes, and the report shows E[size / Pillow's size] next to the speed:
172
+ a faster encoder that writes a bigger file is making a trade, not
173
+ winning.
174
+
175
+ ### Resize: two things that make a naive comparison wrong
176
+
177
+ - **Antialiasing.** libstb, Pillow and scikit-image prefilter when
178
+ shrinking. `cv2.INTER_LINEAR` and `INTER_CUBIC` do not: they are
179
+ faster and they alias. OpenCV's antialiasing counterpart is
180
+ `INTER_AREA`, which is what the box-filter row uses. Read the
181
+ OpenCV linear/cubic downscale numbers with that in mind.
182
+ - **Colour space.** `stb_image_resize2` resizes in linear light by
183
+ default (sRGB-correct). Pillow and OpenCV blend the stored values
184
+ directly. The like-for-like pairing is `Resizer(filter, srgb=False)`
185
+ and that is what is labelled "libstb". The library's real default is
186
+ benchmarked as a separate series, "libstb (sRGB-correct)", so the
187
+ price of correct behaviour is visible instead of hidden.
188
+
189
+ Only 3-channel images take part in resize: alpha means different
190
+ things in different libraries (premultiplied or not), which would not
191
+ be a like-for-like comparison.
192
+
193
+ ### Correctness before speed
194
+
195
+ `verify.py` runs before any timing and stops the build if it fails. On
196
+ small **non-square** images (so a swapped width and height cannot hide)
197
+ it checks that every operation produces the right thing: lossless
198
+ formats must decode to the original pixels *exactly* (channel order
199
+ included), JPEG must agree with Pillow's decode within a normalized mean
200
+ absolute error of 5e-4 (0.1275 of one 8-bit level), encoder output is
201
+ decoded back with Pillow, and resize output must have exactly the
202
+ requested shape and be within 1e-2 of Pillow's result for the same filter
203
+ on a smooth image (OpenCV, which does not antialias, is the worst at
204
+ 6.6e-3). A speed number for an operation
205
+ that produced wrong pixels is worse than no number.
206
+
207
+ ### The memory benchmark
208
+
209
+ `bench_op_memory_driver.py` spawns a fresh Python process per
210
+ (corpus entry, operation, library) via `bench_op_memory_one.py`, and
211
+ records two numbers from that process: the peak RSS before the
212
+ operation (after imports, input loaded, native object built) and after
213
+ it. The **delta** is what the report charts. The absolute peak alone
214
+ would mostly measure how heavy each library is to import (OpenCV alone
215
+ is tens of MB), which says nothing about a 2-megapixel resize.
216
+
217
+ It carries the same one real gotcha as pygixml's memory benchmark: on
218
+ Linux, `ru_maxrss` is **not** reset by `execve()`, so a measurement
219
+ subprocess spawned from a driver that had already inflated itself with
220
+ image data would inherit that inflation as its own reported "peak".
221
+ The driver therefore never opens an image: it reads only the
222
+ manifest's metadata (paths and byte counts) and hands each entry to a
223
+ fresh child.
224
+
225
+ What it does not measure, on purpose: images under 256x256 (the whole
226
+ operation fits inside allocator noise), `info` (it allocates nothing
227
+ worth measuring), and bmp/tga decoding (uncompressed: the memory story
228
+ is the file size). There is no separate size-sweep for memory as there
229
+ is in pygixml: the per-entry measurement already spans 0.065 to 4
230
+ megapixels, and the report plots memory against image size for every
231
+ operation.
232
+
233
+ ## Requirements
234
+
235
+ - CMake >= 3.18
236
+ - Python 3.9+ (used to create the venv; nothing needs to be
237
+ pre-installed into your system Python)
238
+ - A C++17 compiler (libstb is built from source into the venv)
239
+ - Internet access (competitors + libstb from PyPI/GitHub, the real
240
+ photographs, a real TrueType font, and Chart.js are all fetched at
241
+ build time: nothing is vendored in this repository). Every download
242
+ of a corpus file is best-effort: if one fails, the suite continues on
243
+ what it has, and without the font it skips the font benchmark.
244
+
245
+ ## On fairness
246
+
247
+ Every library in these operations does the same class of work: one
248
+ pass over the pixels (decode, encode, resize) or one pass over the
249
+ glyphs (text). There is no O(1)-vs-O(n) story as in pygixml's
250
+ streaming layer, so ratios are fair here, and the report computes
251
+ them: it picks whichever library wins the most comparisons as the
252
+ **reference**, then for every other library computes
253
+ **E[target/ref]**: the ratio on *each* corpus entry individually,
254
+ averaged across entries, ratio-then-average and not
255
+ average-then-ratio.
256
+
257
+ The report writes these definitions as LaTeX formulas (inline, between `\(` and `\)`) and renders
258
+ them in the browser with KaTeX. KaTeX is fetched from the npm registry at build time, like Chart.js,
259
+ and inlined together with the eight fonts it needs, so `report.html` is still one self-contained
260
+ file. Without KaTeX the formulas show as their LaTeX source.
261
+
262
+ ```
263
+ E[time_x / time_ref] = mean( time_x_i / time_ref_i for each corpus entry i )
264
+ ```
265
+
266
+ not `median(time_x) / median(time_ref)` and not
267
+ `mean(time_x) / mean(time_ref)`. Corpus entries here span three orders
268
+ of magnitude in pixel count, and averaging the raw numbers first lets
269
+ the 2048x2048 images dominate; ratio-then-average weighs every entry's
270
+ *relative* performance equally. See `_e_ratio()` in
271
+ `report/generate_report.py`.
272
+
273
+ That the reference is "whoever wins most often" means the report can
274
+ end up with a reference other than libstb, and the summary line will
275
+ say so; nothing in it is hard-coded.
276
+
277
+ ## What these benchmarks do not say
278
+
279
+ - **Security.** stb is written for trusted input. Its own readme is
280
+ explicit that stb_image and stb_truetype are not hardened against
281
+ malicious files, while libjpeg-turbo, libpng and FreeType are
282
+ actively fuzzed. That is a real difference between libstb and every
283
+ competitor here that no speed number captures. If you decode
284
+ untrusted uploads, this matters more than any chart.
285
+ - **Features.** libstb is deliberately small. It does not do CMYK,
286
+ 16-bit-per-channel PNG pipelines, ICC profiles, EXIF orientation,
287
+ animated formats, or text shaping. The install-size table is there
288
+ to give context, and its last column says what each package is, but
289
+ "smaller and faster" only counts for the subset both sides do.
290
+ - **Multi-threading.** Everything is pinned to one thread. OpenCV's
291
+ and NumPy's threaded paths would change the resize story on a
292
+ many-core machine.
293
+ - **One machine.** Numbers are from the specific machine recorded in
294
+ the report's Environment section. Ratios travel better than
295
+ absolute times, but re-run it on yours.
296
+
297
+ ## What the report doesn't say (on purpose)
298
+
299
+ `results/report.html` is the results, not the write-up: it doesn't
300
+ explain how the corpus was built, why timing uses best-of-N, or what
301
+ went wrong along the way: that's this file. The exceptions are the
302
+ machine it ran on (CPU model, core count, RAM, OS, Python version),
303
+ which appears in the report's Environment section via
304
+ `system_info.py`, and the count of correctness checks that passed
305
+ before timing began, since both are facts about those specific numbers
306
+ rather than about the methodology in general.
@@ -0,0 +1,26 @@
1
+ # Download.cmake -- generic file(DOWNLOAD) wrapper for use in script
2
+ # mode (cmake -P), so a single add_custom_command can invoke it
3
+ # without duplicating the same DOWNLOAD/STATUS-check boilerplate.
4
+ #
5
+ # Usage:
6
+ # cmake -DURL=<url> -DDEST=<path> -P Download.cmake
7
+
8
+ if(NOT URL OR NOT DEST)
9
+ message(FATAL_ERROR "Download.cmake: both -DURL=... and -DDEST=... are required")
10
+ endif()
11
+
12
+ if(EXISTS "${DEST}")
13
+ return()
14
+ endif()
15
+
16
+ get_filename_component(_dest_dir "${DEST}" DIRECTORY)
17
+ file(MAKE_DIRECTORY "${_dest_dir}")
18
+
19
+ message(STATUS "Downloading ${URL} -> ${DEST}")
20
+ file(DOWNLOAD "${URL}" "${DEST}" STATUS _status TIMEOUT 60)
21
+ list(GET _status 0 _code)
22
+ if(NOT _code EQUAL 0)
23
+ list(GET _status 1 _msg)
24
+ file(REMOVE "${DEST}")
25
+ message(FATAL_ERROR "Download failed (${_msg}): ${URL}")
26
+ endif()
@@ -0,0 +1,76 @@
1
+ # FetchRealCorpus.cmake
2
+ #
3
+ # Downloads a small real-world corpus via plain file(DOWNLOAD), no
4
+ # FetchContent needed since we just want the raw files, not to build
5
+ # anything from them:
6
+ #
7
+ # - a handful of real photographs (the sample images that ship with
8
+ # OpenCV: github.com/opencv/opencv/tree/4.x/samples/data), and
9
+ # - one real TrueType font (DejaVu Sans, from matplotlib's copy),
10
+ # for the font benchmark.
11
+ #
12
+ # Always lands in benchmarks/corpus/ in the SOURCE tree (persistent
13
+ # across clean `build/` wipes, so nothing is re-downloaded every time),
14
+ # with a .gitignore containing `*` written into it, so the downloaded
15
+ # files are never committed, only the folder itself.
16
+ # This runs at CONFIGURE time (this file is include()'d directly by the
17
+ # top-level CMakeLists.txt, before add_subdirectory()), so
18
+ # `cmake -S . -B build` alone is enough to have the corpus ready.
19
+ #
20
+ # Every download is best-effort: a failure is a warning, never a build
21
+ # error. The suite degrades gracefully to the synthetic corpus (and,
22
+ # without the font, skips the font benchmark).
23
+ #
24
+ # Defines, for the caller:
25
+ # LIBSTB_REAL_CORPUS_DIR the folder holding the real images ("" if none)
26
+ # LIBSTB_REAL_FONT path of the downloaded .ttf ("" if unavailable)
27
+
28
+ set(LIBSTB_BENCH_REAL_IMAGES_BASE
29
+ "https://raw.githubusercontent.com/opencv/opencv/4.x/samples/data"
30
+ CACHE STRING "Base URL the real sample photographs are downloaded from")
31
+ set(LIBSTB_BENCH_REAL_IMAGES lena.jpg fruits.jpg baboon.jpg messi5.jpg butterfly.jpg home.jpg
32
+ CACHE STRING "File names (under the base URL) of the real photographs to download")
33
+ set(LIBSTB_BENCH_FONT_URL
34
+ "https://raw.githubusercontent.com/matplotlib/matplotlib/main/lib/matplotlib/mpl-data/fonts/ttf/DejaVuSans.ttf"
35
+ CACHE STRING "A real TrueType font for the font benchmark (set to an empty string to skip it)")
36
+
37
+ set(_libstb_corpus_dir "${CMAKE_CURRENT_SOURCE_DIR}/corpus")
38
+ file(MAKE_DIRECTORY "${_libstb_corpus_dir}")
39
+ file(WRITE "${_libstb_corpus_dir}/.gitignore" "*\n!.gitignore\n")
40
+
41
+ function(_libstb_fetch url dest)
42
+ if(EXISTS "${dest}")
43
+ return()
44
+ endif()
45
+ message(STATUS "libstb benchmarks: downloading ${url}")
46
+ file(DOWNLOAD "${url}" "${dest}" STATUS _st TIMEOUT 60)
47
+ list(GET _st 0 _code)
48
+ if(NOT _code EQUAL 0)
49
+ list(GET _st 1 _msg)
50
+ message(WARNING "libstb benchmarks: could not download ${url} (${_msg}); continuing without it.")
51
+ file(REMOVE "${dest}")
52
+ endif()
53
+ endfunction()
54
+
55
+ set(LIBSTB_REAL_CORPUS_DIR "")
56
+ set(_libstb_real_count 0)
57
+ foreach(_name ${LIBSTB_BENCH_REAL_IMAGES})
58
+ _libstb_fetch("${LIBSTB_BENCH_REAL_IMAGES_BASE}/${_name}" "${_libstb_corpus_dir}/${_name}")
59
+ if(EXISTS "${_libstb_corpus_dir}/${_name}")
60
+ math(EXPR _libstb_real_count "${_libstb_real_count} + 1")
61
+ endif()
62
+ endforeach()
63
+ if(_libstb_real_count GREATER 0)
64
+ set(LIBSTB_REAL_CORPUS_DIR "${_libstb_corpus_dir}")
65
+ message(STATUS "libstb benchmarks: real corpus has ${_libstb_real_count} photographs in ${LIBSTB_REAL_CORPUS_DIR}")
66
+ else()
67
+ message(WARNING "libstb benchmarks: no real photographs available; running on the synthetic corpus only.")
68
+ endif()
69
+
70
+ set(LIBSTB_REAL_FONT "")
71
+ if(LIBSTB_BENCH_FONT_URL)
72
+ _libstb_fetch("${LIBSTB_BENCH_FONT_URL}" "${_libstb_corpus_dir}/DejaVuSans.ttf")
73
+ if(EXISTS "${_libstb_corpus_dir}/DejaVuSans.ttf")
74
+ set(LIBSTB_REAL_FONT "${_libstb_corpus_dir}/DejaVuSans.ttf")
75
+ endif()
76
+ endif()
@@ -0,0 +1,2 @@
1
+ *
2
+ !.gitignore