Re: test of math previews (was: [LyX/master] Really fix bug #9354)

2015-06-02 Thread Enrico Forestieri
On Mon, Jun 01, 2015 at 08:50:49PM +0200, Jürgen Spitzmüller wrote:

 2015-06-01 19:34 GMT+02:00 Enrico Forestieri for...@lyx.org:
 
  On Mon, Jun 01, 2015 at 03:50:49PM +0200, Enrico Forestieri wrote:
   On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
   
1) b3d2ffc0 introduces a regression in stable and master wrt 2.1.3.
  See the
attached lyx-bug-font2.lyx. This is because legacy_lyxpreview2ppm.py
  now
includes the font lmodern (L236). I do not understand this addition:
  font
setting is already done in the preamble. Removing the line fixes the
  issue.
  
   It was added in order to have vector fonts, otherwise the previews
   generated by the legacy method would be of very poor quality. It is
   difficult to determine what a user could do in the preamble and whether
   it is safe using lmodern or not. However, given that it may produce
  issues,
   it may be better not using it, if nobody has a better idea.
 
  Jürgen, any idea on this one?
 
 
 lmodern must only be loaded if no other font has been loaded, i.e. if
 computer modern is the active font:
 
 \def\tempa{cmr}
 
 \ifx\f@family\tempa\usepackage{lmodern}\else\fi

Thanks. I have applied a fix based on your suggestion.

-- 
Enrico


Re: test of math previews (was: [LyX/master] Really fix bug #9354)

2015-06-02 Thread Enrico Forestieri
On Mon, Jun 01, 2015 at 08:50:49PM +0200, Jürgen Spitzmüller wrote:

> 2015-06-01 19:34 GMT+02:00 Enrico Forestieri :
> 
> > On Mon, Jun 01, 2015 at 03:50:49PM +0200, Enrico Forestieri wrote:
> > > On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
> > > >
> > > > 1) b3d2ffc0 introduces a regression in stable and master wrt 2.1.3.
> > See the
> > > > attached lyx-bug-font2.lyx. This is because legacy_lyxpreview2ppm.py
> > now
> > > > includes the font lmodern (L236). I do not understand this addition:
> > font
> > > > setting is already done in the preamble. Removing the line fixes the
> > issue.
> > >
> > > It was added in order to have vector fonts, otherwise the previews
> > > generated by the legacy method would be of very poor quality. It is
> > > difficult to determine what a user could do in the preamble and whether
> > > it is safe using lmodern or not. However, given that it may produce
> > issues,
> > > it may be better not using it, if nobody has a better idea.
> >
> > Jürgen, any idea on this one?
> >
> 
> lmodern must only be loaded if no other font has been loaded, i.e. if
> computer modern is the active font:
> 
> \def\tempa{cmr}
> 
> \ifx\f@family\tempa\usepackage{lmodern}\else\fi

Thanks. I have applied a fix based on your suggestion.

-- 
Enrico


Re: test of math previews (was: [LyX/master] Really fix bug #9354)

2015-06-01 Thread Enrico Forestieri
On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
 
 In fact it does not work entirely in master. There is a regression (after
 bc47054b I believe) because compilation can now fail due to \renewcommandx
 being used without the command being defined prior to that (try the attached
 lyx-bug-renewcommandx.lyx). (Stable is fine in this regard after your commit
 9285f338, it seems.) http://www.lyx.org/trac/ticket/6369
 
 One quick solution would be to prepend all \renewcommandx\a{b} with
 \providecommand\a{}.

I think this was already addressed by Jürgen at 83a9ed4e.

 Here are other conclusions from my test of stable and master this week-end:
 
 1) b3d2ffc0 introduces a regression in stable and master wrt 2.1.3. See the
 attached lyx-bug-font2.lyx. This is because legacy_lyxpreview2ppm.py now
 includes the font lmodern (L236). I do not understand this addition: font
 setting is already done in the preamble. Removing the line fixes the issue.

It was added in order to have vector fonts, otherwise the previews
generated by the legacy method would be of very poor quality. It is
difficult to determine what a user could do in the preamble and whether
it is safe using lmodern or not. However, given that it may produce issues,
it may be better not using it, if nobody has a better idea.

 2) In master, preview incorrectly calls latex instead of pdflatex if the
 default output format is set to default. More details in the attached
 lyx-bug-microtype.lyx. (It causes the instant preview to fail, while the
 default (pdflatex) compilation with Ctrl+R succeeds.)
 Stable also fails because it seems to call latex instead of pdflatex all the
 time, but it does not appear to be a regression wrt 2.1.3.

