[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 01/01: Bug #62934 - after glyph remapped mark it as used
From: |
Deri James |
Subject: |
[groff] 01/01: Bug #62934 - after glyph remapped mark it as used |
Date: |
Mon, 22 Aug 2022 18:31:27 -0400 (EDT) |
deri pushed a commit to branch master
in repository groff.
commit f275b477e0f49d180224a77271c1b68e913b71b5
Author: Deri James <deri@chuzzlewit.myzen.co.uk>
AuthorDate: Mon Aug 22 23:30:40 2022 +0100
Bug #62934 - after glyph remapped mark it as used
When many glyphs are remapped from code points above 255
such as writing documents in cyrillic with the U-TR fonts,
gropdf starts reusing code points in the range 128-255.
If subsequently one of those code points is actually required,
such as \(em (code 138), and it has been replaced by a
cyrillic, then it needs to be mapped to another free code.
To determine if a particular code point is free each glyph
has a USED flag. The bug was caused because after remapping
\(em to the next free glyph the USED flag was not set. So the
next new cyrillic character to be entered was given the same
code point as had been allocated to \(em.
* src/devices/gropdf/gropdf.pl: Set the USED flag on remapped
glyphs.
Fixes <https://savannah.gnu.org/bugs/?62934>.
Thanks to Nikita Ivanov for spotting the problem and testing
the fix.
---
ChangeLog | 25 +++++++++++++
src/devices/gropdf/gropdf.pl | 87 ++++++++++++++++++++++----------------------
2 files changed, 69 insertions(+), 43 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 643abd9b9..80a97ae94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2022-08-22 Deri James <deri@chuzzlewit.myzen.co.uk>
+
+ Bug #62934 - after glyph remapped mark it as used
+
+ When many glyphs are remapped from code points above 255
+ such as writing documents in cyrillic with the U-TR fonts,
+ gropdf starts reusing code points in the range 128-255.
+ If subsequently one of those code points is actually required,
+ such as \(em (code 138), and it has been replaced by a
+ cyrillic, then it needs to be mapped to another free code.
+
+ To determine if a particular code point is free each glyph
+ has a USED flag. The bug was caused because after remapping
+ \(em to the next free glyph the USED flag was not set. So the
+ next new cyrillic character to be entered was given the same
+ code point as had been allocated to \(em.
+
+ * src/devices/gropdf/gropdf.pl: Set the USED flag on remapped
+ glyphs.
+
+ Fixes <https://savannah.gnu.org/bugs/?62934>.
+
+ Thanks to Nikita Ivanov for spotting the problem and testing
+ the fix.
+
2022-08-20 Deri James <deri@chuzzlewit.myzen.co.uk>
Bug #62923 - problem using aliased glyphs
diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl
index b5fe98d87..4b6b1c009 100644
--- a/src/devices/gropdf/gropdf.pl
+++ b/src/devices/gropdf/gropdf.pl
@@ -112,13 +112,13 @@ my $w_flg=0;
my $nomove=0;
my $pendmv=0;
my $gotT=0;
-my $suppress=0; # Suppress processing?
-my %incfil; # Included Files
-my @outlev=([0,undef,0,0]); # Structure pdfmark /OUT entries
+my $suppress=0; # Suppress processing?
+my %incfil; # Included Files
+my @outlev=([0,undef,0,0]); # Structure pdfmark /OUT entries
my $curoutlev=\@outlev;
-my $curoutlevno=0; # Growth point for @curoutlev
+my $curoutlevno=0; # Growth point for @curoutlev
my $Foundry='';
-my $xrev=0; # Reverse x direction of font
+my $xrev=0; # Reverse x direction of font
my $matrixchg=0;
my $wt=-1;
my $thislev=1;
@@ -478,13 +478,13 @@ sub MakeMatrix
$slant*=$env{FontHT}/$cftsz if $env{FontHT} != 0;
my $ang=rad($slant);
- $mat[2]=sprintf('%.3f',sin($ang)/cos($ang));
- }
+ $mat[2]=sprintf('%.3f',sin($ang)/cos($ang));
+ }
- if ($fontxrev)
- {
- $mat[0]=-$mat[0];
- }
+ if ($fontxrev)
+ {
+ $mat[0]=-$mat[0];
+ }
}
$matrix=join(' ',@mat);
@@ -1142,12 +1142,12 @@ sub do_x
}
}
elsif (lc($xprm[1]) eq 'xrev')
- {
- $xrev=!$xrev;
- }
- elsif (lc($xprm[1]) eq 'markstart')
- {
- $mark={'rst' => ($xprm[2]+$xprm[4])/$unitwidth, 'rsb' =>
($xprm[3]-$xprm[4])/$unitwidth, 'xpos' => $xpos-($xprm[4]/$unitwidth),
+ {
+ $xrev=!$xrev;
+ }
+ elsif (lc($xprm[1]) eq 'markstart')
+ {
+ $mark={'rst' => ($xprm[2]+$xprm[4])/$unitwidth, 'rsb' =>
($xprm[3]-$xprm[4])/$unitwidth, 'xpos' => $xpos-($xprm[4]/$unitwidth),
'ypos' => $ypos, 'lead' => $xprm[4]/$unitwidth,
'pdfmark' => join(' ',@xprm[5..$#xprm])};
}
elsif (lc($xprm[1]) eq 'markend')
@@ -2411,21 +2411,21 @@ sub LoadFont
my (@r)=split;
my (@p)=split(',',$r[1]);
- if ($r[1] eq '"')
- {
- $fnt{NAM}->{$r[0]}=[@{$fnt{NAM}->{$lastnm}}];
- next;
- }
+ if ($r[1] eq '"')
+ {
+ $fnt{NAM}->{$r[0]}=[@{$fnt{NAM}->{$lastnm}}];
+ next;
+ }
$r[3]=oct($r[3]) if substr($r[3],0,1) eq '0';
$r[0]='u0020' if $r[3] == 32;
- $r[0]="u00".hex($r[3]) if $r[0] eq '---';
-# next if $r[3] >255;
- $r[4]=$r[0] if !defined($r[4]);
- $fnt{NAM}->{$r[0]}=[$p[0],$r[3],'/'.$r[4],$r[3],0];
- $fnt{NO}->[$r[3]]=[$r[0],$r[0]];
- $lastnm=$r[0];
- $lastchr=$r[3] if $r[3] > $lastchr;
+ $r[0]="u00".hex($r[3]) if $r[0] eq '---';
+# next if $r[3] >255;
+ $r[4]=$r[0] if !defined($r[4]);
+ $fnt{NAM}->{$r[0]}=[$p[0],$r[3],'/'.$r[4],$r[3],0];
+ $fnt{NO}->[$r[3]]=[$r[0],$r[0]];
+ $lastnm=$r[0];
+ $lastchr=$r[3] if $r[3] > $lastchr;
$fixwid=$p[0] if $fixwid == -1;
$fixwid=-2 if $fixwid > 0 and $p[0] != $fixwid;
@@ -3648,15 +3648,15 @@ sub do_t
{
PutLine(0) if $#lin > -1;
MakeMatrix(1);
- $stream.="$matrix ".PutXY($xpos,$ypos)." Tm\n", $poschg=0;
- $stream.="$curkern Tc\n";
- $stream.="0 Tw ";
- $stream.="($par) Tj\n";
- MakeMatrix();
- $stream.="$matrix ".PutXY($xpos,$ypos)." Tm\n", $poschg=0;
- $matrixchg=0;
- $stream.="$curkern Tc\n";
- return;
+ $stream.="$matrix ".PutXY($xpos,$ypos)." Tm\n", $poschg=0;
+ $stream.="$curkern Tc\n";
+ $stream.="0 Tw ";
+ $stream.="($par) Tj\n";
+ MakeMatrix();
+ $stream.="$matrix ".PutXY($xpos,$ypos)." Tm\n", $poschg=0;
+ $matrixchg=0;
+ $stream.="$curkern Tc\n";
+ return;
}
if ($pendmv)
@@ -3776,11 +3776,12 @@ sub RemapChr
if ($unused && $unused <= 255)
{
- my $glyph=$fnt->{NO}->[$unused]->[1];
- delete($fontlst{$cft}->{CACHE}->{$cftsz});
- $fnt->{NAM}->{$chnm}->[ASSIGNED]=$unused;
- $fnt->{NO}->[$unused]->[1]=$chnm;
- $widtbl=CacheWid($cft);
+ my $glyph=$fnt->{NO}->[$unused]->[1];
+ delete($fontlst{$cft}->{CACHE}->{$cftsz});
+ $fnt->{NAM}->{$chnm}->[ASSIGNED]=$unused;
+ $fnt->{NAM}->{$chnm}->[USED]=1;
+ $fnt->{NO}->[$unused]->[1]=$chnm;
+ $widtbl=CacheWid($cft);
$stream.="% AAA Assign $chnm ($ch) to $unused\n" if $debug;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 01/01: Bug #62934 - after glyph remapped mark it as used,
Deri James <=