Hendrik, Andrew,
I didn't know that font substitution was going on, yes it would be nice if we could get that in Pharo, provided the cost is acceptable.
Switching to Arial Unicode MS does indeed work.
My faith has been restored ;-)
Thx a lot,
Sven
PS: Sadly, I don't like the way the font is being anti-aliased���
On 13 Nov 2012, at 19:32, Andrew Tween <
amtween@hotmail.com> wrote:
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: sven@stfx.eu
> Date: Mon, 12 Nov 2012 16:37:51 +0100
> To: Pharo-project@lists.gforge.inria.fr
> 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