Note that we have to guarantee backward compatibility and using latex
when the document does not specify a default output format is a must,
otherwise instant preview may fail for existing documents.
See #9371 for details.

When using pdflatex (or other formats producing a pdf) for generating
the previews, the legacy method is used. It turns out to be much slower
than the dvipng route, so that care is taken to try to use dvi output for
all previews not failing and then trying pdflatex for those that fail.
For some reason, the failure you report escapes those checks. So, this
reason should be identified and accordingly corrected. Typically, in
open source projects one can suggest a patch to speed up the correction
of an issue.

 3) As reported in #6369, InstantPreview multiplies math macros
 definitions. Although the particular compilation issue has been solved, the
 duplication of macro definitions is not fixed. This has performance
 consequences. In stable and master, opening a moderately-sized math article
 (10-20 pages) with instant preview activated results in 75s of full CPU
 usage (and more when latex is called incorrectly instead of pdflatex), 55s
 during which LyX is unresponsive (and just generates the tex file). The
 instant preview tex file is 55 lines long and is 16MB big, mainly
 comprised of macro definitions (maybe there is another performance
 bottleneck, but this is probably one). So instant preview is still unusable
 for me (at least until the instant preview inset supports math macros---BTW
 the patch http://www.lyx.org/trac/attachment/ticket/9354/9354.diff works
 well for me).

This is not my experience. Instant preview snippets for the math manual
(which surely qualifies as a medium-sized math article) are generated in
about 10 seconds on my old and slow laptop and the instant preview tex
file is about 50Kb.

 4) Using Ctrl+Mousewheel to zoom sometimes results in a preview of the wrong
 size. LyX recreates the previews when zooming, and sometimes we end up with
 an intermediary size of preview inconsistent with the size of the text (race
 condition?).

The previous are generated asynchronously, thus, if you change the zoom while
they are still being generated, you may end up with different sizes. This
can be improved, of course. Maybe using Ctrl+Mousewheel may generate
multiple sizes at once and this causes that issue. Try using the Alt+ and
Alt- shortcuts (and wait for the previews to be generated before using
them again).

 (BTW why redoing preview from scratch when the pdf is already generated? Why
 not keeping the each preview as a pdfs, displayed on the fly by LyX using
 Cairo, when actually needed? This sounds vastly more efficient.)

There is the problem of assuring that the previews are still the same and
not actually changed. ATM there is no way to trigger a different way for
the regeneration due to zooming. Also in this case, I think that a patch
would be thoughtfully considered, but I doubt it can lead to a significant
speed up, as the most part of the time is spent in converting the pdfs
rather than regenerating them.

 3+4) Zooming with Ctrl+mousewheel is impossible with instant preview
 activated in a reasonably-sized document as a combination of 3) and 4). LyX
 freezes as soon 

Re: test of math previews (was: [LyX/master] Really fix bug #9354)

2015-06-01 Thread Enrico Forestieri
On Mon, Jun 01, 2015 at 03:50:49PM +0200, Enrico Forestieri wrote:
 On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
  
  2) In master, preview incorrectly calls latex instead of pdflatex if the
  default output format is set to default. More details in the attached
  lyx-bug-microtype.lyx. (It causes the instant preview to fail, while the
  default (pdflatex) compilation with Ctrl+R succeeds.)
  Stable also fails because it seems to call latex instead of pdflatex all the
  time, but it does not appear to be a regression wrt 2.1.3.
 
 Note that we have to guarantee backward compatibility and using latex
 when the document does not specify a default output format is a must,
 otherwise instant preview may fail for existing documents.
 See #9371 for details.
 
 When using pdflatex (or other formats producing a pdf) for generating
 the previews, the legacy method is used. It turns out to be much slower
 than the dvipng route, so that care is taken to try to use dvi output for
 all previews not failing and then trying pdflatex for those that fail.
 For some reason, the failure you report escapes those checks. So, this
 reason should be identified and accordingly corrected. Typically, in
 open source projects one can suggest a patch to speed up the correction
 of an issue.

