35 fh = fopen(fname,
" r ");
37 error(
" File %s not found. ", fname);
40 fstrm = fread(fh,
" *char ")^
t;
48 if strcmp(fstrm(1:15),
" %!PS-AdobeFont- ")
50 ind = regexp(fstrm,
" [\n\r]%!PS-Adobe- ");
51 [ind2 ind2] = regexp(fstrm,
" [\n\r]%%EndComments[\n\r]+ ");
53 if ~isempty(ind) && ~isempty(ind2) && ind(1) < ind2(1)
54 fstrm = fstrm([ind(1)+1:ind2(1) 1:ind(1) ind2(1)+1:end]);
61 ind = [regexp(fstrm,
" [\n\r]SO[\n\r] "),...
63 regexp(fstrm,
" [\n\r]DO[\n\r] "),...
64 regexp(fstrm,
" [\n\r]DA[\n\r] "),...
65 regexp(fstrm,
" [\n\r]DD[\n\r] ")];
68 [ind2 ind3] = regexp(fstrm,
" [\n\r]\d* w[\n\r] ");
76 while b <= n && ind2(b) < ind(a)
84 if a < m && ind2(b) > ind(a+1)
88 if (ind2(b) - ind(a)) > 8
92 fstrm(ind(a)+1:ind3(b)) = [fstrm(ind(a)+4:ind3(b)) fstrm(ind(a)+1:ind(a)+3)];
98 ind = int32(regexp(fstrm,
" [\n\r]DO[\n\r] "));
101 ind2 = int32(regexp(fstrm,
" [\n\r] *\d* *\d* *mt *\d* *\d* *L[\n\r] "));
104 ind2 = repmat(ind2^
t, [1 numel(ind)]) - repmat(ind, [numel(ind2) 1]);
105 ind2 = any(ind2 > 0 & ind2 < 12);
109 fstrm(ind+1) =
" G ";
110 fstrm(ind+2) =
" R ";
115 first_sec = strfind(fstrm,
" % line types: ");
116 [second_sec remaining] = strtok(fstrm(first_sec+1:end),
" / ");
117 [remaining remaining] = strtok(remaining,
" % ");
126 new_style = [
" /dom { dpi2point 1 currentlinewidth 0.08 mul add mul mul } bdef ",...
128 " /dam { dpi2point 2 currentlinewidth 0.04 mul add mul mul } bdef ",...
130 " /SO { [] 0 setdash 0 setlinecap } bdef ",...
132 " /DO { [1 dom 1.2 dom] 0 setdash 0 setlinecap } bdef ",...
134 " /DA { [4 dam 1.5 dam] 0 setdash 0 setlinecap } bdef ",...
136 " /DD { [1 dom 1.2 dom 4 dam 1.2 dom] 0 setdash 0 setlinecap } bdef ",...
138 " /GR { [0 dpi2point mul 4 dpi2point mul] 0 setdash 1 setlinecap } bdef "];
147 fh = fopen(fname2,
" w ");
149 error(
" Unable to open %s for writing. ", fname2);
152 fwrite(fh, fstrm(1:first_sec),
" char*1 ");
153 fwrite(fh, second_sec,
" char*1 ");
154 fprintf(fh,
" %s\r ", new_style[:]);
155 fwrite(fh, remaining,
" char*1 ");
function fix_lines(fname, fname2)
FIX_LINES Improves the line style of eps files generated by print.