@@ -57,24 +57,31 @@ pub fn default() string {
5757 if os.is_file (xml_file) && os.is_readable (xml_file) {
5858 xml := os.read_file (xml_file) or { continue }
5959 lines := xml.split ('\n ' )
60- unsafe { xml.free () }
6160 mut candidate_font := ''
6261 for line in lines {
6362 if line.contains ('<font' ) {
64- candidate_font = line.all_after ('>' ).all_before ('<' ).trim (' \n\t\r ' )
63+ tmp1 := line.all_after ('>' )
64+ tmp2 := tmp1 .all_before ('<' )
65+ tmp3 := tmp2 .trim (' \n\t\r ' )
66+ mut_assign (candidate_font, tmp3 )
6567 if candidate_font.contains ('.ttf' ) {
6668 for location in font_locations {
67- candidate_path := os.join_path (location, candidate_font)
69+ candidate_path := os.join_path_single (location, candidate_font)
6870 if os.is_file (candidate_path) && os.is_readable (candidate_path) {
6971 debug_font_println ('Using font "${candidate_path} "' )
7072 return candidate_path
7173 }
7274 unsafe { candidate_path.free () }
7375 }
7476 }
77+ unsafe { tmp3 .free () }
78+ unsafe { tmp2 .free () }
79+ unsafe { tmp1 .free () }
7580 }
7681 }
7782 unsafe { candidate_font.free () }
83+ unsafe { lines.free () }
84+ unsafe { xml.free () }
7885 }
7986 }
8087 unsafe { font_locations.free () }
@@ -157,6 +164,7 @@ pub fn get_path_variant(font_path string, variant Variant) string {
157164 return res
158165}
159166
167+ @[manualfree]
160168fn mut_replace (s & string , find string , replacement string ) {
161169 new := (* s).replace (find, replacement)
162170 unsafe { s.free () }
@@ -165,6 +173,7 @@ fn mut_replace(s &string, find string, replacement string) {
165173 }
166174}
167175
176+ @[manualfree]
168177fn mut_plus (s & string , tail string ) {
169178 new := (* s) + tail
170179 unsafe { s.free () }
@@ -173,6 +182,7 @@ fn mut_plus(s &string, tail string) {
173182 }
174183}
175184
185+ @[manualfree]
176186fn mut_assign (s & string , value string ) {
177187 unsafe { s.free () }
178188 unsafe {
0 commit comments