[racket] text/font not rendering symbol fonts on WinXP

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sat Nov 24 11:14:05 EST 2012

Is it worth raising this point on a pango mailing list and see if what
their take is?

Robby

On Sat, Nov 24, 2012 at 10:10 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> Robby's answer is in principle right: `racket/draw' really wants to
> work with Unicode characters, and the right way to access dingbat-like
> glyphs is to use the corresponding Unicode code point. The
> `racket/draw' library mostly inherits this policy from Pango.
>
> Under Windows, Pango ignores "Wingdings" because it's a non-Unicode
> symbol font. The same thing happens with "EZ Special-I" from
> "ByzMusicFonts". We may want to change Pango's behavior in the copy
> that is distributed with Racket; more on that below.
>
> On a normal Ubuntu installation, I believe the "Dingbats" font is set
> up for Unicode-style use, and that's why "012abc" renders as "012abc".
> The glyphs probably are not taken from the "Dingbats" font but found
> through fallbacks in another font. If you want a snowflake, use
> "\u2744", and that should work everywhere. Of course, you don't
> actually want a snowflake, so that's not the end of the story.
>
>
> When I install "EZ Special-I" in Ubuntu, then... well, Racket crashes
> due to problems with missing glyphs. But with the repair that I just
> pushed to the Racket source repo, the text renders in the way you
> expect. The Pango behavior on Ubuntu seems to be to allow the font use,
> even though the font claims to be a symbol font --- perhaps on the
> assumption that fonts will be well behaved from the Unicode perspective
> (in contrast to Windows, where non-well-behaved fonts are available by
> default).
>
>
> I think we should probably patch Racket's version of Pango for Windows
> to allow the use of symbol fonts. A danger of this hack is that a
> symbol font might be used as a fallback for a normal glyph when the
> glyph isn't found in some other font. I think that danger is low,
> though, and the consequences of failure seem relatively minor (i.e.,
> just pick a different main font). Furthermore, my Win7 installation
> seems to have fonts that act like symbol fonts but apparently don't
> claim to be, which defeats Pango's existing check.
>
> Unfortunately, patching Pango means compiling it myself for Windows,
> which is a tedious task that I had so far avoided. Maybe it's
> unavoidable, though.
>
>
> At Fri, 23 Nov 2012 15:55:43 -0500, Clement Erik Ferguson wrote:
>> I'm sorry, I don't think I've explained the problem I'm having clearly.
>>
>> I have fonts that I'm using that map latin characters to neumes for
>> byzantine chant music. So pressing "1" gives me a particular musical
>> symbol, and "a" gives me another symbol. I am trying to use text/font to
>> render those symbols, so I call it with a "1" but I'm getting a "1" instead
>> of the musical symbol on certain platforms. This method works fine on
>> Ubuntu 12.04 32bit and a Debian system that another user tested it on (I'm
>> not sure of the version info), but it isn't working on Windows XP and on
>> Ubuntu 12.10 64bit.
>>
>> If you go to https://github.com/muraiki/byzscribe and scroll down to the
>> picture, you can see what the output should look like. On platforms where
>> it doesn't work, instead of getting the musical symbols I simply get the
>> textual string that should map to those symbols, such as 01a.
>>
>> You can download the font package, which includes a PDF with a character
>> table, from here:
>> http://www.stanthonysmonastery.org/music/ByzMusicFonts.zipThe
>> character table is EZ-CharacterTables.pdf
>>
>> The other symbol fonts that I've tried work in the same way, although
>> instead of musical symbols they have other things like snowflakes and
>> shapes. Those aren't the fonts that I need to use, but I wanted to make
>> sure that the problem didn't lie in the byzantine chant fonts. On platforms
>> where the byzantine chant fonts don't work as expected, no other symbol
>> fonts work, either.
>>
>> I'm sorry if this is a bit confusing. Thank you for your help!
>>
>>
>> On Fri, Nov 23, 2012 at 3:38 PM, Robby Findler
>> <robby at eecs.northwestern.edu>wrote:
>>
>> > If you want to use, say, α, then you need an actual α in the string, not
>> > an "a".
>> >
>> > I don't know how the dingbats work, but certainly that's how it works
>> > for characters that are in the unicode character set.
>> >
>> > (You can type those characters by using their LaTeX equivalents and
>> > then hitting control-\ or alt-\ (depending on the platform).)
>> >
>> > Robby
>> >
>> > On Fri, Nov 23, 2012 at 2:02 PM, Clement Erik Ferguson
>> > <clementraphael at gmail.com> wrote:
>> > > Now I'm experiencing the same problem in Ubuntu 12.10. No symbol fonts
>> > > render when using text/font; I only get the latin text equivalent. I
>> > tried
>> > > this using the Dingbats font built into Ubuntu along with custom symbol
>> > > fonts I had downloaded. Both Dingbats and the other symbol fonts I
>> > > downloaded work fine in other programs.
>> > >
>> > > The system where this did work correctly was an Ubuntu 12.04 machine
>> > > (running under a VM). The Ubuntu 12.10 machine I'm using now is a fresh
>> > OS
>> > > installation using the 64-bit binary downloaded from the Racket site.
>> > >
>> > > Is anyone else using Ubuntu 12.10? Can you try running the following
>> > code?
>> > >
>> > > (require 2htdp/image)
>> > > (text/font "test" FONT-SIZE "black" "Dingbats" 'symbol 'normal 'normal
>> > #f)
>> > >
>> > > This should render some triangles and a snowflake, not "test".
>> > >
>> > > Thanks!
>> > >
>> > >
>> > > On Wed, Nov 21, 2012 at 1:54 PM, Robby Findler <
>> > robby at eecs.northwestern.edu>
>> > > wrote:
>> > >>
>> > >> The text/font function ultimately just calls find-or-create-font with
>> > >> the font details and then draw-string on the dc<%> with the string, so
>> > >> I guess that this is either a problem at that level of the Racket GUI
>> > >> system, or something that is just different about how Windows works
>> > >> from other platforms. (Sorry I don't know the right answer here.)
>> > >>
>> > >> Robby
>> > >>
>> > >> On Wed, Nov 21, 2012 at 12:29 PM, Clement Erik Ferguson
>> > >> <clementraphael at gmail.com> wrote:
>> > >> > Hi all,
>> > >> >
>> > >> > I'm a newcomer to Racket and I ran into a problem with the text/font
>> > >> > function in 2htdp/image. stamourv on #racket helped me diagnose this,
>> > >> > and it
>> > >> > seems to be a problem confined to Windows XP. When using text/font
>> > with
>> > >> > a
>> > >> > symbol font like Wingdings or Symbol (standard symbol fonts included
>> > >> > with
>> > >> > Windows) the character is not rendered. Instead, I get whatever the
>> > >> > equivalent Roman character would be.
>> > >> >
>> > >> > For instance:
>> > >> >
>> > >> > (define testingfont
>> > >> >   (text/font "012abc" 36 "black"
>> > >> >              "Wingdings" 'default 'normal 'normal #f))
>> > >> >
>> > >> > If I then type testingfont into the interactions window, instead of
>> > >> > rendering a series of symbols I get the input string 012abc instead. I
>> > >> > also
>> > >> > tried using 'symbol instead of 'default. We tried the same code on
>> > >> > Debian
>> > >> > (stamourv) and Ubuntu (me) and it worked fine on those platforms.
>> > >> >
>> > >> > I'm running Windows XP 32-bit, and I am using Racket 5.3.1.
>> > >> >
>> > >> > Thanks!
>> > >> >
>> > >> > ____________________
>> > >> >   Racket Users list:
>> > >> >   http://lists.racket-lang.org/users
>> > >> >
>> > >
>> > >
>> >
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users


Posted on the users mailing list.