### ----------------------------------------------------
### -- Font::FreeType
### -- Licenses: Artistic-2.0
### -- Authors: David Warring
### -- File: lib/Font/FreeType/NamedInfo.rakumod
### ----------------------------------------------------
#| Information from 'names table' in font file
unit class Font::FreeType::NamedInfo;

use NativeCall;
use Font::FreeType::Raw;

has FT_SfntName $!raw handles <platform-id encoding-id language-id name-id string-len>;
submethod TWEAK(FT_SfntName:D :$!raw!) { }

method Str {
    my $len := $.string-len;
    my buf8 $buf .= allocate($len);
    if $len {
        Font::FreeType::Raw::memcpy(nativecast(Pointer, $buf), $!raw.string, $len);
    }
    # todo various encoding schemes
    $buf.decode;
}

=begin pod

=head2 Synopsis

    use Font::FreeType;

    my Font::FreeType $freetype .= new;
    my $face = $freetype.face('Vera.ttf');
    my $infos = $face.named-infos;
    if $infos {
      say .Str for @$infos;
    }

=head2 Description

The TrueType and OpenType specifications allow the inclusion of a special
_names table_ in font files. This table contains textual (and internationalized)
information regarding the font, like family name, copyright, version, etc.

Possible values for _platform-id_, _encoding-id_, _language-id_, and
_name\_id_ are given in the file _ttnameid.h_ from FreeType distribution. For
details please refer to the TrueType or OpenType specification.

=head2 Methods

=head3 platform-id
=head3 encoding-id
=head3 language-id
=head3 name-id
=head3 Str

The _name_ string. Note that its format differs depending on the (platform,
 encoding) pair. It can be a Pascal String, a UTF-16 one, etc.

=head2 Authors

Geoff Richards <qef@laxan.com>

David Warring <david.warring@gmail.com> (Raku Port)

=head2 Copyright

Copyright 2004, Geoff Richards.

Ported from Perl to Raku by David Warring <david.warring@gmail.com>

=end pod


