Source

Description

This is an abstract base class for font descriptor source references. See also instance classes:

Example

use CSS::Font::Descriptor;
use CSS::Font::Resources;
use CSS::Font::Resources::Source;
my CSS::Font::Descriptor @font-face;
@font-face.push: CSS::Font::Descriptor.new: :font-family("DejaVu Sans"), :src<url("fonts/DejaVuSans.ttf")>;
@font-face.push: CSS::Font::Descriptor.new: :font-family<serif>, :font-weight<bold>, :src<local(DejaVuSans-Bold)>;
my $font = "bold 12pt times roman, serif";
my CSS::Font::Resources $fonts .= new: :$font, :@font-face;
my CSS::Font::Resources::Source @sources = $fonts.sources;
with @sources.head -> $src {
    say ($src.type, $src.format, $src.IO.path).join: ', ';
    # has matched the second descriptor.
    # results may be system dependant, e.g.:
    # local, truetype, /usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf
}

Methods

font-descriptor

use CSS::Font::Descriptor;
method font-descriptor returns CSS::Font::Descriptor;

Returns the CSS::Font::Descriptor associated with the source.

format

use CSS::Font::Resource::Source :FontFormat;
method format returns FontFormat;

Returns the font-format, one of: 'woff', 'woff2', 'truetype', 'opentype', 'embedded-opentype', 'svg'.

The format may be set by a `format(...)` declaration in the CSS `src` property. If this is absent, the format is guessed from the extension on the url (url sources), or matching file (local sources).

type Returns the source type 'local' (CSS::Font::Resources::Source::Local), or 'url' (CSS::Font::Resources::Source::Url)

IO

method IO returns IO::Path;

Returns an IO::Path to a font file

Blob

method format returns FontFormat;

Returns an Blob of the font file's

CSS::Font::Resources v0.0.9

CSS Font Resource selection and loading

Authors

  • David Warring

License

Artistic-2.0

Dependencies

CSS::Properties:ver<0.7.5+>Temp::PathLWP::SimpleURI:ver<0.3.3+>

Test Dependencies

Provides

  • CSS::Font::Resources
  • CSS::Font::Resources::Source
  • CSS::Font::Resources::Source::Local
  • CSS::Font::Resources::Source::Url
  • CSS::URI

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.