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, const_missing, #extension, #filter?, #filtered, for, #full_path, #initialize, #raw, #relative_path, #to_datauri
Instance Method Details
#face ⇒ Object
33
34
35
|
# File 'lib/fuse/document/asset/font.rb', line 33
def face
@face ||= [family, weight, style].join('-')
end
|
#type ⇒ Object
37
38
39
|
# File 'lib/fuse/document/asset/font.rb', line 37
def type
MIME_TYPES[extension.to_sym] || super
end
|
#variant ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/fuse/document/asset/font.rb', line 22
def variant
@variant ||= begin
match = VARIANT_PATTERN.match(path)
{
family: match[1],
weight: match[2] || 'normal',
style: match[3] || 'normal'
}
end
end
|