/usr/share/perl5/Debian/Defoma/Font.pm is in defoma 0.11.12ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | package Debian::Defoma::Font;
use strict;
use POSIX;
use Exporter;
use vars qw(@EXPORT @ISA %Fobjs $Userspace);
use Debian::Defoma::Common;
import Debian::Defoma::Common qw(&arg_check &arg_check_category &get_files);
use Debian::Defoma::FontCache;
@ISA = qw(Exporter);
@EXPORT = qw(&defoma_font_init &defoma_font_register &defoma_font_unregister
&defoma_font_reregister &defoma_font_term
&defoma_font_if_register &defoma_font_get_fonts
&defoma_font_get_hints &defoma_font_get_failed
&defoma_font_get_object);
%Fobjs = ();
$Userspace = 1;
sub defoma_font_init {
%Fobjs = ();
&Debian::Defoma::FontCache::initialize(ROOTDIR);
my @list = get_files("\\.font-cache\$", ROOTDIR);
my $o;
my $i;
foreach $i (@list) {
$i =~ s/\.font-cache$//;
$o = new Debian::Defoma::FontCache($i);
$o->read();
$Fobjs{$i} = $o;
}
return 0;
}
sub defoma_font_check_font {
my $font = shift;
my @list = values(%Fobjs);
foreach my $fobj (@list) {
if (exists($fobj->{cache_list}->{$font})) {
return $fobj->{category};
}
}
return '';
}
sub defoma_font_get_object {
my $category = shift;
unless (exists($Fobjs{$category})) {
my $fo = $Fobjs{$category} = new Debian::Defoma::FontCache($category);
}
return $Fobjs{$category};
}
sub defoma_font_register {
my $category = shift;
my $font = shift;
my @hints = @_;
arg_check($font, $category) || return 1;
arg_check_category($category) || return 1;
my $fobj;
if (exists($Fobjs{$category})) {
$fobj = $Fobjs{$category};
} else {
$fobj = $Fobjs{$category} = new Debian::Defoma::FontCache($category);
}
my $s = defoma_font_check_font($font);
if ($s ne '') {
printw("$font: already registered in category $s.");
return 1;
}
$fobj->add_font($font, @hints);
$fobj->add_user($font) if (USERSPACE && $Userspace);
$Userspace = 1;
printv("Registering $font..");
&Debian::Defoma::Configure::call_m($fobj, 'register', $category, $font,
@hints);
return 0;
}
sub defoma_font_unregister {
my $category = shift;
my $font = shift;
my $fobj;
unless (exists($Fobjs{$category})) {
printw("$category: Category not found.");
return 1;
}
$fobj = $Fobjs{$category};
unless (exists($fobj->{cache_list}->{$font})) {
printw("$font: not registered.");
return 1;
}
my @hints = split(' ', $fobj->{cache_list}->{$font});
printv("Unregistering $font..");
&Debian::Defoma::Configure::call_m($fobj, 'unregister', $category, $font,
@hints);
$fobj->remove_font($font);
$fobj->remove_user($font) if (USERSPACE);
return 0;
}
sub defoma_font_reregister {
my $category = shift;
my $font = shift;
my @hints0;
my $c = defoma_font_check_font($font);
if ($c ne '') {
if ($c eq $category) {
@hints0 = defoma_font_get_hints($c, $font);
if (@hints0 == @_) {
my $i = 0;
while ($i < @hints0 && $i < @_) {
last if ($hints0[$i] ne $_[$i]);
$i++;
}
return 0 if ($i == @_);
}
}
defoma_font_unregister($c, $font);
}
my $r = defoma_font_register($category, $font, @_);
return $r;
}
sub defoma_font_term {
my $fobj;
my @list = values(%Fobjs);
foreach $fobj (@list) {
$fobj->write();
}
return 0;
}
sub defoma_font_if_register {
my $category = shift;
my $font = shift;
if (exists($Fobjs{$category})) {
return 1 if (exists($Fobjs{$category}->{cache_list}->{$font}));
}
return 0;
}
sub defoma_font_get_fonts {
my $category = shift;
my @ret = ();
if (exists($Fobjs{$category})) {
my $fobj = $Fobjs{$category};
@ret = keys(%{$fobj->{cache_list}});
}
return @ret;
}
sub defoma_font_get_hints {
my $category = shift;
my $font = shift;
my @ret = ();
if (exists($Fobjs{$category})) {
my $fobj = $Fobjs{$category};
if (exists($fobj->{cache_list}->{$font})) {
@ret = split(' ', $fobj->{cache_list}->{$font});
}
}
return @ret;
}
sub defoma_font_get_failed {
my $category = shift;
my $font = shift;
my %ret = ();
if (exists($Fobjs{$category})) {
my $fobj = $Fobjs{$category};
if (exists($fobj->{fcache_list}->{$font})) {
%ret = %{$fobj->{fcache_list}->{$font}};
}
}
return %ret;
}
1;
|