mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
Fix cantarell conversion
This commit is contained in:
parent
fada053c72
commit
6e88579c56
@ -178,7 +178,7 @@ def createFontMapping(fontlist):
|
|||||||
"sans", "sf", "cantarell", "scaled", "oldstyle")
|
"sans", "sf", "cantarell", "scaled", "oldstyle")
|
||||||
return fm
|
return fm
|
||||||
|
|
||||||
def convert_fonts(document, fm):
|
def convert_fonts(document, fm, osfoption = "osf"):
|
||||||
" Handle font definition (LaTeX preamble -> native) "
|
" Handle font definition (LaTeX preamble -> native) "
|
||||||
|
|
||||||
rpkg = re.compile(r'^\\usepackage(\[([^\]]*)\])?\{([^\}]+)\}')
|
rpkg = re.compile(r'^\\usepackage(\[([^\]]*)\])?\{([^\}]+)\}')
|
||||||
@ -197,7 +197,6 @@ def convert_fonts(document, fm):
|
|||||||
pkg = mo.group(3)
|
pkg = mo.group(3)
|
||||||
o = 0
|
o = 0
|
||||||
oscale = 1
|
oscale = 1
|
||||||
osfoption = "osf"
|
|
||||||
has_osf = False
|
has_osf = False
|
||||||
while o < len(options):
|
while o < len(options):
|
||||||
if options[o] == osfoption:
|
if options[o] == osfoption:
|
||||||
@ -226,12 +225,17 @@ def convert_fonts(document, fm):
|
|||||||
fontscale = "\\font_" + fontinfo.scaletype + "_scale"
|
fontscale = "\\font_" + fontinfo.scaletype + "_scale"
|
||||||
fontinfo.scaleval = oscale
|
fontinfo.scaleval = oscale
|
||||||
if has_osf:
|
if has_osf:
|
||||||
if fontinfo.osfopt == None:
|
if fontinfo.osfopt == None:
|
||||||
options.extend("osf")
|
options.extend(osfoption)
|
||||||
continue
|
continue
|
||||||
osf = find_token(document.header, "\\font_osf false")
|
osf = find_token(document.header, "\\font_osf false")
|
||||||
if osf != -1:
|
osftag = "\\font_osf"
|
||||||
document.header[osf] = "\\font_osf true"
|
if osf == -1 and fontinfo.fonttype != "math":
|
||||||
|
# Try with newer format
|
||||||
|
osftag = "\\font_" + fontinfo.fonttype + "_osf"
|
||||||
|
osf = find_token(document.header, osftag + " false")
|
||||||
|
if osf != -1:
|
||||||
|
document.header[osf] = osftag + " true"
|
||||||
if i > 0 and document.preamble[i-1] == "% Added by lyx2lyx":
|
if i > 0 and document.preamble[i-1] == "% Added by lyx2lyx":
|
||||||
del document.preamble[i-1]
|
del document.preamble[i-1]
|
||||||
i -= 1
|
i -= 1
|
||||||
@ -2857,7 +2861,7 @@ def convert_CantarellFont(document):
|
|||||||
|
|
||||||
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
|
if find_token(document.header, "\\use_non_tex_fonts false", 0) != -1:
|
||||||
fm = createFontMapping(['Cantarell'])
|
fm = createFontMapping(['Cantarell'])
|
||||||
convert_fonts(document, fm)
|
convert_fonts(document, fm, "oldstyle")
|
||||||
|
|
||||||
def revert_CantarellFont(document):
|
def revert_CantarellFont(document):
|
||||||
" Revert native Cantarell font definition to LaTeX "
|
" Revert native Cantarell font definition to LaTeX "
|
||||||
|
Loading…
Reference in New Issue
Block a user