Skip to content
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

migrate to x/image/math/fixed #30

Open
sbinet opened this issue Sep 9, 2015 · 12 comments
Open

migrate to x/image/math/fixed #30

sbinet opened this issue Sep 9, 2015 · 12 comments

Comments

@sbinet
Copy link

sbinet commented Sep 9, 2015

with the move of code.google.com/p/go-freetype to github.com/golang/freetype there has been some API changes, namely the move to golang.org/x/image/math/fixed to express font sizes.

more info here:
https://groups.google.com/d/topic/golang-nuts/tr-MftD7kbo/discussion

could you please migrate to that new API? it's blocking gonum/plot: gonum/plot#216

thanks.

@sbinet
Copy link
Author

sbinet commented Sep 9, 2015

additionally, migrating from code.google.com/p/jamslam-freetype-go to github.com/golang/freetype would perhaps help reducing dependency creep (at least from gonum/plot point of view as one of our dependencies is already using the github.com/golang/freetype package)

@sbinet
Copy link
Author

sbinet commented Sep 21, 2015

(gentle) ping?
is this repo still maintained?

@BurntSushi
Copy link
Owner

@sbinet It is, but it's going to move slowly. This in particular might take me some time to do, because freetype is also used in Wingo.

@sbinet
Copy link
Author

sbinet commented Sep 21, 2015

ok. thanks for the update :)

@bmatsuo
Copy link

bmatsuo commented Nov 17, 2015

My comment from duplicate #32:

It seems that the package requires the Context.MeasureString method which iirc was not available in "code.google.com/p/freetype-go/freetype".Context. I assume this was the original reason the "jamslam-" variant was used.

I have had similar requirements in the past. And I have used "jamslam" to meet them. Most recently when dealing with and trying to avoid code.google.com I found that I could achieve the MeasureString functionality by combining "github.com/golang/freetype" and "golang.org/x/image/font". You can look at my code. There is some weird rendering stuff going on in that program. But if you just trace back the types from the call site it should be fairly straightforward.

I think what it would boil down to in xgraphics/text.go would be something like the following (with some additional logic to create a font.Drawer):

w := f.MeasureString(text)
h := int(c.PointToFixed(fontSize) >> 6)

The height calculation is basically the same thing that "jamslam" is doing.

@BurntSushi
Copy link
Owner

@bmatsuo Thanks for that comment, that's really helpful. I'll make sure to get this fixed up soon. (I'm still using and relying on go get to work day-to-day, so it'll really get fixed.)

FYI, I am "jamslam." :P It was an old nick of mine. Worst case scenario, I'll just put that code on Github.

@bmatsuo
Copy link

bmatsuo commented Nov 17, 2015

FYI, I am "jamslam."

😮 Your code is prolific @BurntSushi (edit: 😉).

Is your primary concern not breaking wingo? Have you considered vendoring its dependencies? If not with GO15VENDOREXPERIMENT than godep can allow the command to remain available though go get using import path rewrites.

I haven't used xgraphics or related packages. But at a naive glance it doesn't seem too difficult to make the change. I could potentially write a pull request if you want.

@BurntSushi
Copy link
Owner

@bmatsuo That is pretty much my primary concern. And AFAIK, there are others using xgbutil, so I don't want to break them either. Unfortunately, I never quite figured out how to write good tests for X, so everything has to be tested by me manually. In retrospect, that was a really big mistake, because I am a huge bottleneck.

If you want to submit a PR, that'd be awesome. But I will find a way to fix it either way (I cannot live without Wingo), and your comment was already helpful enough, so don't sweat it!

@sbinet
Copy link
Author

sbinet commented Jan 28, 2016

time's up.
is anybody working on this?
if not, I'll try to give a stab at it following #30 (comment)
(in the meantime, I had to remove gonum/plot support for x11 as it was failing our travis builds)

@BurntSushi
Copy link
Owner

@sbinet Gah, I fell way behind. I might be able to get to it this weekend. But yes, I'll be forced to do it at some point since I need go get to work for Wingo.

@BurntSushi
Copy link
Owner

I at least have the build working again by importing graphics-go and freetype-go into github in commit 41e40dc. I didn't actually migrate to updates in the API though, so I'll leave this issue open, but hopefully it's enough to get gonum/plot working again on x11!

@KenjiTakahashi
Copy link

I know it's been years, but here's an attempt to make the switch: jezek#2 🙂.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants