Rebol Programming/make-face

From Wikibooks, open books for an open world
Jump to navigation Jump to search

USAGE:[edit | edit source]

MAKE-FACE style /styles ss /clone /size wh /spec blk /offset xy /keep 

DESCRIPTION:[edit | edit source]

Make a face from a given style name or example face.

MAKE-FACE is a function value.

ARGUMENTS:[edit | edit source]

  • style -- A name or a face (Type: word object)

REFINEMENTS:[edit | edit source]

  • /styles
    • ss -- Stylesheet (Type: any)
  • /clone -- Copy all primary facets
  • /size
    • wh -- Size of face (Type: pair)
  • /spec
    • blk -- Spec block (Type: block)
  • /offset
    • xy -- Offset of face (Type: pair)
  • /keep -- Keep style related data

SOURCE CODE[edit | edit source]

make-face: func [
    {Make a face from a given style name or example face.} 
    style [word! object!] "A name or a face" 
    /styles ss "Stylesheet" 
    /clone "Copy all primary facets" 
    /size wh [pair!] "Size of face" 
    /spec blk [block!] "Spec block" 
    /offset xy [pair!] "Offset of face" 
    /keep "Keep style related data"
][
    if word? style [style: either styles [select ss style] [get-style style]] 
    if none? style [return none] 
    spec: [parent-face: saved-area: line-list: old-offset: old-size: none] 
    if blk [spec: append copy spec blk] 
    style: make style spec 
    if size [style/size: wh] 
    if offset [style/offset: xy] 
    style/flags: exclude style/flags state-flags 
    if clone [
        foreach word [text effect colors texts font para edge] [
            if style/:word [
                set in style word either series? style/:word [copy style/:word] [
                    make style/:word []
                ]
            ]
        ]
    ] 
    do bind style/init in style 'init 
    if not keep [
        style/init: copy [] 
        style/facets: none
    ] 
    style
]