Handbook
Glossary
font
Factor handbook
»
UI framework
»
Implementing new gadgets
»
Customizing gadget appearance
»
Implementing custom drawing logic
»
Rendering text
»
Fonts
Next:
<font> ( name -- font )
Vocabulary
fonts
Class description
The class of fonts.
Definition
IN:
fonts
TUPLE:
font
name size bold? italic? foreground background
;
Methods
USING:
accessors
combinators
fonts
fonts.shaping
fonts.shaping.private
kernel
;
M:
font
>shaped-font
shaped-font
new
H{
}
clone
>>shaping-options
swap
{
[
name>>
>>name
]
[
size>>
>>size
]
[
bold?>>
>>bold?
]
[
italic?>>
>>italic?
]
[
foreground>>
>>foreground
]
[
background>>
>>background
]
}
cleave
;
USING:
accessors
combinators
fonts
kernel
;
M:
font
derive-font
[
clone
]
dip
over
{
[
[
name>>
]
either?
>>name
]
[
[
size>>
]
either?
>>size
]
[
[
bold?>>
]
either?
>>bold?
]
[
[
italic?>>
]
either?
>>italic?
]
[
[
foreground>>
]
either?
>>foreground
]
[
[
background>>
]
either?
>>background
]
}
2cleave
;
USING:
fonts
fonts.shaping.private
kernel
;
M:
font
font-shaping-options
drop
H{
}
;
USING:
accessors
combinators
fonts
kernel
make
pdf.values
sequences
splitting
;
M:
font
pdf-value
[
"<<"
,
"/Type /Font"
,
"/Subtype /Type1"
,
{
[
name>>
{
{
"sans-serif"
~quotation~
}
{
"serif"
~quotation~
}
{
"monospace"
~quotation~
}
[
" is unsupported"
append
throw
]
}
case
]
[
[
bold?>>
]
[
italic?>>
]
bi
or
[
"-"
append
]
when
]
[
bold?>>
[
"Bold"
append
]
when
]
[
italic?>>
[
"Italic"
append
]
when
]
[
name>>
{
"sans-serif"
"monospace"
}
member?
[
"Italic"
"Oblique"
replace
]
when
]
}
cleave
"/BaseFont "
prepend
,
">>"
,
]
{
}
make
join-lines
;