| 1 | # This is the code for Config::Apple::Profile::Payload::Font. | ||
| 2 | # For Copyright, please see the bottom of the file. | ||
| 3 | |||
| 4 | package Config::Apple::Profile::Payload::Font; | ||
| 5 | |||
| 6 | 3 | ▶ | use 5.10.1; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 3 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 3 | ▶ | use base qw(Config::Apple::Profile::Payload::Common); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 3 | our $VERSION = '0.87.1'; | |
| 12 | |||
| 13 | 3 | ▶ | use Email::Valid; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 3 | ▶ | use Readonly; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 3 | ▶ | use Regexp::Common; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 3 | ▶ | use Config::Apple::Profile::Targets qw(:all); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 3 | ▶ | use Config::Apple::Profile::Payload::Common; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 3 | ▶ | use Config::Apple::Profile::Payload::Types qw(:all); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | |||
| 20 | |||
| 21 | =encoding utf8 | ||
| 22 | |||
| 23 | =head1 NAME | ||
| 24 | |||
| 25 | Config::Apple::Profile::Payload::Font - The Font payload type. | ||
| 26 | |||
| 27 | =head1 SYNOPSIS | ||
| 28 | |||
| 29 | use Config::Apple::Profile; | ||
| 30 | use Config::Apple::Profile::Payload::Font; | ||
| 31 | use File::Spec; | ||
| 32 | |||
| 33 | my $font_file_path = '/path/to/font.otf'; | ||
| 34 | |||
| 35 | my $font = new Config::Apple::Profile::Payload::Font; | ||
| 36 | my $payload = $email->payload; | ||
| 37 | |||
| 38 | open my $font_file, '<', $font_file_path | ||
| 39 | or die "Unable to open font $font_file_path: $!"; | ||
| 40 | $payload->{Font} = $font_file; | ||
| 41 | |||
| 42 | my $profile = new Config::Apple::Profile::Profile; | ||
| 43 | push @{$profile->content}, $font; | ||
| 44 | |||
| 45 | print $profile->export; | ||
| 46 | |||
| 47 | |||
| 48 | =head1 DESCRIPTION | ||
| 49 | |||
| 50 | This class implements the Font payload, which is used to install new fonts | ||
| 51 | on a device running iOS. This profile is not used by Mac OS X. | ||
| 52 | |||
| 53 | B<NOTE:> No testing is performed of the Font data provided. The author is not | ||
| 54 | aware of any Perl modules that can be used to test opening OpenType (.otf) | ||
| 55 | files, except for C<Font::FreeType>, which does not seem to be working. | ||
| 56 | |||
| 57 | |||
| 58 | =head1 PAYLOAD KEYS | ||
| 59 | |||
| 60 | All of the payload keys defined in L<Config::Apple::Profile::Payload::Common> | ||
| 61 | are used by this payload. | ||
| 62 | |||
| 63 | This payload has the following additional keys: | ||
| 64 | |||
| 65 | =head2 C<Name> | ||
| 66 | |||
| 67 | I<Optional> | ||
| 68 | |||
| 69 | A string. This is the name the user sees at the time the Font is installed. | ||
| 70 | Once installed, the font's embedded PostScript name is what the user will see. | ||
| 71 | |||
| 72 | =head2 C<Font> | ||
| 73 | |||
| 74 | Data. This is the TrueType (.ttf) or OpenType (.otf) font file. | ||
| 75 | |||
| 76 | B<NOTE:> Font collections (.ttc or .otc) are not supported. Use separate | ||
| 77 | payloads for each font. | ||
| 78 | |||
| 79 | B<NOTE:> Each font installed must have a unique embedded PostScript name. If | ||
| 80 | multiple fonts with the same embedded PostScript name are installed, only one | ||
| 81 | will be displayed to the user; which one is actually used is undefined. | ||
| 82 | |||
| 83 | =cut | ||
| 84 | |||
| 85 | 3 | Readonly our %payloadKeys => ( | |
| 86 | # Bring in the common keys... | ||
| 87 | %Config::Apple::Profile::Payload::Common::payloadKeys, | ||
| 88 | |||
| 89 | # ... and define our own! | ||
| 90 | 'Name' => { | ||
| 91 | type => $ProfileString, | ||
| 92 | description => 'Font name shown during installation.', | ||
| 93 | optional => 1, | ||
| 94 | targets => { | ||
| 95 | $TargetIOS => '5.0', | ||
| 96 | }, | ||
| 97 | }, | ||
| 98 | 'Font' => { | ||
| 99 | type => $ProfileData, | ||
| 100 | description => 'The TrueType (.ttf) or OpenType (.otf) font file.', | ||
| 101 | targets => { | ||
| 102 | $TargetIOS => '5.0', | ||
| 103 | }, | ||
| 104 | }, | ||
| 105 | |||
| 106 | # Finish with basic payload information | ||
| 107 | 'PayloadType' => { | ||
| 108 | type => $ProfileString, | ||
| 109 | value => 'com.apple.font', | ||
| 110 | targets => { | ||
| 111 | $TargetIOS => '5.0', | ||
| 112 | }, | ||
| 113 | }, | ||
| 114 | 'PayloadVersion' => { | ||
| 115 | type => $ProfileNumber, | ||
| 116 | value => 1, | ||
| 117 | targets => { | ||
| 118 | $TargetIOS => '5.0', | ||
| 119 | }, | ||
| 120 | }, | ||
| 121 | ); # End of %payloadKeys | ||
| 122 | |||
| 123 | |||
| 124 | =head1 ACKNOWLEDGEMENTS | ||
| 125 | |||
| 126 | Refer to L<Config::Apple::Profile> for acknowledgements. | ||
| 127 | |||
| 128 | =head1 AUTHOR | ||
| 129 | |||
| 130 | A. Karl Kornel, C<< <karl at kornel.us> >> | ||
| 131 | |||
| 132 | =head1 COPYRIGHT AND LICENSE | ||
| 133 | |||
| 134 | Copyright © 2014 A. Karl Kornel. | ||
| 135 | |||
| 136 | This program is free software; you can redistribute it and/or modify it | ||
| 137 | under the terms of either: the GNU General Public License as published | ||
| 138 | by the Free Software Foundation; or the Artistic License. | ||
| 139 | |||
| 140 | See L<http://dev.perl.org/licenses/> for more information. | ||
| 141 | |||
| 142 | =cut | ||
| 143 | |||
| 144 | 3 | 1; | |