deri pushed a commit to branch master
in repository groff.

commit 2a5ad85ce4e4d114bb2ccb89064c774087df7522
Author: Deri James <[email protected]>
AuthorDate: Thu Sep 11 13:29:12 2025 +0100

    [gropdf]: Handle TTF->PFB converted fonts better, and
    restore cut'n'paste handling of '\-' mapped to U+2212.
    
    * src/devices/gropdf/gropdf.pl (FindChr): Some fonts
    invent Unicode Code Points for characters which have
    no sanctioned UCP, use the base UCP.
    (LoadFont): Handle 6 char UCPs.
    (LoadFont, AssignGlyph): Restore functionality of
    mapping U+2212 (minus) to U+002D (hyphen) when cutting
    and pasting from a pdf.
    (Subset): Other 'naughty' fonts use hyphen(s) when
    assigning a postscript name to a glyph (e.g. 'f-f-i'),
    allow it.
---
 ChangeLog                    | 16 ++++++++++++++++
 src/devices/gropdf/gropdf.pl | 12 ++++++------
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cc2c06f7a..40862ebe4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2025-08-03  Deri James  <[email protected]>
+
+       [gropdf]: Handle TTF->PFB converted fonts better, and
+       restore cut'n'paste handling of '\-' mapped to U+2212.
+
+       * src/devices/gropdf/gropdf.pl (FindChr): Some fonts
+       invent Unicode Code Points for characters which have
+       no sanctioned UCP, use the base UCP.
+       (LoadFont): Handle 6 char UCPs.
+       (LoadFont, AssignGlyph): Restore functionality of
+       mapping U+2212 (minus) to U+002D (hyphen) when cutting
+       and pasting from a pdf.
+       (Subset): Other 'naughty' fonts use hyphen(s) when
+       assigning a postscript name to a glyph (e.g. 'f-f-i'),
+       allow it.
+
 2025-09-02  G. Branden Robinson <[email protected]>
 
        * doc/doc.am (DOC_GROFF): Move `-M` option that is present only
diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl
index 958d54b59..a96d37c9a 100644
--- a/src/devices/gropdf/gropdf.pl
+++ b/src/devices/gropdf/gropdf.pl
@@ -2159,7 +2159,7 @@ sub FindChr
        }
        elsif (defined($thisfnt->{NAM}->{$ch}->[UNICODE]))
        {
-           return pack('U',hex($thisfnt->{NAM}->{$ch}->[UNICODE]))
+           return pack('U',hex(substr($thisfnt->{NAM}->{$ch}->[UNICODE],0,4)));
        }
     }
     elsif ($ch=~m/^\w+$/)       # ligature not in font i.e. \(ff
@@ -3451,11 +3451,11 @@ sub LoadFont
 
            $r[3]=oct($r[3]) if substr($r[3],0,1) eq '0';
            $r[4]=$r[0] if !defined($r[4]);
-           $r[6]=$1 if !defined($r[6] and defined($r[5]) and $r[5]=~m/^-- 
([0-9A-F]{4})/);
+           $r[6]=$1 if !defined($r[6] and defined($r[5]) and $r[5]=~m/^-- 
([0-9A-F]{4,6})/);
            if (exists($fnt{NAM}->{$r[0]}))
            {
                # Prefer postscript names other than 'uni' or 'afii' as primary
-               if ($fnt{NAM}->{$r[0]}->[2]=~m'^/(:afii\d{5}|uni[A-F0-9]{4,5})')
+               if ($fnt{NAM}->{$r[0]}->[2]=~m'^/(:afii\d{5}|uni[A-F0-9]{4,6})')
                {
                    my $n=$fnt{NAM}->{$r[0]}->[1];
                    $fnt{NAM}->{"#$n"}=$fnt{NAM}->{$r[0]};
@@ -3547,7 +3547,7 @@ sub LoadFont
     $fontlst{$fontno}->{NM}='/F'.$fontno;
     $fontlst{$fontno}->{FNT}=\%fnt;
 
-    if (defined($fnt{encoding}) and $fnt{encoding} eq 'text.enc' and $ucmap ne 
'')
+    if ($ucmap ne '')
     {
        if ($textenccmap eq '')
        {
@@ -4517,7 +4517,7 @@ sub AssignGlyph
     {
        ($chf->[MINOR],$chf->[MAJOR])=($chf->[CHRCODE],0);
     }
-    elsif ($chf->[CHRCODE] == 173)
+    elsif ($chf->[UNICODE] eq "2212") # minus
     {
        ($chf->[MINOR],$chf->[MAJOR])=(31,0);
     }
@@ -5096,7 +5096,7 @@ sub Subset
     my $glyphs=shift;
     my $extra=shift;
 
-    foreach my $g ($glyphs=~m/(\/[.\w]+)/g)
+    foreach my $g ($glyphs=~m/(\/[.\w-]+)/g)
     {
        if (exists($sec{$g}))
        {

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to