Hi Alexander,

> 2019/05/28 15:20、Alexander Ilin <ajs...@yandex.ru>のメール:
> 
>  Is it possible to tell Uniscribe to render the text in white color?
>  If such text shows up on the black background, that would confirm part of 
> the theory.

Nice Idea.
I modified the code to whiten the device context given by with-memory-dc using 
PatBlt.
Uniscribe works well with transparent background text.
The next step should be to use BitBlt.




USING: accessors alien.c-types alien.data colors images.viewer
io io.encodings.string io.encodings.utf16n io.styles kernel
literals math sequences ui ui.commands ui.gadgets
ui.gadgets.borders ui.gadgets.panes ui.gadgets.tracks
ui.gestures windows.gdi32 windows.offscreen windows.ole32
windows.types windows.usp10 locals fonts windows.fonts
windows.errors ;
IN: hello-uniscribe


! NOTE:  The following declarations are required in gdi32.factor
!
!        FUNCTION: int SetBkMode ( HDC hdc, int iBkMode )
!        FUNCTION: BOOL PatBlt ( HDC hdc, int x, int y, int width, int height, 
DWORD rop )


TUPLE: hello-gadget < track ;

: <hello-gadget> ( -- gadget )
    horizontal hello-gadget new-track
    [
        { { font-size 24 } } [
            "Hello" print
            "Grüß dich" print
            "здравствуйте" print
            "こんにちは" print
            "안녕하세요" print
            "שָׁלוֹם " print
        ] with-style
    ] make-pane { 10 10 } <border>
    f track-add ;

:: com-screen-shot ( gadget -- )
    [ :> dc
      gadget dim>> dc
      [
          dc 0 0 gadget dim>> first2  WHITENESS PatBlt drop
      ] make-bitmap-image image-window        
    ] with-memory-dc ;
    
CONSTANT: ssa-dwFlags flags{ SSA_GLYPHS SSA_FALLBACK SSA_TAB }

:: (com-screen-shot-with-text) ( dim bkMode uOptions -- )
    [ :> dc
      dim dc [         
          dc sans-serif-font cache-font SelectObject win32-error=0/f
          dc T{ rgba f 0.0 1.0 1.0 0.0 } color>RGB SetBkColor drop
          dc T{ rgba f 0.0 0.0 1.0 1.0 } color>RGB SetTextColor drop
          dc bkMode SetBkMode drop

          dc 0 0 dim first2 WHITENESS PatBlt drop
          
          dc
          "Hello!"
          [ utf16n encode ] ! pString
          [ length ] bi ! cString
          dup 1.5 * 16 + >integer ! cGlyphs -- MSDN says this is "recommended 
size"
          -1 ! iCharset -- Unicode
          ssa-dwFlags
          0 ! iReqWidth
          f ! psControl
          f ! psState
          f ! piDx
          f ! pTabdef
          f ! pbInClass
          f void* <ref> ! pssa
          [ ScriptStringAnalyse ] keep
          [ check-ole32-error ] [ |ScriptStringFree void* deref ] bi*
          
          0 ! iX
          0 ! iY
          uOptions
          { 0 0 } dim <RECT>
          0 ! iMinSel
          0 ! iMaxSel
          FALSE ! fDisabled
          ScriptStringOut check-ole32-error
      ] make-bitmap-image image-window        
    ] with-memory-dc ;

: com-screen-shot-with-text-opaque ( gadget -- )
    dim>> OPAQUE ETO_OPAQUE (com-screen-shot-with-text) ;

: com-screen-shot-with-text-transparent-1 ( gadget -- )
    dim>> OPAQUE 0 (com-screen-shot-with-text) ;

: com-screen-shot-with-text-transparent-2 ( gadget -- )
    dim>> TRANSPARENT ETO_OPAQUE (com-screen-shot-with-text) ;

: com-screen-shot-with-text-transparent-3 ( gadget -- )
    dim>> TRANSPARENT 0 (com-screen-shot-with-text) ;

hello-gadget "gestures" f {
    { T{ key-down { sym "1" } } com-screen-shot }
    { T{ key-down { sym "2" } } com-screen-shot-with-text-opaque }
    { T{ key-down { sym "3" } } com-screen-shot-with-text-transparent-1 }
    { T{ key-down { sym "4" } } com-screen-shot-with-text-transparent-2 }
    { T{ key-down { sym "5" } } com-screen-shot-with-text-transparent-3 }
} define-command-map

MAIN-WINDOW: hello-uniscribe { { title "გამარჯობა, uniscribe" } }
    <hello-gadget> >>gadgets ;



--
KUSUMOTO Norio



> 2019/05/28 15:20、Alexander Ilin <ajs...@yandex.ru>のメール:
> 
>  Is it possible to tell Uniscribe to render the text in white color?
>  If such text shows up on the black background, that would confirm part of 
> the theory.



_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to