@@ -33,7 +33,9 @@ DefKeyVal('Gin', 'keepaspectratio', '', 'true');
3333DefKeyVal(' Gin' , ' clip' , ' ' , ' true' );
3434DefKeyVal(' Gin' , ' scale' , ' ' );
3535DefKeyVal(' Gin' , ' angle' , ' ' );
36+ DefKeyVal(' Gin' , ' actualtext' , ' ' );
3637DefKeyVal(' Gin' , ' alt' , ' ' );
38+ DefKeyVal(' Gin' , ' artifact' , ' ' , ' true' );
3739DefKeyVal(' Gin' , ' trim' , ' GraphixDimensions' );
3840DefKeyVal(' Gin' , ' viewport' , ' GraphixDimensions' );
3941# NOTE: graphicx defines @angle to actually carry out the rotation (on \box\z@) w/\Gin@erotate
@@ -56,19 +58,30 @@ DefConstructor('\@includegraphicx OptionalMatch:* OptionalKeyVals:Gin Semiverbat
5658 scope => ' global' ,
5759 afterConstruct => sub {
5860 my ($document , $whatsit ) = @_ ;
59- my $alt = $whatsit -> getProperty(' alt' );
60- # Trickery to set @description EVEN IF empty string (constructor shorthand omits it)
61- if (defined $alt ) {
62- $document -> getNode-> lastChild-> setAttribute(description => ToString($alt )); } },
61+ my $actualtext = $whatsit -> getProperty(' actualtext' );
62+ my $alt = $whatsit -> getProperty(' alt' );
63+ my $artifact = $whatsit -> getProperty(' artifact' );
64+ $artifact = 1 if defined $artifact && ToString($artifact ) ne ' false' ;
65+ if ($artifact || defined $actualtext || defined $alt ) {
66+ my $node = $document -> getNode-> lastChild;
67+ # Trickery to set @description EVEN IF empty string (constructor shorthand omits it)
68+ $node -> setAttribute(description => ToString($actualtext // $alt // ' ' ));
69+ # when both actualtext and alt are specified, use aria-description for alt
70+ $document -> setAttribute($node , ' aria:description' , ToString($alt )) if defined $alt && defined $actualtext ;
71+ $document -> setAttribute($node , ' aria:hidden' , ' true' ) if defined $artifact ; } },
6372 properties => sub {
6473 my ($stomach , $starred , $kv , $graphic ) = @_ ;
6574 my $options = graphicX_options($starred , $kv );
6675 my ($path , @candidates ) = image_candidates(ToString($graphic ));
67- my $alt = $kv && $kv -> getValue(' alt' );
76+ my $alt = $kv && $kv -> getValue(' alt' );
77+ my $actualtext = $kv && $kv -> getValue(' actualtext' );
78+ my $artifact = $kv && $kv -> getValue(' artifact' );
6879 (path => $path ,
6980 candidates => join (' ,' , @candidates ),
70- (defined $alt ? (alt => $alt ) : ()),
71- options => $options ); },
81+ actualtext => $actualtext ,
82+ alt => $alt ,
83+ artifact => $artifact ,
84+ options => $options ); },
7285 mode => ' restricted_horizontal' , enterHorizontal => 1);
7386
7487# **********************************************************************
0 commit comments