Hi Nadeem and Matthew, Thanks for the suggestions. The more I look into fonts - the more complicated it gets. I think I will postpone the "render math in Racket" project and try to render math formulas via TeX and either pdf or svg (via poppler or rsvg).
2013/11/16 Matthew Butterick <m...@mbtype.com>: > 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 <nad...@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 > > > > ____________________ > Racket Users list: > http://lists.racket-lang.org/users > -- -- Jens Axel Søgaard ____________________ Racket Users list: http://lists.racket-lang.org/users