I had a closer look at this issue and it turned out to be as follows.
If a snippet produces latex errors it is now not previewed at all.
Now, when using the microtype package in dvi mode, latex issues an
error about not finding the tfm file for a font, but nevertheless
goes on and produces a correct output. This error is issued only at
the beginning so that it associated with the first snippet, which is
for this reason marked as bad. Actually, the script generates a valid
preview but it is not used. All other snippets are used, so only the
first one is omitted even if it would be Ok.

There are 2 possible solutions. The first one is omitting the microtype
package for the sake of generating the previews by using the faster
dvipng method (attached patch no-microtype.diff for master).
The second one is forcing the use of pdflatex when the use of microtype
is detected. In this case the slower legacy mathod will be used for
generating the previews (attached patch yes-microtype.diff for master).

Please, vote for the one or the other. I will commit the patch getting
more votes.

I also noticed that when microtype is used in dvi mode latex takes a
lot more of time to process the same file. Maybe this is the cause of
the slowdown observed by Guillaume.

-- 
Enrico
diff --git a/lib/scripts/lyxpreview2bitmap.py b/lib/scripts/lyxpreview2bitmap.py
index 5eca959..9d46054 100755
--- a/lib/scripts/lyxpreview2bitmap.py
+++ b/lib/scripts/lyxpreview2bitmap.py
@@ -160,11 +160,17 @@ def extract_metrics_info(dvipng_stdout):
 
 def fix_latex_file(latex_file):
 documentclass_re = re.compile((documentclass\[)(1[012]pt,?)(.+))
+microtype_re = re.compile(usepackage.*\{microtype\})
 
 tmp = mkstemp()
 
 changed = 0
 for line in open(latex_file, 'r').readlines():
+match = microtype_re.match(line)
+if match != None:
+changed = 1
+continue
+
 match = documentclass_re.match(line)
 if match == None:
 tmp.write(line)
diff --git a/lib/scripts/lyxpreview2bitmap.py b/lib/scripts/lyxpreview2bitmap.py
index 5eca959..3aec16f 100755
--- a/lib/scripts/lyxpreview2bitmap.py
+++ b/lib/scripts/lyxpreview2bitmap.py
@@ -160,11 +160,17 @@ def extract_metrics_info(dvipng_stdout):
 
 def fix_latex_file(latex_file):
 documentclass_re = re.compile((documentclass\[)(1[012]pt,?)(.+))
+microtype_re = re.compile(usepackage.*\{microtype\})
 
 tmp = mkstemp()
 
+force_pdf_output = 0
 changed = 0
 for line in open(latex_file, 'r').readlines():
+match = microtype_re.match(line)
+if match != None:
+force_pdf_output = 1
+
 match = documentclass_re.match(line)
 if match == None:
 tmp.write(line)
@@ -176,7 +182,7 @@ def fix_latex_file(latex_file):
 if changed:
 copyfileobj(tmp, open(latex_file,wb), 1)
 
-return changed
+return force_pdf_output
 
 
 def convert_to_ppm_format(pngtopnm, basename):
@@ -384,6 +390,12 @@ def main(argv):
 # These flavors of latex are known to produce pdf output
 pdf_output = latex in pdflatex_commands
 
+# Omit font size specification in latex file.
+force_pdf_output = fix_latex_file(latex_file)
+if force_pdf_output and not pdf_output:
+pdf_output = True
+latex = pdflatex
+
 progress(Latex command: %s % latex)
 progress(Latex produces pdf output: %s % pdf_output)
 progress(Bibtex command: %s % bibtex)
@@ -391,10 +403,6 @@ def main(argv):
 progress(Preprocess through lilypond-book: %s % lilypond)
 progress(Altering the latex file for font size and colors)
 
-# Omit font size specification in latex file and 

Re: test of math previews (was: [LyX/master] Really fix bug #9354)

2015-06-01 Thread Enrico Forestieri
On Mon, Jun 01, 2015 at 03:50:49PM +0200, Enrico Forestieri wrote:
 On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
  
  1) b3d2ffc0 introduces a regression in stable and master wrt 2.1.3. See the
  attached lyx-bug-font2.lyx. This is because legacy_lyxpreview2ppm.py now
  includes the font lmodern (L236). I do not understand this addition: font
  setting is already done in the preamble. Removing the line fixes the issue.
 
 It was added in order to have vector fonts, otherwise the previews
 generated by the legacy method would be of very poor quality. It is
 difficult to determine what a user could do in the preamble and whether
 it is safe using lmodern or not. However, given that it may produce issues,
 it may be better not using it, if nobody has a better idea.

Jürgen, any idea on this one?

-- 
Enrico


Re: test of math previews (was: [LyX/master] Really fix bug #9354)

2015-06-01 Thread Jürgen Spitzmüller
2015-06-01 19:34 GMT+02:00 Enrico Forestieri for...@lyx.org:

 On Mon, Jun 01, 2015 at 03:50:49PM +0200, Enrico Forestieri wrote:
  On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
  
   1) b3d2ffc0 introduces a regression in stable and master wrt 2.1.3.
 See the
   attached lyx-bug-font2.lyx. This is because legacy_lyxpreview2ppm.py
 now
   includes the font lmodern (L236). I do not understand this addition:
 font
   setting is already done in the preamble. Removing the line fixes the
 issue.
 
  It was added in order to have vector fonts, otherwise the previews
  generated by the legacy method would be of very poor quality. It is
  difficult to determine what a user could do in the preamble and whether
  it is safe using lmodern or not. However, given that it may produce
 issues,
  it may be better not using it, if nobody has a better idea.

 Jürgen, any idea on this one?


lmodern must only be loaded if no other font has been loaded, i.e. if
computer modern is the active font:

\def\tempa{cmr}

\ifx\f@family\tempa\usepackage{lmodern}\else\fi

Jürgen


Re: test of math previews (was: [LyX/master] Really fix bug #9354)

2015-06-01 Thread Enrico Forestieri
On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
> 
> In fact it does not work entirely in master. There is a regression (after
> bc47054b I believe) because compilation can now fail due to \renewcommandx
> being used without the command being defined prior to that (try the attached
> lyx-bug-renewcommandx.lyx). (Stable is fine in this regard after your commit
> 9285f338, it seems.) 
> 
> One quick solution would be to prepend all \renewcommandx\a{b} with
> \providecommand\a{}.

I think this was already addressed by Jürgen at 83a9ed4e.

> Here are other conclusions from my test of stable and master this week-end:
> 
> 1) b3d2ffc0 introduces a regression in stable and master wrt 2.1.3. See the
> attached lyx-bug-font2.lyx. This is because legacy_lyxpreview2ppm.py now
> includes the font lmodern (L236). I do not understand this addition: font
> setting is already done in the preamble. Removing the line fixes the issue.

It was added in order to have vector fonts, otherwise the previews
generated by the legacy method would be of very poor quality. It is
difficult to determine what a user could do in the preamble and whether
it is safe using lmodern or not. However, given that it may produce issues,
it may be better not using it, if nobody has a better idea.

> 2) In master, preview incorrectly calls latex instead of pdflatex if the
> default output format is set to "default". More details in the attached
> lyx-bug-microtype.lyx. (It causes the instant preview to fail, while the
> "default" (pdflatex) compilation with Ctrl+R succeeds.)
> Stable also fails because it seems to call latex instead of pdflatex all the
> time, but it does not appear to be a regression wrt 2.1.3.

Note that we have to guarantee backward compatibility and using latex
when the document does not specify a default output format is a must,
otherwise instant preview may fail for existing documents.
See #9371 for details.

When using pdflatex (or other formats producing a pdf) for generating
the previews, the legacy method is used. It turns out to be much slower
than the dvipng route, so that care is taken to try to use dvi output for
all previews not failing and then trying pdflatex for those that fail.
For some reason, the failure you report escapes those checks. So, this
reason should be identified and accordingly corrected. Typically, in
open source projects one can suggest a patch to speed up the correction
of an issue.

> 3) As reported in #6369, "InstantPreview multiplies math macros
> definitions". Although the particular compilation issue has been solved, the
> duplication of macro definitions is not fixed. This has performance
> consequences. In stable and master, opening a moderately-sized math article
> (10-20 pages) with instant preview activated results in 75s of full CPU
> usage (and more when latex is called incorrectly instead of pdflatex), 55s
> during which LyX is unresponsive (and just generates the tex file). The
> instant preview tex file is 55 lines long and is 16MB big, mainly
> comprised of macro definitions (maybe there is another performance
> bottleneck, but this is probably one). So instant preview is still unusable
> for me (at least until the instant preview inset supports math macros---BTW
> the patch  works
> well for me).

This is not my experience. Instant preview snippets for the math manual
(which surely qualifies as a medium-sized math article) are generated in
about 10 seconds on my old and slow laptop and the instant preview tex
file is about 50Kb.

> 4) Using Ctrl+Mousewheel to zoom sometimes results in a preview of the wrong
> size. LyX recreates the previews when zooming, and sometimes we end up with
> an intermediary size of preview inconsistent with the size of the text (race
> condition?).

The previous are generated asynchronously, thus, if you change the zoom while
they are still being generated, you may end up with different sizes. This
can be improved, of course. Maybe using Ctrl+Mousewheel may generate
multiple sizes at once and this causes that issue. Try using the Alt+ and
Alt- shortcuts (and wait for the previews to be generated before using
them again).

> (BTW why redoing preview from scratch when the pdf is already generated? Why
> not keeping the each preview as a pdfs, displayed on the fly by LyX using
> Cairo, when actually needed? This sounds vastly more efficient.)

There is the problem of assuring that the previews are still the same and
not actually changed. ATM there is no way to trigger a different way for
the regeneration due to zooming. Also in this case, I think that a patch
would be thoughtfully considered, but I doubt it can lead to a significant
speed up, as the most part of the time is spent in converting the pdfs
rather than regenerating them.

> 3+4) Zooming with Ctrl+mousewheel is impossible with instant preview
> activated in a reasonably-sized document 

