lamuzzachiodi / tclfpdf

Port of tFPDF (PHP) by by Ian Back and Tycho Veltmeijer (modified version of FPDF by Olivier Plathey) to TCL
9 stars 0 forks source link

ttf_font.tcl and set $offset or set offset #9

Closed gregnix closed 6 months ago

gregnix commented 6 months ago

ttf_font.tcl proc ::tclfpdf::ttf_getCMAP4

row 1091 and 1092

set $offset [expr ($unichar - $startCount($n)) * 2 + $idRangeOffset($n)];
set $offset [ expr $idRangeOffset_start + 2 * $n + $offset]; 

Therefore it produces an error for me

set offset [expr ($unichar - $startCount($n)) * 2 + $idRangeOffset($n)];
set offset [ expr $idRangeOffset_start + 2 * $n + $offset]; 
lamuzzachiodi commented 6 months ago

Can you send some snippet of you code to test ?

gregnix commented 6 months ago

Cannot restore the condition that led to the error. Was with one of the examples.

gregnix commented 6 months ago

May repeat mistakes. I have two different DejaVuSansCondensed.ttf Calling the example utf8.tcl With the 1) DejaVuSansCondensed.ttf the proc proc ::tclfpdf::ttf_getCMAP4 from ttf_font.tcl at the point with set $offset passed through.

1.) 667K 10. Aug 2023 DejaVuSansCondensed.ttf

::tclfpdf::ttf_getCMAP4 can't read "offset": no such variable while executing "set $offset [expr ($unichar - $startCount($n)) * 2 + $idRangeOffset($n)]" (procedure "::tclfpdf::ttf_getCMAP4" line 41) invoked from within "::tclfpdf::ttf_getCMAP4 $unicode_cmap_offset" (procedure "::tclfpdf::ttf_extractInfo" line 242) invoked from within "::tclfpdf::ttf_extractInfo" (procedure "ttf_getMetrics" line 27) invoked from within "ttf_getMetrics $ttffile" (procedure "AddFont" line 39) invoked from within "AddFont "DejaVu" "" "DejaVuSansCondensed.ttf" 1"

after correction of ttf_font.tcl proc ::tclfpdf::ttf_getCMAP4

row 1091 and 1092 set $offset after set offset

dejavusanscondensed.mtx.tcl

set name "DejaVuSansCondensed" ;
set type "TTF";
array set desc {ItalicAngle 0.0 Flags 4 CapHeight 928 MissingWidth 540 FontBBox {[ -918 -463 1614 1232 ]} Descent -236 Ascent 928 StemV 87};
set up -20;
set ut 44;
set ttffile "~/development/src/tcktk/pdflib/tclfpdf-1.6/font/DejaVuSansCondensed.ttf";
set originalsize 682828;
set fontkey "dejavu";

2.) 665K 18. Sep 2021 DejaVuSansCondensed.ttf

dejavusanscondensed.mtx.tcl

set name "DejaVuSansCondensed" ;
set type "TTF";
array set desc {ItalicAngle 0.0 Flags 4 CapHeight 928 MissingWidth 540 FontBBox {[ -918 -463 1614 1232 ]} Descent -236 Ascent 928 StemV 87};
set up -63;
set ut 44;
set ttffile "~/development/src/tcktk/pdflib/tclfpdf-1.6/font/DejaVuSansCondensed.ttf";
set originalsize 680264;
set fontkey "dejavu";
lamuzzachiodi commented 6 months ago

Your observation is correct. I have the second version ("set originalsize 680264;") and in this case these lines aren't called. I'll fix in 1.7