[racket] Interpretation of font information

From: Matthew Butterick (mb at mbtype.com)
Date: Fri Nov 15 20:56:14 EST 2013

You've already noticed the essential problem, which is that there is no standardized width, height, or alignment for the square-root glyph. (Off the top of my head, I can't think of any Unicode glyph that is standardized in this way.)

As Nadeem suggested, you can 1) draw it yourself using primitives.

2) You could also include a math-symbol font in your program and use it for all the symbol work. Then you know in advance what the shapes will look like and can rely on those measurements.

But I think (1) ends up being more practical, because you soon run into situations where your font won't help you — e.g., you want to show the square root of an expression with a numerator & denominator. At that point, the square-root symbol wants to be two lines high, and merely scaling the square-root glyph in the font won't look right.

There are also LaTeX-to-SVG renderers out there, if you want to circumvent the problem at a higher level.





On Nov 15, 2013, at 2:21 PM, Nadeem Abdul Hamid <nadeem at acm.org> wrote:

> Not an answer to your question, but maybe you should try just generating the entire symbol programmatically using pict primitives instead of trying to get half of it from a font character?
> --- nadeem
> 
> On Friday, November 15, 2013, Jens Axel Søgaard wrote:
> Hi All,
> 
> I want to render simple mathematical formulas using picts.
> Consider a simple example, the square root of x:
> 
>     √x
> 
> To make this look nice, I want to introduce an overline that draws a bar over x.
> The bar should begin where the root sign ends. To do this I need to know
> how high the root sign is. Calculating this has turned out to more complicated
> than I expected. If I use a font size of say 30, then the root sign will (in
> some fonts) be higher than 30. If I use (text "√" font) to get a pict then
> the pict height will be 30 (for most fonts), but the end of the root sign
> will stick out of the bounding box. It actually makes sense it stick out,
> since this makes it easy to make roots over tall characters such as h.
> 
> 
> 
> -- 
> 
> --
> Nadeem Abdul Hamid
> Associate Professor, Computer Science
> Berry College, Mount Berry, GA 30149
> http://cs.berry.edu/~nhamid/
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131115/6d0bff20/attachment-0001.html>

Posted on the users mailing list.