Re: test of math previews (was: [LyX/master] Really fix bug #9354)

2015-06-01 Thread Enrico Forestieri
On Mon, Jun 01, 2015 at 03:50:49PM +0200, Enrico Forestieri wrote:
> On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
> > 
> > 2) In master, preview incorrectly calls latex instead of pdflatex if the
> > default output format is set to "default". More details in the attached
> > lyx-bug-microtype.lyx. (It causes the instant preview to fail, while the
> > "default" (pdflatex) compilation with Ctrl+R succeeds.)
> > Stable also fails because it seems to call latex instead of pdflatex all the
> > time, but it does not appear to be a regression wrt 2.1.3.
> 
> Note that we have to guarantee backward compatibility and using latex
> when the document does not specify a default output format is a must,
> otherwise instant preview may fail for existing documents.
> See #9371 for details.
> 
> When using pdflatex (or other formats producing a pdf) for generating
> the previews, the legacy method is used. It turns out to be much slower
> than the dvipng route, so that care is taken to try to use dvi output for
> all previews not failing and then trying pdflatex for those that fail.
> For some reason, the failure you report escapes those checks. So, this
> reason should be identified and accordingly corrected. Typically, in
> open source projects one can suggest a patch to speed up the correction
> of an issue.

I had a closer look at this issue and it turned out to be as follows.
If a snippet produces latex errors it is now not previewed at all.
Now, when using the microtype package in dvi mode, latex issues an
error about not finding the tfm file for a font, but nevertheless
goes on and produces a correct output. This error is issued only at
the beginning so that it associated with the first snippet, which is
for this reason marked as bad. Actually, the script generates a valid
preview but it is not used. All other snippets are used, so only the
first one is omitted even if it would be Ok.

There are 2 possible solutions. The first one is omitting the microtype
package for the sake of generating the previews by using the faster
dvipng method (attached patch no-microtype.diff for master).
The second one is forcing the use of pdflatex when the use of microtype
is detected. In this case the slower legacy mathod will be used for
generating the previews (attached patch yes-microtype.diff for master).

Please, vote for the one or the other. I will commit the patch getting
more votes.

I also noticed that when microtype is used in dvi mode latex takes a
lot more of time to process the same file. Maybe this is the cause of
the slowdown observed by Guillaume.

-- 
Enrico
diff --git a/lib/scripts/lyxpreview2bitmap.py b/lib/scripts/lyxpreview2bitmap.py
index 5eca959..9d46054 100755
--- a/lib/scripts/lyxpreview2bitmap.py
+++ b/lib/scripts/lyxpreview2bitmap.py
@@ -160,11 +160,17 @@ def extract_metrics_info(dvipng_stdout):
 
 def fix_latex_file(latex_file):
 documentclass_re = re.compile("(documentclass\[)(1[012]pt,?)(.+)")
+microtype_re = re.compile("usepackage.*\{microtype\}")
 
 tmp = mkstemp()
 
 changed = 0
 for line in open(latex_file, 'r').readlines():
