[ANN] true unicode left arrows without clobbering underscores (cs)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] true unicode left arrows without clobbering underscores (cs)

michal-list

hi -

Attached is a changeset that gives you back the left arrow for assignement, without clobbering the underscore charcode and without hacking fonts. It also preserves ansi assignment in the change file and in fileOuts. Practically, this means that whenever you type := in a code editor, and accept it, you will see a left arrow, but the source file will preserve the ':='.

It does that by using the unicode character for left arrow (instead of hijacking the underscore), and rewriting that unicode character as := on write out. This is a tiny changeset (3 lines of code, basically), which I have made for my personal use, but I'm posting it here both for comments/ameliorations/criticisms, and in case it is useful to anyone. This is by far not an area of the image that I am familiar with, so I welcome criticism and pointers (and of course(I can package it for the inbox in case there is interest).

In order to benefit from this changeset, you must be using a font that has the unicode left arrow. The default fonts that come with squeak 4.2a don't have it, so you will need to install the FreeType package first and choose a font such as Times New Roman or Arial Unicode MS, etc. (To see a left arrow, do a PrintIt on 'Character value: 8592', and make sure that the chosen font is installed as the default code font (World Menu > appearances > system fonts > code font)).

Whenever I have a moment, I will add the up arrow, and also a preference for converting underscore assignments to true unicode left arrows. If there is interest, I will post that too.

Michal



trueLeftArrowModest.2.cs (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] true unicode left arrows without clobbering underscores (cs)

Ralph Johnson
That looks very interesting.

What happens if you don't have a font with left-arrow?  Does it give you the little black "illegal character" box?

-Ralph


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] true unicode left arrows without clobbering underscores (cs)

Tobias Pape
In reply to this post by michal-list
Am 2010-10-03 um 16:44 schrieb Michal:

>
> hi -
>
> Attached is a changeset that gives you back the left arrow for assignement, without clobbering the underscore charcode and without hacking fonts. It also preserves ansi assignment in the change file and in fileOuts. Practically, this means that whenever you type := in a code editor, and accept it, you will see a left arrow, but the source file will preserve the ':='.
>
> It does that by using the unicode character for left arrow (instead of hijacking the underscore), and rewriting that unicode character as := on write out. This is a tiny changeset (3 lines of code, basically), which I have made for my personal use, but I'm posting it here both for comments/ameliorations/criticisms, and in case it is useful to anyone. This is by far not an area of the image that I am familiar with, so I welcome criticism and pointers (and of course(I can package it for the inbox in case there is interest).
>
> In order to benefit from this changeset, you must be using a font that has the unicode left arrow. The default fonts that come with squeak 4.2a don't have it, so you will need to install the FreeType package first and choose a font such as Times New Roman or Arial Unicode MS, etc. (To see a left arrow, do a PrintIt on 'Character value: 8592', and make sure that the chosen font is installed as the default code font (World Menu > appearances > system fonts > code font)).
>
> Whenever I have a moment, I will add the up arrow, and also a preference for converting underscore assignments to true unicode left arrows. If there is interest, I will post that too.
>
> Michal
> <trueLeftArrowModest.2.cs>

Wonderful!

Thought of something like that myself.
Does any other smalltalk allow 'true' arrows,
btw?
  Anyone there to add the arrow to the default
font(s)?

So Long,
        -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] true unicode left arrows without clobbering underscores (cs)

Bert Freudenberg

On 04.10.2010, at 06:36, Tobias Pape wrote:

> Am 2010-10-03 um 16:44 schrieb Michal:
>>
>> hi -
>>
>> Attached is a changeset that gives you back the left arrow for assignement, without clobbering the underscore charcode and without hacking fonts. It also preserves ansi assignment in the change file and in fileOuts. Practically, this means that whenever you type := in a code editor, and accept it, you will see a left arrow, but the source file will preserve the ':='.
>>
>> It does that by using the unicode character for left arrow (instead of hijacking the underscore), and rewriting that unicode character as := on write out. This is a tiny changeset (3 lines of code, basically), which I have made for my personal use, but I'm posting it here both for comments/ameliorations/criticisms, and in case it is useful to anyone. This is by far not an area of the image that I am familiar with, so I welcome criticism and pointers (and of course(I can package it for the inbox in case there is interest).
>>
>> In order to benefit from this changeset, you must be using a font that has the unicode left arrow. The default fonts that come with squeak 4.2a don't have it, so you will need to install the FreeType package first and choose a font such as Times New Roman or Arial Unicode MS, etc. (To see a left arrow, do a PrintIt on 'Character value: 8592', and make sure that the chosen font is installed as the default code font (World Menu > appearances > system fonts > code font)).
>>
>> Whenever I have a moment, I will add the up arrow, and also a preference for converting underscore assignments to true unicode left arrows. If there is interest, I will post that too.
>>
>> Michal
>> <trueLeftArrowModest.2.cs>
>
> Wonderful!
>
> Thought of something like that myself.
> Does any other smalltalk allow 'true' arrows,
> btw?
>  Anyone there to add the arrow to the default
> font(s)?
>
> So Long,
> -Tobias

Our font's characterToGlyphMap could well map the codepoint 8592 to glyph index 256, and the arrow glyph be appended to the glyphs form ...

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: [ANN] true unicode left arrows without clobbering underscores (cs)

Tobias Pape
Am 2010-10-04 um 10:22 schrieb Bert Freudenberg:

>>
>> Thought of something like that myself.
>> Does any other smalltalk allow 'true' arrows,
>> btw?
>> Anyone there to add the arrow to the default
>> font(s)?
>>
>> So Long,
>> -Tobias
>
> Our font's characterToGlyphMap could well map the codepoint 8592 to glyph index 256, and the arrow glyph be appended to the glyphs form ...
>
> - Bert -

Hm, sounds feasible but feels like a hack.
BTW: I noticed, that the Original Bitstream Vera is included as
TTCFont, however, the Bitmap DejaVu StrikeFont is based on
its Descendant. I noticed that the actual DejaVu font includes
an arrow whilst the Vera does not. Why not replace the Vera
by the DejaVu entirely?

So Long,
        -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] true unicode left arrows without clobbering underscores (cs)

Bert Freudenberg
On 04.10.2010, at 13:31, Tobias Pape wrote:

> Am 2010-10-04 um 10:22 schrieb Bert Freudenberg:
>>>
>>> Thought of something like that myself.
>>> Does any other smalltalk allow 'true' arrows,
>>> btw?
>>> Anyone there to add the arrow to the default
>>> font(s)?
>>>
>>> So Long,
>>> -Tobias
>>
>> Our font's characterToGlyphMap could well map the codepoint 8592 to glyph index 256, and the arrow glyph be appended to the glyphs form ...
>>
>> - Bert -
>
> Hm, sounds feasible but feels like a hack.

Not really, that's how fonts work nowadays. We do not want to pay the price in terms of memory for full coverage. So we select glyphs, and no font has full unicode coverage in any case. Now by what criteria we select the glyphs we can decide on our own.

> BTW: I noticed, that the Original Bitstream Vera is included as
> TTCFont, however, the Bitmap DejaVu StrikeFont is based on
> its Descendant. I noticed that the actual DejaVu font includes
> an arrow whilst the Vera does not. Why not replace the Vera
> by the DejaVu entirely?

Because it's too big once rendered into bitmaps. I'd be interested to know how large it would be if we had at least the LGC subset covered ... but the only additional glyph we really need right now is the left-arrow.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] true unicode left arrows without clobbering underscores (cs)

Tobias Pape
Am 2010-10-04 um 15:13 schrieb Bert Freudenberg:

>> Hm, sounds feasible but feels like a hack.
>
> Not really, that's how fonts work nowadays. We do not want to pay the price in terms of memory for full coverage. So we select glyphs, and no font has full unicode coverage in any case. Now by what criteria we select the glyphs we can decide on our own.

If you say so. Am I right that this creates the need for
a layer of Indirection: Character value -> Glyph id in a map?

>
>> BTW: I noticed, that the Original Bitstream Vera is included as
>> TTCFont, however, the Bitmap DejaVu StrikeFont is based on
>> its Descendant. I noticed that the actual DejaVu font includes
>> an arrow whilst the Vera does not. Why not replace the Vera
>> by the DejaVu entirely?
>
> Because it's too big once rendered into bitmaps. I'd be interested to know how large it would be if we had at least the LGC subset covered ... but the only additional glyph we really need right now is the left-arrow.

True.

So Long,
        -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: [ANN] true unicode left arrows without clobbering underscores (cs)

Bert Freudenberg


On 04.10.2010, at 15:36, Tobias Pape <[hidden email]> wrote:

Am 2010-10-04 um 15:13 schrieb Bert Freudenberg:

Hm, sounds feasible but feels like a hack.

Not really, that's how fonts work nowadays. We do not want to pay the price in terms of memory for full coverage. So we select glyphs, and no font has full unicode coverage in any case. Now by what criteria we select the glyphs we can decide on our own.

If you say so. Am I right that this creates the need for
a layer of Indirection: Character value -> Glyph id in a map?

That is already the case. Use the source, Luke ;)

- Bert -

BTW: I noticed, that the Original Bitstream Vera is included as
TTCFont, however, the Bitmap DejaVu StrikeFont is based on
its Descendant. I noticed that the actual DejaVu font includes
an arrow whilst the Vera does not. Why not replace the Vera
by the DejaVu entirely?

Because it's too big once rendered into bitmaps. I'd be interested to know how large it would be if we had at least the LGC subset covered ... but the only additional glyph we really need right now is the left-arrow.

True.

So Long,
   -Tobias


Reply | Threaded
Open this post in threaded view
|

Re: [ANN] true unicode left arrows without clobbering underscores (cs)

michal-list
In reply to this post by Ralph Johnson

> What happens if you don't have a font with left-arrow?  Does it give
> you the little black "illegal character" box?

I got the 'question marks' that the standard squeak font gives when
encountering higher charcodes. Other fonts do give those little boxes.

Michal

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] true unicode left arrows without clobbering underscores (cs)

michal-list
In reply to this post by Bert Freudenberg

> Our font's characterToGlyphMap could well map the codepoint 8592 to
> glyph index 256, and the arrow glyph be appended to the glyphs form

what would it take to do that? Is it something I could easily add to
the arrow changeset?

Michal

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] true unicode left arrows without clobbering underscores (cs)

Hannes Hirzel
Michal,

Bitmap fonts are stored in instances of class Form. As a bitmap of
just the font height but wide contains all the shapes - one after the
other.

Then you have an index into this bitmap which tells where to start
copying and how wide the bitmap for a particular glyph is.

You would have to add the bitmap for the arrow at the end of the
bitmap and update the index and the map accordingly.

As Bert writes there seem to be two levels of mapping. One map from
Unicode to bitmap font index and the index contains the information
into the bitmap.

You basically have to figure out how bitmap fonts are implemented. If
I remember well there is quite some material on the Squeak wiki. And
googeling for
  Juan Vuletich DejaVu
might reveal some information which is helpful as well.
I assume the left arrow should have anti-aliasing as well.

And please add a preference so that people who prefer just to have
   :=
instead of the left arrow can maintain that.

Thank you for your work on this.

Your experience - in particular if properly documented - will be
helpful for adding other characters needed for mathematics or other
purposes.

--Hannes

On 10/4/10, Michal <[hidden email]> wrote:

>
>> Our font's characterToGlyphMap could well map the codepoint 8592 to
>> glyph index 256, and the arrow glyph be appended to the glyphs form
>
> what would it take to do that? Is it something I could easily add to
> the arrow changeset?
>
> Michal
>
>