@simonklee/opentui-tex-native-source 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/native/lib.zig +11 -4
- package/native/microtex.patch +825 -0
- package/native/vendor/{.bootstrap-v5 → .bootstrap-v8} +1 -1
- package/native/vendor/microtex/lib/atom/atom_matrix.cpp +44 -35
- package/native/vendor/microtex/lib/atom/atom_matrix.h +2 -2
- package/native/vendor/microtex/lib/atom/atom_row.cpp +2 -2
- package/native/vendor/microtex/lib/core/parse_limits.h +54 -0
- package/native/vendor/microtex/lib/core/parser.cpp +14 -5
- package/native/vendor/microtex/lib/macro/macro_delims.cpp +5 -5
- package/native/vendor/microtex/lib/macro/macro_env.h +33 -33
- package/native/vendor/microtex/lib/utils/string_utils.h +2 -1
- package/native/vendor/microtex/lib/wrapper/byte_seq.cpp +13 -3
- package/native/vendor/microtex/lib/wrapper/byte_seq.h +1 -0
- package/native/vendor/microtex/lib/wrapper/cwrapper.cpp +25 -14
- package/native/vendor/zigtex/src/root.zig +15 -12
- package/native/vendor/zigtex/src/tex.zig +14 -31
- package/native/zigtex-0.16.patch +209 -16
- package/package.json +1 -1
- package/scripts/bootstrap-native +17 -24
package/native/lib.zig
CHANGED
|
@@ -114,6 +114,9 @@ fn render(
|
|
|
114
114
|
foreground: [3]u8,
|
|
115
115
|
background: [3]u8,
|
|
116
116
|
) !void {
|
|
117
|
+
if (!std.unicode.utf8ValidateSlice(source) or std.mem.indexOfScalar(u8, source, 0) != null) {
|
|
118
|
+
return error.InvalidTex;
|
|
119
|
+
}
|
|
117
120
|
var arena = std.heap.ArenaAllocator.init(std.heap.c_allocator);
|
|
118
121
|
defer arena.deinit();
|
|
119
122
|
const allocator = arena.allocator();
|
|
@@ -124,7 +127,7 @@ fn render(
|
|
|
124
127
|
"#{x:0>2}{x:0>2}{x:0>2}",
|
|
125
128
|
.{ foreground[0], foreground[1], foreground[2] },
|
|
126
129
|
);
|
|
127
|
-
const renderer =
|
|
130
|
+
const renderer = if (renderer_instance) |*value| value else return error.InternalError;
|
|
128
131
|
const svg = renderer.parseRender(allocator, source, .{
|
|
129
132
|
.size = 28,
|
|
130
133
|
.spacing = 8,
|
|
@@ -137,11 +140,15 @@ fn render(
|
|
|
137
140
|
const mutable_svg = try svgWithoutDescription(allocator, svg);
|
|
138
141
|
const image = c.nsvgParse(mutable_svg.ptr, "px", 96) orelse return error.InvalidSvg;
|
|
139
142
|
defer c.nsvgDelete(image);
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
143
|
+
const width_float = @ceil(image.*.width * supersample);
|
|
144
|
+
const height_float = @ceil(image.*.height * supersample);
|
|
145
|
+
if (!(width_float > 0 and width_float <= dimension_max) or
|
|
146
|
+
!(height_float > 0 and height_float <= dimension_max))
|
|
147
|
+
{
|
|
143
148
|
return error.InvalidDimensions;
|
|
144
149
|
}
|
|
150
|
+
const width: usize = @intFromFloat(width_float);
|
|
151
|
+
const height: usize = @intFromFloat(height_float);
|
|
145
152
|
const pixel_length = std.math.mul(usize, width, height) catch return error.InvalidDimensions;
|
|
146
153
|
const pixels_length = std.math.mul(usize, pixel_length, channels) catch return error.InvalidDimensions;
|
|
147
154
|
if (pixels_length > std.math.maxInt(u32)) return error.InvalidDimensions;
|