Re: Jittery text in successive PostScript sequences
Paul Wessel <[email protected]> Wed, 24 Jan 2018 16:57:42 -1000
| Newsgroups | gmane.comp.printing.ghostscript.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Chris et al- Thanks for these suggestions. I've added an option to scale up the dpi by <factor> and use -dDownscaleFactor=<factor> when making the PNGs. Does not seem to take more time and works great! We are very happy with the results. If interested you can see the before and after via these links www.soest.hawaii.edu/pwessel/bug_W1.mp4 <http://www.soest.hawaii.edu/pwessel/bug_W0.mp4> (no factor) www.soest.hawaii.edu/pwessel/bug_W8.mp4 <http://www.soest.hawaii.edu/pwessel/bug_W8.mp4> (factor of 8). The animation is a small 400x250 movie with 601 frames @ 24/sec and now looks very smooth (W8). Perhaps the initial per-character jitter is more of a "feature" than a bug in ghostscript since the problem requires a sequence of images to be noticeable. You guys can be the judge of that. Best regards, and thanks for all the help! Paul > On Jan 23, 2018, at 10:51 PM, Chris Liddell <[email protected]> wrote: > > On 24/01/18 07:55, Paul Wessel wrote: >> Hi Chris, thanks for your comments. >> >>> On Jan 23, 2018, at 9:41 PM, Chris Liddell <[email protected]> wrote: >>> >>> At a guess (and it is a guess), I'd suggest the issue is the low >>> resolution. That will hamper both the accuracy of the stringwidth >>> operation, and the accuracy with which each glyph is placed. >>> >>> It would be interesting to know if the same effect occurs at, say, >>> 300dpi or higher. >> I’ve done up to 800 dpi (3200x2000 pixels) and the jittering is still present, but of course less and less jarring since the pixels are smaller and smaller and the jitter seems to be +/- one pixel. Following a suggestion I have tried to make images 4x the intended resolution and then use graphicsmagic to resize images back to the lower size. This greatly reduces the jitter (but is more work of course). It is certainly a viable workaround. >>> > > In that case, I'd suggest dropping the -dTextAlphaBits=4 and > -dGraphicsAlphaBits=2 and trying out the DownscaleFactor option (I > believe that should work with png). > >>> I'd also try without the -dTextAlphaBits=4 simply to eliminate (or >>> confirm) that as an area of concern. >> I have tried that as well. It only affects the quality of the text, not the jitter. >>> > > Makes the text worse?? (Sorry, I hate anti-aliasing, especially at very > low resolutions!). > > The is interesting, though, since it's a significant change in the data > path for the glyph rendering. > >>> You have quite the morass of irrelevant command line options, there. >>> Most of them are totally irrelevant when producing rendered output >>> formats - they're not having any affect, but I would eliminate them, >>> nevertheless. >> Yes, someone pointed that out too... I will hide away the PDF settings when a raster format is selected. I commented them out for a test and it makes not difference for the jitter. >> >> My guess is that the currentpoint is rounded to nearest pixel, and then [optional] antialiasing is applied after that step, and that this process is repeated on a per-letter basis, yielding different shifts as the rounding goes in different directions. >> > > I don't *think* currentpoint is rounded to pixels, but I suspect that > things like the advance width of glyphs may be. > > Chris > > >>> >>> On 24/01/18 04:14, Paul Wessel wrote: >>>> Hi developers- >>>> >>>> GMT (gmt.soest.hawaii.edu)uses PostScript to make maps and one application builds an animation from sequences of PostScript plots converted to PNG with ghostscript (9.22) and then to MP4 with ffmpeg. We have found a problem that may be a ghostscript bug, or alternatively we are doing something wrong. When using a rotating view (i.e., via a matrix concatenation to simulate different view azimuth (shown in TL corner) [here elevation is fixed at 90 degrees], the resulting text strings "jitter" when viewed as a movie, i.e., the individual letters “dance". For an example, see www.soest.hawaii.edu/pwessel/jittery.mp4. As the movie plays, you will see the INDIVIDUAL letters in the word HELL jitter relative to each other, despite being set via a single show command (shown here is just a snippet of our PostScript code; setting currentpoint, font, etc. are omitted): >>>> >>>> (HELL) dup dup stringwidth pop -2 div exch sh -2 div rmoveto show >>>> >>>> where sh is defined as >>>> >>>> /sh {gsave matrix setmatrix 0 0 moveto true charpath flattenpath pathbbox newpath 4 1 roll pop pop pop grestore} bind def >>>> >>>> [a complete PS example of a single frame can be found here: www.soest.hawaii.edu/pwessel/jittery.ps. >>>> >>>> At first we suspected flattenpath, but HELL (using Helvetica) has no curved segments (?). We also tried to override the flattening with 0.2 setflat, but no difference. We suspect some sort of roundoff but it affects the different letters in the word differently, and that does not appear to be under our control. Could any of the operators we use above to center the string be subject to round-off that affect individual letters? We are using maximum antialiasing (but these settings have no effect on the jitter). An example of the full gs call to build one of the PNG frames is given here: >>>> >>>> gs -q -dSAFER -dNOPAUSE -dBATCH -dPDFSETTINGS=/prepress -dDownsampleColorImages=false -dDownsampleGrayImages=false -dDownsampleMonoImages=false -dUseFlateCompression=true -dEmbedAllFonts=true -dSubsetFonts=true -dMonoImageFilter=/FlateEncode -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dSCANCONVERTERTYPE=2 -dMaxBitmap=2147483647 -dUseFastColor=true -dGraphicsAlphaBits=2 -dTextAlphaBits=4 -sDEVICE=png16m -g400x250 -r100 -sOutputFile=‘jittery_091.png' -f’jittery.ps' >>>> >>>> We are hoping gs developers know where this may happen or if there is anything we can do on our side to remedy the problem. As you can see there is no jittering for plotting a circle or lines. The map frame annotations show the same jittering so it affects all text. >>>> >>>> Thanks for any insight! A zip file with all individual PS and PNG frames is available at www.soest.hawaii.edu/pwessel/jittery.zip. >>>> >>>> FYI, we have tried both tif and jpg instead of png but no difference. We also made PDFs and used OS X Automator to build PNGs and made a movie using QuickTime Pro; same jittering (not sure if OS X High Sierra uses ghostscript in Preview, etc). We have tried small to large (e.g., 4K) resolutions. It seems that although all text (and lines) are correctly anti-aliased, the POSITION of the text items seems rounded to the nearest pixel on a per letter basis. It is this per-letter variability that gives rise the jittery motion. >>>> >>>> Paul Wessel >>>> Lead developer >>>> The Generic Mapping Tools