Open nigeltao opened 7 years ago
I'm @adg and I approve this proposal.
I'm not @adg and I approve this proposal.
CL https://golang.org/cl/28347 mentions this issue.
Is the reference API of the Rust package published somewhere, or does one have to browse the sources? Will it be possible to stroke curves with dashes/dots pattern? (I use forked freetype-go to draw dashed lines and curves in my Go port of ditaa.)
I don't know enough about the Rust community to know if the API is published anywhere other than the source at https://github.com/google/font-rs but its API is pretty minimal: it is a prototype / proof of concept rather than a polished library.
I expect golang.org/x/image/vector will be as capable as github.com/golang/freetype/raster in terms of strokes, so you can build your own dashing code on top of that.
CL https://golang.org/cl/33417 mentions this issue.
github.com/golang/freetype already exists, but its license (the Freetype license) differs from the Go standard library, and code in the stdlib or under golang.org/x cannot depend on out-of-tree code.
I propose to add two new packages in the golang.org/x/image repo that together lets you use TTFs to draw text. There are existing packages under golang.org/x/image/font that can draw bitmap fonts, but this would be the first golang.org/x package that draws vector fonts.
The golang.org/x/image/vector package rasterizes 2-D vector graphics: filled and stroked polygons and Bézier curves. 2-D vector graphics (and the scope of this package) encompasses more than just fonts, but this package will rasterize the glyphs of a vector font such as TrueType. It'd be comparable to the github.com/golang/freetype/raster package, but not based on the Freetype code.
The golang.org/x/image/font/sfnt package parses sfnt font formats, including TrueType (.ttf) and OpenType (.otf). It will implement the existing golang.org/x/image/font font.Face interface for font format agnostic text drawing. It'd be comparable to the github.com/golang/freetype/truetype package, but not based on the Freetype code.
A proof of concept (as a single "package main" instead of two separate packages) exists in a separate repository, https://github.com/google/font-go, which is in turn based on https://github.com/google/font-rs and the accompanying article (https://medium.com/@raphlinus/inside-the-fastest-font-renderer-in-the-world-75ae5270c445) by Raph Levien of Google. Roughly speaking, font.go would become package sfnt, and raster.go and acc*.{go,s} would become package vector.