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 |
I thought it should work :( > 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 > > > > |
On 12.11.2012 21:18, Stéphane Ducasse wrote:
> I thought it should work :( Yes and no. Pharo is fully capable of displaying it, as long as it's part of the font: https://dl.dropbox.com/u/6751081/UniSymbol.PNG What it does not (currently) do, but built in rendering systems usually do, is search for and use other fonts if the currently selected one does not contain it. With a font parser (TTFontReader was removed in 2.0, I think?) I think it would be possible to implement such functionality rather efficiently, I don't see the same happening if one tries the same using the FT-plugin, which would probably require loading each font face, then attempt to load the character and check for errors (where, I am not sure) Cheers, Henry PS. For those wondering, I did not search through all Windows fonts manually. PopChar is a neat utility that easily lets you search for which fonts actually contain glyphs for a given character. (available for MacOS too) > >> 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 >> >> >> >> > |
In reply to this post by Sven Van Caekenberghe-2
CONTENTS DELETED
The author has deleted this message.
|
In reply to this post by Sven Van Caekenberghe-2
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: [hidden email] > Date: Mon, 12 Nov 2012 16:37:51 +0100 > To: [hidden email] > 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 > > > > |
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 <[hidden email]> wrote: Hi Sven, |
In reply to this post by Andrew Tween
Hi andy
Nice to see you here! Stef On Nov 13, 2012, at 7:32 PM, Andrew Tween 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: [hidden email] > > Date: Mon, 12 Nov 2012 16:37:51 +0100 > > To: [hidden email] > > 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 > > > > > > > > |
Free forum by Nabble | Edit this page |