-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update freetype imports #216
Conversation
If the example plots work, LGTM. I don't think we do anything that would conflict if draw2d still uses the old, so I suspect it's fine. |
Please send a PR to fix the imports in draw2d or or file an issue there. I cannot see the reason for the failures (travis and my laptop disagree about some things), but I also cannot build to test here (go.googlesource.com returns a 500) which may be informative. Can we hold off until both of these things are resolved? |
Definitely can hold off. Here's the PR in draw2d, where they are also holding off: |
OK, so that's very good reason to wait. Disappointing that it was redirected before the alternative was ready. @nigeltao, is this reversible? |
Sorry, the redirection happened because it had to happen eventually, and code.google.com went read-only on August 24 (http://google-opensource.blogspot.com.au/2015/03/farewell-to-google-code.html) so I couldn't wait any longer. I didn't announce it yet on the mailing lists because I still have other API changes to make, but I guess I should, if people are having "go get" problems. If you can give me specific build failures, I can suggest what code changes to make, but there'll have to be code changes. |
Thanks @nigeltao, the build failure on travis at the moment appears to be due to downstream failures (due to the redirect). After fixing those (locally) and making the following changes we are now in a state where everyone has to make a move together: diff --git a/vg/font.go b/vg/font.go
index 6572c9c..689fa38 100644
--- a/vg/font.go
+++ b/vg/font.go
@@ -18,6 +18,8 @@ import (
"path/filepath"
"sync"
+ "golang.org/x/image/math/fixed"
+
"github.com/golang/freetype"
"github.com/golang/freetype/truetype"
)
@@ -147,7 +149,7 @@ type FontExtents struct {
// Extents returns the FontExtents for a font.
func (f *Font) Extents() FontExtents {
- bounds := f.font.Bounds(f.Font().FUnitsPerEm())
+ bounds := f.font.Bounds(fixed.Int26_6(f.Font().FUnitsPerEm()))
scale := f.Size / Points(float64(f.Font().FUnitsPerEm()))
return FontExtents{
Ascent: Points(float64(bounds.YMax)) * scale,
@@ -166,9 +168,9 @@ func (f *Font) Width(s string) Length {
for _, rune := range s {
index := f.font.Index(rune)
if hasPrev {
- width += int(f.font.Kerning(f.font.FUnitsPerEm(), prev, index))
+ width += int(f.font.Kern(fixed.Int26_6(f.font.FUnitsPerEm()), prev, index))
}
- width += int(f.font.HMetric(f.font.FUnitsPerEm(), index).AdvanceWidth)
+ width += int(f.font.HMetric(fixed.Int26_6(f.font.FUnitsPerEm()), index).AdvanceWidth)
prev, hasPrev = index, true
}
return Points(float64(width)) * scale
Fetching the changes at #216 to see if that fixes says that the rabbit hole is deep. |
golang-nuts post about the move to github.com/golang/freetype: |
it seems draw2d has migrated to the new freetype location+API. the ball is in our camp, now:
some of these might be fixed after applying Dan's patch from #216 (comment) |
- Use math/fixed - Use new functions * Kerning => Kern * A => Alpha
Fixes #218. |
Please run |
Note: I re-generated |
How did you do the regen? That test should also have a regen flag - but we can deal with that later. All the rest of the tests pass on my machine, but travis is obviously really sick today. |
I suppose xgbutil would need to migrate to |
Do you want to file an issue there? |
done: BurntSushi/xgbutil#30 |
fine by me. |
Fine by me. |
@jle would you please send a PR adding yourself to A+C at https://github.com/gonum/license Thank you. |
@kortschak Thanks for the merge. Sorry I wasn't able to get around to fixing x11 tests. I'd love to be part of A+C but I am highly skeptical that my minor patch warrants such an act. Thanks again. |
Smallest patch counts. |
Looks like code.google.com/p/freetype-go redirects to github.com/golang/freetype now. This fixes
go get
for this project, but some dependent projects like draw2d may still refer to the old path.