+match = microtype_re.match(line)
+if match != None:
+changed = 1
+continue
+
 match = documentclass_re.match(line)
 if match == None:
 tmp.write(line)
diff --git a/lib/scripts/lyxpreview2bitmap.py b/lib/scripts/lyxpreview2bitmap.py
index 5eca959..3aec16f 100755
--- a/lib/scripts/lyxpreview2bitmap.py
+++ b/lib/scripts/lyxpreview2bitmap.py
@@ -160,11 +160,17 @@ def extract_metrics_info(dvipng_stdout):
 
 def fix_latex_file(latex_file):
 documentclass_re = re.compile("(documentclass\[)(1[012]pt,?)(.+)")
+microtype_re = re.compile("usepackage.*\{microtype\}")
 
 tmp = mkstemp()
 
+force_pdf_output = 0
 changed = 0
 for line in open(latex_file, 'r').readlines():
+match = microtype_re.match(line)
+if match != None:
+force_pdf_output = 1
+
 match = documentclass_re.match(line)
 if match == None:
 tmp.write(line)
@@ -176,7 +182,7 @@ def fix_latex_file(latex_file):
 if changed:
 copyfileobj(tmp, open(latex_file,"wb"), 1)
 
-return changed
+return force_pdf_output
 
 
 def convert_to_ppm_format(pngtopnm, basename):
@@ -384,6 +390,12 @@ def main(argv):
 # These flavors of latex are known to produce pdf output
 pdf_output = latex in pdflatex_commands
 
+# Omit font size specification in latex file.
+force_pdf_output = fix_latex_file(latex_file)
+if force_pdf_output and not pdf_output:
+pdf_output = True
+latex = "pdflatex"
+
 progress("Latex command: %s" % latex)
 progress("Latex produces pdf output: %s" % pdf_output)
 progress("Bibtex command: %s" % bibtex)
@@ -391,10 +403,6 @@ def main(argv):
 progress("Preprocess through lilypond-book: %s" % lilypond)
 progress("Altering the latex file for font size and colors")
 

Re: test of math previews (was: [LyX/master] Really fix bug #9354)

2015-06-01 Thread Enrico Forestieri
On Mon, Jun 01, 2015 at 03:50:49PM +0200, Enrico Forestieri wrote:
> On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
> > 
> > 1) b3d2ffc0 introduces a regression in stable and master wrt 2.1.3. See the
> > attached lyx-bug-font2.lyx. This is because legacy_lyxpreview2ppm.py now
> > includes the font lmodern (L236). I do not understand this addition: font
> > setting is already done in the preamble. Removing the line fixes the issue.
> 
> It was added in order to have vector fonts, otherwise the previews
> generated by the legacy method would be of very poor quality. It is
> difficult to determine what a user could do in the preamble and whether
> it is safe using lmodern or not. However, given that it may produce issues,
> it may be better not using it, if nobody has a better idea.

Jürgen, any idea on this one?

-- 
Enrico


Re: test of math previews (was: [LyX/master] Really fix bug #9354)

2015-06-01 Thread Jürgen Spitzmüller
2015-06-01 19:34 GMT+02:00 Enrico Forestieri :

> On Mon, Jun 01, 2015 at 03:50:49PM +0200, Enrico Forestieri wrote:
> > On Mon, Jun 01, 2015 at 07:26:55AM +0100, Guillaume M-M wrote:
> > >
> > > 1) b3d2ffc0 introduces a regression in stable and master wrt 2.1.3.
> See the
> > > attached lyx-bug-font2.lyx. This is because legacy_lyxpreview2ppm.py
> now
> > > includes the font lmodern (L236). I do not understand this addition:
> font
> > > setting is already done in the preamble. Removing the line fixes the
> issue.
> >
> > It was added in order to have vector fonts, otherwise the previews
> > generated by the legacy method would be of very poor quality. It is
> > difficult to determine what a user could do in the preamble and whether
> > it is safe using lmodern or not. However, given that it may produce
> issues,
> > it may be better not using it, if nobody has a better idea.
>
> Jürgen, any idea on this one?
>

lmodern must only be loaded if no other font has been loaded, i.e. if
computer modern is the active font:

\def\tempa{cmr}

\ifx\f@family\tempa\usepackage{lmodern}\else\fi

Jürgen