From 75808db17caf8b960b351e3408e74142f4c85aac Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:42:30 +0200 Subject: Adding upstream version 2.117.0. Signed-off-by: Daniel Baumann --- lib/Lintian/Check/Fonts/Opentype.pm | 95 ++++++++++++++++++++ lib/Lintian/Check/Fonts/Postscript/Type1.pm | 130 ++++++++++++++++++++++++++++ lib/Lintian/Check/Fonts/Truetype.pm | 95 ++++++++++++++++++++ 3 files changed, 320 insertions(+) create mode 100644 lib/Lintian/Check/Fonts/Opentype.pm create mode 100644 lib/Lintian/Check/Fonts/Postscript/Type1.pm create mode 100644 lib/Lintian/Check/Fonts/Truetype.pm (limited to 'lib/Lintian/Check/Fonts') diff --git a/lib/Lintian/Check/Fonts/Opentype.pm b/lib/Lintian/Check/Fonts/Opentype.pm new file mode 100644 index 0000000..9ea5dac --- /dev/null +++ b/lib/Lintian/Check/Fonts/Opentype.pm @@ -0,0 +1,95 @@ +# fonts/opentype -- lintian check script -*- perl -*- + +# Copyright (C) 2019 Felix Lechner +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, you can find it on the World Wide +# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA. + +package Lintian::Check::Fonts::Opentype; + +use v5.20; +use warnings; +use utf8; +use autodie qw(open); + +use Const::Fast; +use Font::TTF::Font; + +use Moo; +use namespace::clean; + +with 'Lintian::Check'; + +const my $SPACE => q{ }; +const my $COMMA => q{,}; + +const my $PERMISSIONS_MASK => 0x0f; +const my $NEVER_EMBED_FLAG => 0x02; +const my $PRINT_PREVIEW_ONLY_FLAG => 0x04; +const my $EDIT_ONLY_FLAG => 0x08; + +sub visit_installed_files { + my ($self, $file) = @_; + + return + unless $file->is_file; + + return + unless $file->file_type =~ /^OpenType font data/; + + $self->pointed_hint('opentype-font-wrong-filename', $file->pointer) + unless $file->name =~ /\.otf$/i; + + my $font = Font::TTF::Font->open($file->unpacked_path); + + my $os2 = defined $font ? $font->{'OS/2'} : undef; + my $table = defined $os2 ? $os2->read : undef; + my $fs_type = defined $table ? $table->{fsType} : undef; + + $font->release + if defined $font; + + return + unless defined $fs_type; + + my @clauses; + + my $permissions = $fs_type & $PERMISSIONS_MASK; + push(@clauses, 'never embed') + if $permissions & $NEVER_EMBED_FLAG; + push(@clauses, 'preview/print only') + if $permissions & $PRINT_PREVIEW_ONLY_FLAG; + push(@clauses, 'edit only') + if $permissions & $EDIT_ONLY_FLAG; + + my $terms; + $terms = join($COMMA . $SPACE, @clauses) + if @clauses; + + $self->pointed_hint('opentype-font-prohibits-installable-embedding', + $file->pointer, "($terms)") + if length $terms; + + return; +} + +1; + +# Local Variables: +# indent-tabs-mode: nil +# cperl-indent-level: 4 +# End: +# vim: syntax=perl sw=4 sts=4 sr et diff --git a/lib/Lintian/Check/Fonts/Postscript/Type1.pm b/lib/Lintian/Check/Fonts/Postscript/Type1.pm new file mode 100644 index 0000000..280eb8f --- /dev/null +++ b/lib/Lintian/Check/Fonts/Postscript/Type1.pm @@ -0,0 +1,130 @@ +# fonts/postscript/type1 -- lintian check script -*- perl -*- + +# Copyright (C) 1998 Christian Schwarz and Richard Braakman +# Copyright (C) 2020 Felix Lechner +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, you can find it on the World Wide +# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA. + +package Lintian::Check::Fonts::Postscript::Type1; + +use v5.20; +use warnings; +use utf8; + +use Const::Fast; +use Encode qw(decode); +use Syntax::Keyword::Try; + +use Lintian::IPC::Run3 qw(safe_qx); + +use Moo; +use namespace::clean; + +const my $SPACE => q{ }; +const my $COLON => q{:}; + +with 'Lintian::Check'; + +sub visit_installed_files { + my ($self, $item) = @_; + + return + unless $item->is_file; + + return + unless $item->file_type =~ m/PostScript Type 1 font program data/; + + my @command = ('t1disasm', $item->unpacked_path); + my $bytes = safe_qx(@command); + + my $output; + try { + # iso-8859-1 works too, but the Font 1 standard could be older + $output = decode('cp1252', $bytes, Encode::FB_CROAK); + + } catch { + die 'In file ' . $item->name . $COLON . $SPACE . $@; + } + + my @lines = split(/\n/, $output); + + my $foundadobeline = 0; + + for my $line (@lines) { + + if ($foundadobeline) { + if ( + $line =~ m{\A [%\s]* + All\s*Rights\s*Reserved\.?\s* + \Z}xsmi + ) { + $self->pointed_hint( + 'license-problem-font-adobe-copyrighted-fragment', + $item->pointer); + + last; + } + } + + $foundadobeline = 1 + if $line =~ m{\A + [%\s]*Copyright\s*\(c\) \s* + 19\d{2}[\-\s]19\d{2}\s* + Adobe\s*Systems\s*Incorporated\.?\s*\Z}xsmi; + +# If copy pasted from black book they are +# copyright adobe a few line before the only +# place where the startlock is documented is +# in the black book copyrighted fragment +# +# 2023-06-05: this check has been adjusted because +# Adobe's type hint code[1] (including Flex[2]) became +# open source[3] with an Apache-2.0 license[4] as +# committed on 2014-09-19, making that check a false +# positive[7]. +# +# We continue to check for copyrighted code that is not +# available under an open source license from the origin +# publication, "Adobe Type 1 Font Format"[5][6]. +# +# [1] - https://github.com/adobe-type-tools/afdko/blob/2bf85cf44a64148353b24db17e0cc41ede5493b1/FDK/Tools/Programs/public/lib/source/t1write/t1write_hintothers.h +# [2] - https://github.com/adobe-type-tools/afdko/blob/2bf85cf44a64148353b24db17e0cc41ede5493b1/FDK/Tools/Programs/public/lib/source/t1write/t1write_flexothers.h +# [3] - https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1375813.html +# [4] - https://github.com/adobe-type-tools/afdko/blob/2bf85cf44a64148353b24db17e0cc41ede5493b1/LICENSE.txt +# [5] - https://adobe-type-tools.github.io/font-tech-notes/pdfs/T1_SPEC.pdf +# [6] - https://lccn.loc.gov/90042516 +# [7] - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1029555 + if ($line =~ m/UniqueID\s*6859/) { + + $self->pointed_hint( + 'license-problem-font-adobe-copyrighted-fragment-no-credit', + $item->pointer); + + last; + } + } + + return; +} + +1; + +# Local Variables: +# indent-tabs-mode: nil +# cperl-indent-level: 4 +# End: +# vim: syntax=perl sw=4 sts=4 sr et diff --git a/lib/Lintian/Check/Fonts/Truetype.pm b/lib/Lintian/Check/Fonts/Truetype.pm new file mode 100644 index 0000000..71e120a --- /dev/null +++ b/lib/Lintian/Check/Fonts/Truetype.pm @@ -0,0 +1,95 @@ +# fonts/truetype -- lintian check script -*- perl -*- + +# Copyright (C) 2019 Felix Lechner +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, you can find it on the World Wide +# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free +# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, +# MA 02110-1301, USA. + +package Lintian::Check::Fonts::Truetype; + +use v5.20; +use warnings; +use utf8; +use autodie qw(open); + +use Const::Fast; +use Font::TTF::Font; + +use Moo; +use namespace::clean; + +with 'Lintian::Check'; + +const my $SPACE => q{ }; +const my $COMMA => q{,}; + +const my $PERMISSIONS_MASK => 0x0f; +const my $NEVER_EMBED_FLAG => 0x02; +const my $PRINT_PREVIEW_ONLY_FLAG => 0x04; +const my $EDIT_ONLY_FLAG => 0x08; + +sub visit_installed_files { + my ($self, $file) = @_; + + return + unless $file->is_file; + + return + unless $file->file_type =~ /^TrueType Font data/; + + $self->pointed_hint('truetype-font-wrong-filename', $file->pointer) + unless $file->name =~ /\.ttf$/i; + + my $font = Font::TTF::Font->open($file->unpacked_path); + + my $os2 = defined $font ? $font->{'OS/2'} : undef; + my $table = defined $os2 ? $os2->read : undef; + my $fs_type = defined $table ? $table->{fsType} : undef; + + $font->release + if defined $font; + + return + unless defined $fs_type; + + my @clauses; + + my $permissions = $fs_type & $PERMISSIONS_MASK; + push(@clauses, 'never embed') + if $permissions & $NEVER_EMBED_FLAG; + push(@clauses, 'preview/print only') + if $permissions & $PRINT_PREVIEW_ONLY_FLAG; + push(@clauses, 'edit only') + if $permissions & $EDIT_ONLY_FLAG; + + my $terms; + $terms = join($COMMA . $SPACE, @clauses) + if @clauses; + + $self->pointed_hint('truetype-font-prohibits-installable-embedding', + $file->pointer, "($terms)") + if length $terms; + + return; +} + +1; + +# Local Variables: +# indent-tabs-mode: nil +# cperl-indent-level: 4 +# End: +# vim: syntax=perl sw=4 sts=4 sr et -- cgit v1.2.3