library: vendors/stb_image + vendors/stb_truetype — stb ships with sx
The stb headers move from the repo-root vendors/ (resolvable only with CWD = sx repo) into library/vendors/ following the sqlite convention — bindings module + c/ sources + provenance README — so '#import "vendors/stb_image/stb_image.sx"' (image v2.30 + image_write v1.16) and '#import "vendors/stb_truetype/stb_truetype.sx"' (v1.26) work from any consumer via the stdlib search paths. modules/ffi/stb.sx dissolves into the stb_image vendor; modules/ffi/stb_truetype.sx keeps its non-stb text-shaping companions and re-imports the vendored unit. examples/1625 pins a deterministic in-memory BMP decode; examples/1626 pins font init + metric invariants against the system Helvetica.
This commit is contained in:
20
library/vendors/stb_image/README.md
vendored
Normal file
20
library/vendors/stb_image/README.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# vendors/stb_image — image decode/encode for sx programs
|
||||
|
||||
- stb_image: **v2.30**; stb_image_write: **v1.16** (version comments at
|
||||
the top of each header)
|
||||
- Source: <https://github.com/nothings/stb> (`stb_image.h`,
|
||||
`stb_image_write.h`)
|
||||
- License: public domain / MIT, dual (see the headers' license blocks)
|
||||
- Files: `c/stb_image.h` + `c/stb_image_impl.c`, `c/stb_image_write.h`
|
||||
+ `c/stb_image_write_impl.c` (each impl .c defines the
|
||||
`*_IMPLEMENTATION` macro and includes its header)
|
||||
|
||||
`#import "vendors/stb_image/stb_image.sx"` resolves through the stdlib
|
||||
search paths; the decls (`stbi_load`, `stbi_load_from_memory`,
|
||||
`stbi_image_free`, `stbi_write_png`, …) are synthesized from the
|
||||
headers, and the implementation compiles once per machine through sx's
|
||||
object cache. `examples/1625-vendor-stb-image-decode.sx` pins an
|
||||
in-memory BMP decode in the sx suite.
|
||||
|
||||
To upgrade: replace the headers under `c/` with newer upstream copies,
|
||||
update this file, and rebuild (the object cache keys on source bytes).
|
||||
7988
library/vendors/stb_image/c/stb_image.h
vendored
Normal file
7988
library/vendors/stb_image/c/stb_image.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
library/vendors/stb_image/c/stb_image_impl.c
vendored
Normal file
2
library/vendors/stb_image/c/stb_image_impl.c
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
1724
library/vendors/stb_image/c/stb_image_write.h
vendored
Normal file
1724
library/vendors/stb_image/c/stb_image_write.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
library/vendors/stb_image/c/stb_image_write_impl.c
vendored
Normal file
2
library/vendors/stb_image/c/stb_image_write_impl.c
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
19
library/vendors/stb_image/stb_image.sx
vendored
Normal file
19
library/vendors/stb_image/stb_image.sx
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// =====================================================================
|
||||
// vendors/stb_image — Sean Barrett's stb_image (decode) and
|
||||
// stb_image_write (encode) as one `#import c` unit (c/, see README.md
|
||||
// for versions + provenance).
|
||||
//
|
||||
// `#import "vendors/stb_image/stb_image.sx"` gives any sx program
|
||||
// image decode/encode with no system dependency and no build flags:
|
||||
// the decls are synthesized from the headers, and the implementation
|
||||
// compiles through sx's content-addressed object cache — once per
|
||||
// machine, not once per run.
|
||||
// =====================================================================
|
||||
|
||||
#import c {
|
||||
#include "c/stb_image.h";
|
||||
#source "c/stb_image_impl.c";
|
||||
|
||||
#include "c/stb_image_write.h";
|
||||
#source "c/stb_image_write_impl.c";
|
||||
};
|
||||
20
library/vendors/stb_truetype/README.md
vendored
Normal file
20
library/vendors/stb_truetype/README.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# vendors/stb_truetype — font parsing/rasterization for sx programs
|
||||
|
||||
- Version: **v1.26** (version comment at the top of the header)
|
||||
- Source: <https://github.com/nothings/stb> (`stb_truetype.h`)
|
||||
- License: public domain / MIT, dual (see the header's license block)
|
||||
- Files: `c/stb_truetype.h` + `c/stb_truetype_impl.c` (the impl .c
|
||||
defines `STB_TRUETYPE_IMPLEMENTATION` and includes the header)
|
||||
|
||||
`#import "vendors/stb_truetype/stb_truetype.sx"` resolves through the
|
||||
stdlib search paths; the decls (`stbtt_InitFont`,
|
||||
`stbtt_ScaleForPixelHeight`, `stbtt_GetFontVMetrics`,
|
||||
`stbtt_MakeGlyphBitmap`, …) are synthesized from the header, and the
|
||||
implementation compiles once per machine through sx's object cache.
|
||||
`stbtt_fontinfo` is opaque on the sx side: allocate a 256-byte blob
|
||||
and pass its pointer (modules/ui/glyph_cache.sx is the reference
|
||||
consumer; `examples/1626-vendor-stb-truetype-metrics.sx` pins font
|
||||
init + metrics in the sx suite).
|
||||
|
||||
To upgrade: replace `c/stb_truetype.h` with a newer upstream copy,
|
||||
update this file, and rebuild (the object cache keys on source bytes).
|
||||
5079
library/vendors/stb_truetype/c/stb_truetype.h
vendored
Normal file
5079
library/vendors/stb_truetype/c/stb_truetype.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
library/vendors/stb_truetype/c/stb_truetype_impl.c
vendored
Normal file
2
library/vendors/stb_truetype/c/stb_truetype_impl.c
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#define STB_TRUETYPE_IMPLEMENTATION
|
||||
#include "stb_truetype.h"
|
||||
17
library/vendors/stb_truetype/stb_truetype.sx
vendored
Normal file
17
library/vendors/stb_truetype/stb_truetype.sx
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// =====================================================================
|
||||
// vendors/stb_truetype — Sean Barrett's stb_truetype (TTF/TTC
|
||||
// parsing, glyph metrics, bitmap rasterization) as a `#import c` unit
|
||||
// (c/, see README.md for version + provenance).
|
||||
//
|
||||
// `#import "vendors/stb_truetype/stb_truetype.sx"` gives any sx
|
||||
// program font loading with no system dependency: the decls are
|
||||
// synthesized from the header, and the implementation compiles
|
||||
// through sx's content-addressed object cache. `stbtt_fontinfo` is
|
||||
// opaque on the sx side — allocate a 256-byte blob and pass its
|
||||
// pointer (see modules/ui/glyph_cache.sx for the established idiom).
|
||||
// =====================================================================
|
||||
|
||||
#import c {
|
||||
#include "c/stb_truetype.h";
|
||||
#source "c/stb_truetype_impl.c";
|
||||
};
|
||||
Reference in New Issue
Block a user