Skip to content

Commit

Permalink
don't warn about wide char in unicode font names
Browse files Browse the repository at this point in the history
  • Loading branch information
dk committed Dec 21, 2024
1 parent 7d311fe commit 3a6eecf
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions t/Object/Fonts.xt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use strict;
use warnings;
use Test::More;
use Prima::sys::Test qw(noX11);
use open ':std', ':encoding(utf8)';
use Encode;

my $x;

Expand All @@ -17,19 +17,21 @@ sub t
encoding => $f->{encoding},
});

my $fname = Encode::encode('utf-8', $f->{name});

my $ok = 1;
for ( qw( height size direction)) {
my $fx = $x-> font-> $_();
$x-> font( $_ => $x-> font-> $_() * 3 + 12);
my $fx2 = $x-> font-> $_();
SKIP: {
if ( $fx2 == $fx || $x->font->name ne $f->{name}) {
skip "$_ / $f->{name}", 1;
skip "$_ / $fname", 1;
next;
}
$x-> font( $_ => $fx);
$fx = int( $fx + .5 ) if $^O =~ /win32/i && $_ eq 'size';
$ok &= is( $x-> font-> $_(), $fx, "$_ / $f->{name}");
$ok &= is( $x-> font-> $_(), $fx, "$_ / $fname");
};
}

Expand All @@ -43,11 +45,11 @@ sub t
my $fw2 = $x-> font-> width;
SKIP: {
if ( $fw2 == $fw || $x->font->name ne $f->{name}) {
skip "width / $f->{name}", 1;
skip "width / $fname", 1;
next;
}
$x-> font( $_ => $fh, width => $fw, name => $fn );
$ok &= is( $x-> font-> width, $fw, "width by $_ / $f->{name}");
$ok &= is( $x-> font-> width, $fw, "width by $_ / $fname");
};
}

Expand All @@ -59,19 +61,19 @@ sub t
my $fx2 = $x-> font-> style;
SKIP : {
if ( $fx2 == $fx || $x->font->name ne $f->{name}) {
skip "style / $f->{name}", 1;
skip "style / $fname", 1;
}
$x-> font( style => $fx);
is( $x-> font-> style, $fx, "style / $f->{name}");
is( $x-> font-> style, $fx, "style / $fname");
};

# wrapping
SKIP : {
$x-> font-> height( 16);
my ($a,$b,$c) = @{$x->get_font_abc(ord('e'),ord('e'))};
my $w = $a + $b + $c;
skip "text wrap / $f->{name}", 1 if $w <= 1; # some non-latin or symbol font
cmp_ok( scalar @{$x-> text_wrap( "eeee eeee eeee eeee eeee", $w * 5)}, '>', 4, "text wrap $f->{name}");
skip "text wrap / $fname", 1 if $w <= 1; # some non-latin or symbol font
cmp_ok( scalar @{$x-> text_wrap( "eeee eeee eeee eeee eeee", $w * 5)}, '>', 4, "text wrap $fname");
}

return $ok;
Expand Down

0 comments on commit 3a6eecf

Please sign in to comment.