gg: improve font loading diagnostics with `-d debug_font`
							parent
							
								
									5f3dcde358
								
							
						
					
					
						commit
						8be64ef80e
					
				| 
						 | 
					@ -65,6 +65,7 @@ fn new_ft(c FTConfig) ?&FT {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						mut normal_path := c.font_path
 | 
				
			||||||
	mut bytes := []byte{}
 | 
						mut bytes := []byte{}
 | 
				
			||||||
	$if android {
 | 
						$if android {
 | 
				
			||||||
		// First try any filesystem paths
 | 
							// First try any filesystem paths
 | 
				
			||||||
| 
						 | 
					@ -82,26 +83,33 @@ fn new_ft(c FTConfig) ?&FT {
 | 
				
			||||||
			return none
 | 
								return none
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	bold_path := if c.custom_bold_font_path != '' {
 | 
						mut bold_path := if c.custom_bold_font_path != '' {
 | 
				
			||||||
		c.custom_bold_font_path
 | 
							c.custom_bold_font_path
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		get_font_path_variant(c.font_path, .bold)
 | 
							get_font_path_variant(c.font_path, .bold)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	bytes_bold := os.read_bytes(bold_path) or {
 | 
						bytes_bold := os.read_bytes(bold_path) or {
 | 
				
			||||||
		debug_font_println('failed to load font "$bold_path"')
 | 
							debug_font_println('failed to load font "$bold_path"')
 | 
				
			||||||
 | 
							bold_path = c.font_path
 | 
				
			||||||
		bytes
 | 
							bytes
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	mono_path := get_font_path_variant(c.font_path, .mono)
 | 
						mut mono_path := get_font_path_variant(c.font_path, .mono)
 | 
				
			||||||
	bytes_mono := os.read_bytes(mono_path) or {
 | 
						bytes_mono := os.read_bytes(mono_path) or {
 | 
				
			||||||
		debug_font_println('failed to load font "$mono_path"')
 | 
							debug_font_println('failed to load font "$mono_path"')
 | 
				
			||||||
 | 
							mono_path = c.font_path
 | 
				
			||||||
		bytes
 | 
							bytes
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	italic_path := get_font_path_variant(c.font_path, .italic)
 | 
						mut italic_path := get_font_path_variant(c.font_path, .italic)
 | 
				
			||||||
	bytes_italic := os.read_bytes(italic_path) or {
 | 
						bytes_italic := os.read_bytes(italic_path) or {
 | 
				
			||||||
		debug_font_println('failed to load font "$italic_path"')
 | 
							debug_font_println('failed to load font "$italic_path"')
 | 
				
			||||||
 | 
							italic_path = c.font_path
 | 
				
			||||||
		bytes
 | 
							bytes
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	fons := sfons.create(512, 512, 1)
 | 
						fons := sfons.create(512, 512, 1)
 | 
				
			||||||
 | 
						debug_font_println('Font used for font_normal : $normal_path')
 | 
				
			||||||
 | 
						debug_font_println('Font used for font_bold   : $bold_path')
 | 
				
			||||||
 | 
						debug_font_println('Font used for font_mono   : $mono_path')
 | 
				
			||||||
 | 
						debug_font_println('Font used for font_italic : $italic_path')
 | 
				
			||||||
	return &FT{
 | 
						return &FT{
 | 
				
			||||||
		fons: fons
 | 
							fons: fons
 | 
				
			||||||
		font_normal: C.fonsAddFontMem(fons, c'sans', bytes.data, bytes.len, false)
 | 
							font_normal: C.fonsAddFontMem(fons, c'sans', bytes.data, bytes.len, false)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue