Class: Fuse::Document::Asset::Font
Constant Summary
collapse
- CSS_FORMATS =
[
{ extension: :woff, format: 'woff' },
{ extension: :ttf, format: 'truetype' },
{ extension: :otf, format: 'opentype' }
]
- MIME_TYPES =
{
otf: 'application/x-font-opentype',
ttf: 'application/x-font-truetype',
woff: 'application/x-font-woff'
}
- VARIANT_PATTERN =
%r`([^/]+?)(?:[-_ ](normal|bold|bolder|lighter|[1-9]00))?(?:[-_ ](normal|italic|oblique))?\.[a-z]+$`
TYPES
Instance Attribute Summary
#path
Instance Method Summary
collapse
[], #call, #extension, #filter?, #filtered, for, #full_path, #initialize, #raw, #relative_path, #to_datauri
Instance Method Details
#face ⇒ Object
27
|
# File 'lib/fuse/document/asset/font.rb', line 27
def face; @face ||= [family, weight, style].join('-') end
|
#family ⇒ Object
14
|
# File 'lib/fuse/document/asset/font.rb', line 14
def family; @family ||= variant[:family] end
|
#style ⇒ Object
16
|
# File 'lib/fuse/document/asset/font.rb', line 16
def style; @style ||= variant[:style] end
|
#type ⇒ Object
28
29
30
|
# File 'lib/fuse/document/asset/font.rb', line 28
def type
MIME_TYPES[extension.to_sym] || super
end
|
#variant ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/fuse/document/asset/font.rb', line 17
def variant
@variant ||= begin
match = VARIANT_PATTERN.match(path)
{
family: match[1],
weight: match[2] || 'normal',
style: match[3] || 'normal'
}
end
end
|
#weight ⇒ Object
15
|
# File 'lib/fuse/document/asset/font.rb', line 15
def weight; @weight ||= variant[:weight] end
|