canvas_ity
Ultralight
canvas_ity | Ultralight | |
---|---|---|
7 | 53 | |
318 | 4,597 | |
- | 0.3% | |
2.5 | 2.9 | |
2 months ago | 12 days ago | |
C++ | CMake | |
ISC License | - |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
canvas_ity
-
Writing a TrueType font renderer
I have a small TTF implementation that's in the neighborhood of that size and is open source. It's part of my canvas_ity single-header library [0] that's around 2300 LOC / 36 KB object size and implements a C++ version of most of the 2D HTML5 canvas spec [1].
The core implementation of the TTF parsing and drawing is in L1526-L1846 with another small bit at L3205-L3274 of src/canvas_ity.hpp.
It's something of a toy implementation that only supports western left-to-right text, and doesn't do any hinting at all, nor kerning, nor shaping. But it's enough to draw a basic "Hello world!" using any typical TTF file.
The test suite in test/test.cpp L84-304 embeds a few custom Base64-encoded TTF files. They're small and only have a few glyphs but they do exercise a number of interesting edge cases in the OpenType TTF spec [2]. Have a look at the HTML5 port of the test suite at test/test.html in different browsers to see how their canvas implementations render those fonts.
[0] https://github.com/a-e-k/canvas_ity
[1] https://www.w3.org/TR/2015/REC-2dcontext-20151119/
[2] https://standards.iso.org/ittf/PubliclyAvailableStandards/c0...
-
The Lone Developer Problem
Agreed, that sort of documentation is pure gold when done well.
It's something I always try to pay forward by doing in my own code. For example, one of my own solo projects was an STB-style single-header -like rasterizer library for C++. I started the implementation half of the library with a short outline of the rendering pipeline's dataflow and the top-level functions responsible for each stage:
https://github.com/a-e-k/canvas_ity/blob/f32fbb37e2fe7c0fcae...
-
Ask HN: What have you created that deserves a second chance on HN?
https://github.com/a-e-k/canvas_ity
This is an STB-style single-header C++ library with no dependencies beyond the standard C++ library. In about 2300 lines of 78-column code (not counting blanks or comments), or 1300 semicolons, it implements an API based on the basic W3C specification to draw 2D vector graphics into an image buffer:
- Strokes and fills (with antialiasing and gamma-correct blending)
- Linear and radial gradients
- Patterns (with repeat modes and bi-cubic resampling)
- Line caps and line joins (handling high curvature)
- Dash patterns and dash offsets
- Transforms
- Lines, quadratic and cubic Beziers, arcs, and rectangles
- Text (very basic, but does its own TTF font file parsing!)
- Raster images (i.e., sprites)
- Clipping (via masking)
- Compositing modes (Porter-Duff)
- Drop shadows with Gaussian blurs
I also uncovered a number of interesting browser quirks along the way with the HTML5 port of my testing suite.
- Hello, PNG
- A tiny, single-header -like 2D rasterizer for C++
-
canvas_ity - A tiny, single-header <canvas>-like 2D rasterizer
Repository: https://github.com/a-e-k/canvas_ity
- Show HN: Canvas_ity – A tiny, single-header -like 2D rasterizer for C++
Ultralight
- Ultralight: Display Web-Content Everywhere
-
Writing a TrueType font renderer
[2] https://ultralig.ht/
- This year in Servo: over 1000 pull requests and beyond
-
Arc browser launches its Windows client in beta
Web rendering would be Blink, with V8 being the JavaScript engine. I believe they have their own UI rendering process.
I know of another company that does something similar for the UI process, but with WebKit instead as the base:
https://github.com/ultralight-ux/ultralight#rocket-dual-high...
-
Ode to the M1
What I'd really like to see with CEF et al, is JS being dropped, in favor of directly controlling the DOM from the host language. Then we could, for example, write a Rust (or Kotlin, Zig, Haskell, etc) desktop application that simply directly manipulated the DOM, and had it rendered by a HTML+CSS layout engine. Folks could then write a React-like framework for that language (to help render & re-render the DOM in an elegant way).
Ultralight (https://ultralig.ht/) looks pretty cool. I think another possible option is Servo (https://github.com/servo/servo) – it was abandoned by Mozilla along with Rust during their layoffs a while back (but the project still seems to have a decent bit of activity). It would be great if some group of devs could revive the project, or a company could fund such a revival.
Eventually, we'll need to reflect on, and explore whether HTML+CSS is really the best way to do layout, and we could maybe perhaps consider proting the Android/iOS layout approach over to desktop.
-
Anselm's Jazz Distributed Infrastructure Framework
I'm curious if the project will be open-source or do you have plans to go the Awesomium/Ultralight route with both open/closed sources and volume licenses? Or do you plan to offer commercial support services like other open source software?
-
Best cross-platform (Win, Mac, Linux) desktop frameworks?
I’m not tied to any language, but it needs to be able to wrap a c++ library. I started with .NET 7 MAUI - no linux support & very mobile focused. Tried out Electron. Wins on ease and usability, but has massive overhead. (Basic “Hello world” executable compiled to over 200mb) I then discovered Ultralight (https://ultralig.ht/). Big win on size, but was last updated 3 years ago.
-
Remember when this was 0% and 70 mb? This is comical.
tauri exists or if you wanted to ultralig.ht
-
Digital Audio Workstation Front End Development Struggles
I agree web stuff is really the best way to develop UIs. Good luck making responsive stuff in C++ for example. The paradigm of HTML, CSS, and JS is extremely powerful and even allows you to use canvas, webgpu, wasm.
There are multiple commercial projects that use web dev paradigm for GUIs:
https://coherent-labs.com/
https://ultralig.ht/
https://sciter.com/
-
what do you think about alternative browser engines?
Nice review, thanks! There are also: Ultralight (based on Webkit), LiteHTML, Tkhtml3 and Lobo Evolution. See also timeline of web engines.
What are some alternatives?
nanovgXC - Lightweight vector graphics library implementing exact-coverage antialiasing in OpenGL
webview - Tiny cross-platform webview library for C/C++. Uses WebKit (GTK/Cocoa) and Edge WebView2 (Windows).
tinf - Tiny inflate library (inflate, gzip, zlib)
tauri - Build smaller, faster, and more secure desktop applications with a web frontend.
Tephra - A modern, high-performance C++17 graphics and compute library based on Vulkan
qt-ultralight-browser - Ultra-lightweight web browser based on Qt Ultralight webview, powered by Ultralight HTML renderer
art - @Bigfan/art is a React custom renderer for HTML5 Canvas.
wry - Cross-platform WebView library in Rust for Tauri.
osxphotos - Python app to work with pictures and associated metadata from Apple Photos on macOS. Also includes a package to provide programmatic access to the Photos library, pictures, and metadata.
ClassicUO - ClassicUO - an open source implementation of the Ultima Online Classic Client.
fpng - Super fast C++ .PNG writer/reader
litehtml - Fast and lightweight HTML/CSS rendering engine