Enrico Forestieri wrote: > Hi all! > > For some reason the dvipng distributed with miktex (at least the one I > have installed) fails to generate the instant preview images: > > $ python /path/to/lyxpreview2bitmap.py png 0lyxpreview.tex 128 000000 > f0f0f0 makepk: METAFONT failed on "cmmi12".
You need to refresh the MikTeX databases. It's some obvious entry in the package manager's menus. If you can't find it then this is a FAQ on the MikTeX list. (Sorry I can't be less vague :() > So, I tried to force using the legacy_lyxpreview2ppm.py script only to > discover that it can only generate ppm images (as its name implies ;-)). What would be *clever* would be to use pvipng if it exists and to parse its error stream for any "unable to handle PostScript special" type messages, falling back on the dvips->ppm/png conversion route. > I propose the patch at the bottom to also allow png generation in the > legacy script. The patch also addresses the problem that when "ascent" or > "descent" are zero, then the generated image is not correctly aligned on > its baseline with the surrounding text. > > Another problem I faced is the following. When not specifying a > \preview_scale_factor in preferences, the instant-preview inlined > equations are perfectly aligned on the baseline, but specifying, for > example, "\preview_scale_factor 1.02" causes the inlined images to be > shifted down by a noticeable amount. > > I obviated to this by hardcoding in the conversion script "frac = > 1.02*frac", after frac is evaluated in extract_metrics_info(), where 1.02 > matches my \preview_scale_factor. I think that this should be done in the > LyX sources but I didn't had a look at it. Hmmmmm. But we already pass preview_scale_factor to the script in the form of the dpi variable. Why do we need to use it twice? The patch looks good to me but I guess that this block in legacy_lyxpreview2bitmap.py (renamed ;-)) will need to be specialised for ppm files only... # Crop the images if pnmcrop != None: crop_files(pnmcrop, latex_file_re.sub("", latex_file)) I guess that's there's going to be some interaction between this cropping and the veracity of the metric info... -- Angus