View Issue Details

IDProjectCategoryView StatusLast Update
0015920LazarusLCLpublic2011-12-01 11:23
ReporterVanya BatalinAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilitysometimes
Status closedResolutionfixed 
Product Version0.9.28.2Product Build 
Target Version0.9.30Fixed in Version0.9.29 (SVN) 
Summary0015920: PostScript Unicode and brackets issue
DescriptionIn come cases of usage non-latin characters, cyrillic for example, we have some strange issue: we can't open or print generated PostScript document.
I'm looking for the code with text editor and "gs" utility, and found a problem.
In some cases unicode chars has represented as values more than 32 and we can see "(" symbol except of "\052" octal value. To fix it we must change limit to 42 and comment (or remove) brackets conversion. See code below.
Additional Informationin PostScriptCanvas.pas

//Replace the controls chars by PostScript string
function TPostScriptPrinterCanvas.MapedString(const St: string): string;
begin
  Result:=St;
  Result:=StringReplace(Result,'\','\\',[rfReplaceAll]);
// Result:=StringReplace(Result,'(','\(',[rfReplaceAll]);
// Result:=StringReplace(Result,')','\)',[rfReplaceAll]);
  Result:=StringReplace(Result,0000010,'\n',[rfReplaceAll]);
  Result:=StringReplace(Result,0000013,'\r',[rfReplaceAll]);
  Result:=StringReplace(Result,0000008, '\b',[rfReplaceAll]);
  Result:=StringReplace(Result,0000009, '\t',[rfReplaceAll]);
end;

in PostScriptUnicode.pas, OutputString function

    c := byte(w-FBlocks[b].Ini);
    if (c<42) {or (c>128)} then
      SubStr := SubStr + Octal(c)
    else
      SubStr := SubStr + char(c);
Tagslinux, postscript, printer, special, utf8
Fixed in Revision24001
LazTarget0.9.30
Widgetset
Attached Files

Activities

Jesus Reyes

2010-03-08 07:12

developer   ~0035030

Please attach a sample of code with text, and generated postscript

Vanya Batalin

2010-03-11 04:07

reporter   ~0035223

Of course you can see a code sample:

procedure TForm1.Button1Click(Sender: TObject);
var
 aPrinter:TPrinter;
 ps:TPostScriptCanvas;
begin
 aPrinter:=Printer;
 if aPrinter=nil then exit;
 aPrinter.BeginDoc;
 ps:=TPostScriptCanvas(aPrinter.Canvas);
 ps.TextOut(10,10,'АБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ'); //Ok
 ps.TextOut(10,100,'абвгдеёжзиклмнопрстуфхцчшщъыьэюя'); //Ok
 ps.TextOut(10,200,'ШТУКА'); //Error on this!
 ps.SaveToFile(ExtractFilePath(paramstr(0))+'out.ps'); //Save it to file
 aPrinter.EndDoc; //And print
end;

And generated postscript error line:

F07120 (\020\021\022\023\024\025\001\026\027\030\032\033\034\035\036\037 !"#$%&'()*+,-./) show
0.00 792.00 moveto %last pos
2.40 756.00 moveto
(012345Q678:;<=>?@ABCDEFGHIJKLMNO) show
0.00 792.00 moveto %last pos
2.40 732.00 moveto
(("#\032\020) show
0.00 792.00 moveto %last pos

As you can see in captial characters "Ш" and "Щ" we get an open and close brackets. If only one of this letters are used (as showed in line "ШТУКА"), than we give PS parsing exception.

Jesus Reyes

2010-03-15 01:46

developer   ~0035531

Thanks for sample code, I fixed the problem with a variation as MapedString is not really necessary anymore.

Issue History

Date Modified Username Field Change
2010-03-08 06:26 Vanya Batalin New Issue
2010-03-08 06:29 Vanya Batalin Tag Attached: linux
2010-03-08 06:29 Vanya Batalin Tag Attached: printer
2010-03-08 06:29 Vanya Batalin Tag Attached: utf8
2010-03-08 06:29 Vanya Batalin Tag Attached: special
2010-03-08 07:10 Jesus Reyes Status new => assigned
2010-03-08 07:10 Jesus Reyes Assigned To => Jesus Reyes
2010-03-08 07:12 Jesus Reyes LazTarget => -
2010-03-08 07:12 Jesus Reyes Note Added: 0035030
2010-03-08 07:12 Jesus Reyes Status assigned => feedback
2010-03-11 04:07 Vanya Batalin Note Added: 0035223
2010-03-14 23:00 Jesus Reyes Tag Attached: postscript
2010-03-15 01:46 Jesus Reyes Fixed in Revision => 24001
2010-03-15 01:46 Jesus Reyes LazTarget - => 0.9.30
2010-03-15 01:46 Jesus Reyes Status feedback => resolved
2010-03-15 01:46 Jesus Reyes Fixed in Version => 0.9.29 (SVN)
2010-03-15 01:46 Jesus Reyes Resolution open => fixed
2010-03-15 01:46 Jesus Reyes Note Added: 0035531
2010-03-15 01:47 Jesus Reyes Target Version => 0.9.30
2011-12-01 11:23 Marc Weustink Status resolved => closed