‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Friday, February 5th, 2021 at 11:18 PM, Nigel Tao <nigel...@golang.org> wrote: [...]
> > > What's your proposed API? > > > > package sfnt > > > > // Marshal returns the OTF encoding of f. > > > > func Marshal(f Font) ([]byte, error) > > func MarshalWriter(w io.Writer, f Font) error > > I suppose we could rename "type source" to "type Source" and have: > > // Source returns the []byte or io.ReaderAt passed to Parse or ParseReaderAt. > func (f *Font) Source() Source SGTM, and make Source implement io.Reader or io.WriterTo. or directly return an io.Reader (either from the underlying []byte, or as an io.SectionReader - wrapping the io.ReaderAt+size) ? > > or maybe: > // Source returns the []byte or io.ReaderAt passed to Parse or ParseReaderAt. > // > // fileLength is the largest file offset referred to by f's tables. An > // io.ReaderAt doesn't necessarily know its own 'file length'. > func (f *Font) Source() (s Source, fileLength int64) > > Tangentially, using a TTF/OTF font needs random access to the underlying > data, unlike e.g. decoding a JPEG using a 'one and done' sequential read. > Package sfnt was designed to work with either a []byte or an io.ReaderAt, but > the code paths are more complicated for io.ReaderAt. I'm curious if anyone > actually uses the io.ReaderAt support or whether, in hindsight, it was > unnecessary complexity. For example, on many systems it's possible to mmap a > file as a []byte, instead of going through an *os.File, but I don't have a > good sense if "on many systems" is "on all systems (in practice)"... I think Brad may disagree on the availablity of mmap on "all systems" :) looking at some of my uses of sfnt.ParseXYZ, I indeed get more []byte uses than io.ReaderAt ones, but that's mainly because I always provide a way to package fonts like goregular does (ie: w/ a []byte). with the advent of io/fs, the stat count may well reverse. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/vam86qulReL06_JlmEAG7I58n0HS60RFdU_fzokDUng_iW1zMJ5lR93cMerv9Z44u2lpps1_JJaz9ev-wjC7qNPthwm64RXevcZrARUDNio%3D%40sbinet.org.