Re: [racket] how to get exact results from get-text-extent

2014-12-19 Thread Hendrik Boom
On Fri, Dec 19, 2014 at 02:05:30PM -0800, Matthew Butterick wrote: > > What's the best way to impose systematic number typing on existing untyped > code, for instance, forcing everything to be a flonum? Does it require > switching to Typed Racket? Or does mean making explicit calls to > `exact->in

Re: [racket] how to get exact results from get-text-extent

2014-12-19 Thread Matthew Butterick
> > Here's what I'd do: decide on a smallest fractional point and a longest > length, and determine how many bits that requires. If 52 bits is enough, > use flonums. If it's not, write a prototype using bigfloats. If that's too > slow, try double-doubles or fixed-point numbers. What's the best wa

Re: [racket] how to get exact results from get-text-extent

2014-12-03 Thread Matthew Butterick
That's helpful, thanks. I was considering either 64-bit flonum millimeters or 64-bit fixnum nanometers. If there's not a meaningful speed advantage, I'll go with flonum millimeters, because they're more readable and thinkable. Points are traditional in typesetting systems, but that's a habit wort

Re: [racket] how to get exact results from get-text-extent

2014-12-02 Thread Neil Toronto
Here are some options for representing lengths. * Fixed-point numbers; i.e. a fixnum n represents n/2^k (where k = 16 for TeX). These are cheap and easy until you want to multiply or divide them. Then they get more expensive and bit-shifty. You can forget about doing anything else quickly. On

Re: [racket] how to get exact results from get-text-extent

2014-12-01 Thread Matthew Butterick
Right, I meant "exact" in the Racket sense of "exact rational." The broader issue I'm thinking about is what kind of units to use in a typesetting system in order to get the best balance of precision and speed. For instance, the flexibility of a 64-bit flonum doesn't necessarily buy you anything

Re: [racket] how to get exact results from get-text-extent

2014-12-01 Thread Matthew Flatt
We should probably improve the contracts on `racket/draw` to promise flonum results for text metrics. The intent is to make metric-derived calculations have a predictable cost, instead of potentially triggering expensive exact arithmetic. When you say that Pango produces "exact" results, do you me

[racket] how to get exact results from get-text-extent

2014-12-01 Thread Matthew Butterick
The `get-text-extent` method in racket/draw does not contractually guarantee either exact or inexact numbers, though in practice I find it produces inexact. This function, however, calls into the Pango text-layout system. I find that when I invoke Pango's text measuring directly through the FFI