FAQ
The Go port of Freetype has moved from code.google.com/p/freetype-go
to github.com/golang/freetype

I have taken the opportunity of the import path change to make some
breaking API changes. (The original Go code dates from 2010, before
things like the append built-in function existed). I was hoping to
have made all of those changes by the time that Google Code Hosting
became read-only on August 24, but that was not the case. Nonetheless,
in the long term, the code.google.com page should probably redirect to
the github.com page, and since I couldn't flip that switch after GCH
went read-only, the switch was flipped earlier this week.

Unfortunately, this seems to have broken "go get
code.google.com/p/freetype-go/freetype". I thought that GCH would
still serve svn or hg in read-only mode, but I was mistaken.

This has broken projects like github.com/gonum/plot and
github.com/llgcode/draw2d that depended on
code.google.com/p/freetype-go, in that they are now not "go get"table.
Sorry.

I'm happy to answer questions from any such projects about how they
can unbreak their builds. In the short term, they could vendor the old
code.google.com/p/freetype-go code, or they should be able to change
their import paths, possibly also importing some extra packages under
the golang.org/x tree:

import (
"golang.org/x/exp/shiny/font"
"golang.org/x/image/math/fixed"
)

After that, most changes should be mechanical, such as:
- truetype.Font.Kerning becomes truetype.Font.Kern.
- truetype.NoHinting becomes font.HintingNone.
- Some values (like a font scale and an advance width) changes from
int32 to fixed.Int26_6, a common type for sub-pixel measurements. (The
golang.org/x font packages can't depend on
github.com/golang/freetype).
- Similarly, raster.Point becomes fixed.Point26_6.

The golang.org/x/exp/shiny/font package lets programmers use a variety
of font files (such as the Plan 9 font files), not just the truetype
implementation of the freetype project. It might move in the future
out from golang.org/x/exp/..., maybe to golang.org/x/image/..., but
that's where it lives for now.

The long term solution is to favor golang.org/x/exp/shiny/font and its
font.Drawer type over github.com/golang/freetype and its
freetype.Context type (which is deprecated). A font.Drawer can draw
text from a variety of formats, via the font.Face interface, an
implementation of which is a recent addition to the
github.com/golang/freetype/truetype package. One long standing feature
request that was finally implemented is that a font.Drawer can measure
a string without drawing its glyphs. The font.drawer example [0] shows
how to horizontally center the "Jabberwocky" title on the output image
with a truetype.Face. You can compare that to the (deprecated)
freetype.Context example [1], which has similar output, without a
horizontally centered title string.

[0] https://github.com/golang/freetype/blob/master/example/drawer/main.go
[1] https://github.com/golang/freetype/blob/master/example/freetype/main.go

The new packages are not feature-complete, optimized, or API frozen,
by any means. There certainly needs more API to be able to line-break
a paragraph of text. I wasn't intending to talk much about the new API
until it was further along, but the Google Code Hosting read-onliness
made me break "go get", which has prompted me to announce it earlier.

I'm happy to hear your feedback.

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 17 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 28, '15 at 6:53a
activeSep 2, '15 at 12:24a
posts17
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase