[Vm-dev] SqueakVM help for OLPC

Bert Freudenberg bert at freudenbergs.de
Mon May 21 19:30:06 UTC 2007


On May 21, 2007, at 21:21 , Chris Petsos wrote:

> Just for the record this is what we have done till now for Unicode  
> support in the Windows VM...
> We've made the application send Unicode chars to the image window  
> and forward this unicode value to the utf32Code data member with  
> the following...
>
> --- sqWin32Window.c 2007/05/18 06:04:50 1.1
> +++ sqWin32Window.c 2007/05/18 10:26:22
> @@ -799,6 +799,9 @@
>    CreatePrefsMenu();
>    SetWindowTitle();
>    SetForegroundWindow(stWindow);
> +/* Force Unicode WM_CHAR */
> +SetWindowLongW(stWindow,GWL_WNDPROC,GetWindowLong 
> (stWindow,GWL_WNDPROC));
> +SetWindowLongW(consoleWindow,GWL_WNDPROC,GetWindowLong 
> (consoleWindow,GWL_WNDPROC));
>  #ifndef NO_DROP
>    /* drag and drop needs to be set up on per-window basis */
>    SetupDragAndDrop();
> @@ -1069,7 +1072,7 @@
>    ctrl = GetKeyState(VK_CONTROL) & 0x8000;
>    /* now the key code */
>    virtCode = mapVirtualKey(msg->wParam);
> -  keyCode = keymap[msg->wParam];
> +  keyCode = msg->wParam;
>    /* press code must differentiate */
>    switch(msg->message) {
>      case WM_KEYDOWN:
> @@ -1110,14 +1113,14 @@
>    evt = (sqKeyboardEvent*) sqNextEventPut();
>    evt->type = EventTypeKeyboard;
>    evt->timeStamp = msg->time;
> -  evt->charCode = keyCode;
> +  evt->charCode = keymap[keyCode & 0xff];
>    evt->pressCode = pressCode;
>    evt->modifiers = 0;
>    evt->modifiers |= alt ? CommandKeyBit : 0;
>    evt->modifiers |= shift ? ShiftKeyBit : 0;
>    evt->modifiers |= ctrl ? CtrlKeyBit : 0;
>    evt->windowIndex = msg->hwnd == stWindow ? 0 : (int) msg->hwnd;
> -  evt->utf32Code = 0;
> +  evt->utf32Code = keyCode;
>    /* clean up reserved */
>    evt->reserved1 = 0;
>    /* note: several keys are not reported as character events;
>
> In the image side we've created a UnicodeInputInterpreter which is  
> dependent on this sixth field (the utf32Code in the evtBuf Array)  
> for acquiring the unicode value with the following method...
>
> ---------------------------------------------------------------------- 
> ----------------------
> nextCharFrom: sensor firstEvt: evtBuf
>
> | keyValue |
> " Unicode charCode expected as the sixth data member ! "
> keyValue := evtBuf sixth.
> Transcript show: evtBuf asString; cr.
> ^ keyValue asCharacter.
>
> ---------------------------------------------------------------------- 
> ----------------------
>
> So this is it...we have unicode charcodes inside the image...
>
>>  If we can replace all VMs, that would do.  Of course, the image can
>> check the VM version so that they can install proper "interpreter"
>> (including non-interpreting one for later VMs.)
>>
>>  It should be better to use pre-composed chars for these chars, but
>> I'm not entirely sure if it makes sense for all different input
>> methods.
>
> If you have any suggestions-modifications that you feel that will  
> help us avoid problems in the future, they are most welcome!
>
> Right now we trying to load a Unicode font. We've tried your font  
> Yoshiki (greek.out) but it has some problems. We are having a '?'  
> character along with every "carriage return"...
> The same effect happens when we try to load TrueType fonts... we  
> have a small "TrueType Box" in the place of  '?' :-) .
> Any help on how we can properly load a unicode font?

Squeak's TTF importer discards code points > 255. Here is a hack  
around this:

http://lists.squeakfoundation.org/pipermail/squeak-dev/2006-June/ 
105184.html

- Bert -




More information about the Vm-dev mailing list