# Use write_metrics_info to create the .metrics file with this info
def legacy_extract_metrics_info(log_file):
- log_re = re.compile("Preview: ([ST])")
- data_re = re.compile("(-?[0-9]+) (-?[0-9]+) (-?[0-9]+) (-?[0-9]+)")
+ log_re = re.compile(b"Preview: ([ST])")
+ data_re = re.compile(b"(-?[0-9]+) (-?[0-9]+) (-?[0-9]+) (-?[0-9]+)")
tp_ascent = 0.0
tp_descent = 0.0
success = 0
results = []
try:
- for line in open(log_file, 'r').readlines():
+ for line in open(log_file, 'rb').readlines():
match = log_re.match(line)
if match == None:
continue
- snippet = (match.group(1) == 'S')
+ snippet = (match.group(1) == b'S')
success = 1
match = data_re.search(line)
if match == None:
return results
def extract_resolution(log_file, dpi):
- fontsize_re = re.compile("Preview: Fontsize")
- magnification_re = re.compile("Preview: Magnification")
- extract_decimal_re = re.compile("([0-9\.]+)")
- extract_integer_re = re.compile("([0-9]+)")
+ fontsize_re = re.compile(b"Preview: Fontsize")
+ magnification_re = re.compile(b"Preview: Magnification")
+ extract_decimal_re = re.compile(br"([0-9\.]+)")
+ extract_integer_re = re.compile(b"([0-9]+)")
found_fontsize = 0
found_magnification = 0
fontsize = 10.0
try:
- for line in open(log_file, 'r').readlines():
+ for line in open(log_file, 'rb').readlines():
if found_fontsize and found_magnification:
break
else:
tmp.write(b"""
\\usepackage{color}
-\\definecolor{fg}{rgb}{%s}
-\\definecolor{bg}{rgb}{%s}
-\\pagecolor{bg}
+\\definecolor{lyxfg}{rgb}{%s}
+\\definecolor{lyxbg}{rgb}{%s}
+\\pagecolor{lyxbg}
\\usepackage{polyglossia}
""" % (fg_color_gr, bg_color_gr))
polyglossia = True
if not polyglossia:
tmp.write(b"""
\\usepackage{color}
-\\definecolor{fg}{rgb}{%s}
-\\definecolor{bg}{rgb}{%s}
-\\pagecolor{bg}
+\\definecolor{lyxfg}{rgb}{%s}
+\\definecolor{lyxbg}{rgb}{%s}
+\\pagecolor{lyxbg}
\\usepackage[%s,tightpage]{preview}
\\makeatletter
\\def\\t@a{cmr}
\\if\\f@family\\t@a
\\IfFileExists{lmodern.sty}{\\usepackage{lmodern}}{\\usepackage{ae,aecompl}}
\\fi
-\\g@addto@macro\\preview{\\begingroup\\color{bg}\\special{ps::clippath fill}\\color{fg}}
+\\g@addto@macro\\preview{\\begingroup\\color{lyxbg}\\special{ps::clippath fill}\\color{lyxfg}}
\\g@addto@macro\\endpreview{\\endgroup}
\\makeatother
""" % (fg_color_gr, bg_color_gr, previewopts))
tmp.write(b"""
\\usepackage[%s,tightpage]{preview}
\\makeatletter
-\\g@addto@macro\\preview{\\begingroup\\color{bg}\\special{ps::clippath fill}\\color{fg}}
+\\g@addto@macro\\preview{\\begingroup\\color{lyxbg}\\special{ps::clippath fill}\\color{lyxfg}}
\\g@addto@macro\\endpreview{\\endgroup}
\\makeatother
""" % previewopts)