Removed text shadow support
							parent
							
								
									3fb75247b2
								
							
						
					
					
						commit
						9c7d45e08a
					
				| 
						 | 
				
			
			@ -9,8 +9,7 @@ size
 | 
			
		|||
bold?
 | 
			
		||||
italic?
 | 
			
		||||
{ foreground initial: COLOR: black }
 | 
			
		||||
{ background initial: COLOR: white }
 | 
			
		||||
shadow ;
 | 
			
		||||
{ background initial: COLOR: white } ;
 | 
			
		||||
 | 
			
		||||
: <font> ( -- font )
 | 
			
		||||
    font new ; inline
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +37,6 @@ shadow ;
 | 
			
		|||
            [ [ italic?>> ] either? >>italic? ]
 | 
			
		||||
            [ [ foreground>> ] either? >>foreground ]
 | 
			
		||||
            [ [ background>> ] either? >>background ]
 | 
			
		||||
            [ [ shadow>> ] either? >>shadow ]
 | 
			
		||||
        } 2cleave
 | 
			
		||||
    ] when* ;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -58,7 +56,7 @@ shadow ;
 | 
			
		|||
        12 >>size ;
 | 
			
		||||
 | 
			
		||||
: strip-font-colors ( font -- font' )
 | 
			
		||||
    clone f >>background f >>foreground f >>shadow ;
 | 
			
		||||
    clone f >>background f >>foreground ;
 | 
			
		||||
 | 
			
		||||
TUPLE: metrics width ascent descent height leading cap-height x-height ;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,13 +34,12 @@ H{
 | 
			
		|||
    { font-style bold }
 | 
			
		||||
    { wrap-margin 500 }
 | 
			
		||||
    { foreground T{ rgba f 0.216 0.243 0.282 1.0 } }
 | 
			
		||||
    { shadow COLOR: white }
 | 
			
		||||
    { page-color T{ rgba f 0.94 0.94 0.91 1.0 } }
 | 
			
		||||
    { border-width 5 }
 | 
			
		||||
} title-style set-global
 | 
			
		||||
 | 
			
		||||
SYMBOL: help-path-style
 | 
			
		||||
H{ { font-size 10 } { shadow f } } help-path-style set-global
 | 
			
		||||
H{ { font-size 10 } } help-path-style set-global
 | 
			
		||||
 | 
			
		||||
SYMBOL: heading-style
 | 
			
		||||
H{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -121,7 +121,6 @@ ARTICLE: "character-styles" "Character styles"
 | 
			
		|||
"Character styles for " { $link stream-format } " and " { $link with-style } ":"
 | 
			
		||||
{ $subsection foreground }
 | 
			
		||||
{ $subsection background }
 | 
			
		||||
{ $subsection shadow }
 | 
			
		||||
{ $subsection font-name }
 | 
			
		||||
{ $subsection font-size }
 | 
			
		||||
{ $subsection font-style }
 | 
			
		||||
| 
						 | 
				
			
			@ -206,18 +205,6 @@ HELP: background
 | 
			
		|||
    }
 | 
			
		||||
} ;
 | 
			
		||||
 | 
			
		||||
HELP: shadow
 | 
			
		||||
{ $description "Character style. An instance of " { $link color } ". See " { $link "colors" } "." }
 | 
			
		||||
{ $examples
 | 
			
		||||
    { $code
 | 
			
		||||
        "\"Hello world\\n\""
 | 
			
		||||
        "H{ { background COLOR: gray }"
 | 
			
		||||
        "   { shadow COLOR: white }"
 | 
			
		||||
        "   { font-size 72 }"
 | 
			
		||||
        "} format"
 | 
			
		||||
    }
 | 
			
		||||
} ;
 | 
			
		||||
 | 
			
		||||
HELP: font-name
 | 
			
		||||
{ $description "Character style. Font family named by a string." }
 | 
			
		||||
{ $examples
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -116,7 +116,6 @@ SYMBOL: bold-italic
 | 
			
		|||
! Character styles
 | 
			
		||||
SYMBOL: foreground
 | 
			
		||||
SYMBOL: background
 | 
			
		||||
SYMBOL: shadow
 | 
			
		||||
SYMBOL: font-name
 | 
			
		||||
SYMBOL: font-size
 | 
			
		||||
SYMBOL: font-style
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,24 +65,13 @@ M: label baseline
 | 
			
		|||
M: label cap-height
 | 
			
		||||
    label-metrics cap-height>> round ;
 | 
			
		||||
 | 
			
		||||
: draw-text* ( font text fg bg -- )
 | 
			
		||||
    [ rot ] dip
 | 
			
		||||
    [ font-with-background ] when* swap
 | 
			
		||||
    [ font-with-foreground ] when* swap
 | 
			
		||||
    draw-text ;
 | 
			
		||||
 | 
			
		||||
: draw-shadowed-text ( font text -- )
 | 
			
		||||
    [
 | 
			
		||||
        { 0 1 } [ over shadow>> background get draw-text* ]
 | 
			
		||||
        with-translation
 | 
			
		||||
    ] [ foreground get transparent draw-text* ] 2bi ;
 | 
			
		||||
 | 
			
		||||
: draw-normal-text ( font text -- )
 | 
			
		||||
    foreground get background get draw-text* ;
 | 
			
		||||
 | 
			
		||||
M: label draw-gadget*
 | 
			
		||||
    >label< over shadow>>
 | 
			
		||||
    [ draw-shadowed-text ] [ draw-normal-text ] if ;
 | 
			
		||||
    >label<
 | 
			
		||||
    [
 | 
			
		||||
        background get [ font-with-background ] when*
 | 
			
		||||
        foreground get [ font-with-foreground ] when*
 | 
			
		||||
    ] dip
 | 
			
		||||
    draw-text ;
 | 
			
		||||
 | 
			
		||||
M: label gadget-text* string>> % ;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,7 @@ ui.gadgets.menus ui.clipboards ui.gestures ui.traverse ui.render
 | 
			
		|||
ui.text ui.gadgets.presentations ui.gadgets.grids ui.gadgets.tracks
 | 
			
		||||
ui.gadgets.icons ui.gadgets.grid-lines ui.baseline-alignment
 | 
			
		||||
colors io.styles ;
 | 
			
		||||
FROM: io.styles => foreground background shadow ;
 | 
			
		||||
FROM: io.styles => foreground background ;
 | 
			
		||||
IN: ui.gadgets.panes
 | 
			
		||||
 | 
			
		||||
TUPLE: pane < track
 | 
			
		||||
| 
						 | 
				
			
			@ -199,12 +199,11 @@ MEMO: specified-font ( assoc -- font )
 | 
			
		|||
        [ font-size swap at >>size ]
 | 
			
		||||
        [ foreground swap at >>foreground ]
 | 
			
		||||
        [ background swap at >>background ]
 | 
			
		||||
        [ shadow swap at >>shadow ]
 | 
			
		||||
    } cleave
 | 
			
		||||
    derive-font ;
 | 
			
		||||
 | 
			
		||||
: apply-font-style ( style gadget -- style gadget )
 | 
			
		||||
    { font-name font-style font-size foreground background shadow }
 | 
			
		||||
    { font-name font-style font-size foreground background }
 | 
			
		||||
    pick extract-keys specified-font >>font ;
 | 
			
		||||
 | 
			
		||||
: apply-style ( style gadget key quot -- style gadget )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue