86 karma · joined Oct 7, 2016 (10y ago) · 35 submissions
comment 2y ago · link · parent
As the main author of rustybuzz I'm surprised to hear this. If you need a text shaper, rustybuzz is mostly a drop-in replacement for harfbuzz.
Text shaping and TrueType parsing are hard problems, but Rust does not make them more complicated. Quite the opposite. In fact, rustybuzz is written in 100% safe Rust. I would even go further and say that Rust is the only sane option for solving text-related tasks.
comment 3y ago · link · parent
public func read(path: URL) throws -> Array<UInt8> {
let file = try FileHandle(forReadingFrom: path)
let bytes = try file.readToEnd() ?? Data()
return Array(bytes)
}
Yes, the example above is not generic and not even idiomatic Swift, but it's a good glimpse into how Rust could look like.Hopefully someday Swift would become more safe, less tied to ObjC legacy and actually cross-platform. It's a shame that such a nice language is basically Apple-only.
comment 4y ago · link · parent
Probably a day, as long as you know Rust. I can take a look into it if you're interested. usvg (the SVG parser of resvg) is specifically designed to convert a real world SVG with all its quirks into a machine readable, minimal SVG/XML.
One thing to note is that usvg doesn't preserve text at the moment (will be converted into paths automatically) and Quadratic curves.
PS: I also have a longer, but still unfinished rant [0] over SVG complexity if you're interested.
[0] https://github.com/RazrFalcon/resvg/blob/master/docs/renderi...
comment 4y ago · link · parent
But yes, SVG is extremely bloated and under-documented. Especially SVG 2. The core resvg codebase is close to 20 KLOC, while the whole package is like 50 KLOC.
On the other hand, resvg is an exception, because it doesn't rely on any system and/or 3rd party libraries. 95% of the code in the final binary was written by one person (me). Not because it was strictly required, but because it was fun. resvg is basically an epitome of RIIR.
comment 5y ago · link · parent
Just like Skia, all pixel accesses is SIMD accelerated.
It doesn't have C bindings, but they can be trivially implemented.
comment 5y ago · link · parent
From a quick glance, pixie should pass 10-20% of those tests. Yes, SVG is that complex.
comment 6y ago · link · parent
- It still can't handle most of the CMake projects.
- Refactoring/autocompletion/go-to-definition doesn't work on a heavy-templated code.
- Clang must be patched to work correctly (at least code analyzer doesn't work out of the box).
- Code generation sometimes produces malformed code.
- No ANSI escape codes support in terminal/output.
- Random crashes.
IDEA with Rust plugin is years ahead.
13.
Show HN: resvg – a better SVG rendering library
5 points · by RazrFalcon · 7y ago · 1 comment
comment 8y ago · link · parent
And a manually crafted one is just 477B. And 261B compressed. Which is just 3% of the original.
Now we can talk about bloatedness.
<svg width="601" height="751" xmlns="http://www.w3.org/2000/svg">
<rect width="600" height="750" rx="38" fill="white" stroke="black"/>
<rect x="16" y="16" width="568" height="718" rx="24" fill="none" stroke="black" stroke-width="15"/>
<text text-anchor="middle" font-family="Arial" font-size="150" font-weight="bold">
<tspan x="300" y="200">FPS</tspan><tspan x="300" y="350">LIMIT</tspan><tspan x="300" y="660" font-size="350">15</tspan>
</text>
</svg>
[1]: https://github.com/RazrFalcon/svgcleanercomment 8y ago · link · parent
CMake is quite popular (and maybe most popular) but it's a complete horror in comparison to other build systems, especially for other languages (like Cargo for Rust).
If you need some specific example: try to add a git-based dependency with a specific branch in CMake.
comment 9y ago · link · parent
Instead of SVGO you can use svgcleaner[1] with zopfli, which is a bit better.
Yes, nothing compares to manual optimizations, but if you created an SVG using a vector editor - there is no point in manually removing all the garbage it adds in.