Hi Sven,The Monaco font doesn't contain those glyphs. You can find a font that
does have (at least the first of) those glyphs by evaluating this ...
((LogicalFontManager current allFamilies select: [:each| each class =
FreeTypeFontFamily]) select:[:each| (LogicalFont familyName: each
familyName pointSize: 10) hasGlyphsForAll: 16r2654 asCharacter asString])
collect:[:each | each familyName].
on my Mac, this results in - #('Apple Symbols' 'Arial Unicode MS' 'LastResort'
'Menlo')
Having found a suitable font, you can then render the glyphs to screen by doing
something like this...
StringMorph new contents: (String withAll: ((16r2654 to: 16r265F)
collect:[:each | each asCharacter]));font:(LogicalFont familyName:'Apple
Symbols' pointSize: 10); openInWorld .
You can test whether a particular font contains a glyph for some unicode char
by doing this...
(LogicalFont familyName: 'Monaco' pointSize: 10) realFont face
primGetCharIndex: 16r2654. "results in 0 - so it doesn't contain the
glyph"(LogicalFont familyName: 'Apple Symbols' pointSize: 10) realFont face
primGetCharIndex: 16r2654. "results in 371 (>0) - so it does contain the glyph"
If you set your Code font to a suitable font (e.g. 'Apple Symbols') then you
will also see these glyphs in your Workspace.
Operating Systems and Applications substitute missing glyphs with those from
another font when they render text. This is probably why your terminal
displayed the glyphs, even though Monaco doesn't have them.It would be cool to
have a similar glyph substitution scheme in Pharo; I'll see if I can work out
how that can be done
Cheers,Andy
.
> From: [email protected]
> Date: Mon, 12 Nov 2012 16:37:51 +0100
> To: [email protected]
> Subject: [Pharo-project] Unicode Fonts
>
> I was playing with the following:
>
> http://en.wikipedia.org/wiki/Chess_symbols_in_Unicode
>
> '/tmp/chess.txt' asFileReference writeStreamDo: [ :stream |
> (16r2654 to: 16r265F)
> do: [ :each |
> stream nextPut: each asCharacter ]
> separatedBy: [ stream space ].
> stream crlf ].
>
> $ cat /tmp/chess.txt
> ♔ ♕ ♖ ♗ ♘ ♙ ♚ ♛ ♜ ♝ ♞ ♟
>
> (this shows for me, in my terminal/mail, YMMV ;-)
>
> String streamContents: [ :stream |
> (16r2654 to: 16r265F)
> do: [ :each |
> stream nextPut: each asCharacter ]
> separatedBy: [ stream space ].
> stream crlf ].
>
> Is there a way to make this work, a font selection that show these Unicode
> characters in Pharo ? That would be cool.
>
> I tried using Freetype font Monaco, the same as my terminal where the right
> characters show, but that didn't help.
>
> Sven
>
> --
> Sven Van Caekenberghe
> http://stfx.eu
> Smalltalk is the Red Pill
>
>
>
>