mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-30 21:21:10 +00:00 
			
		
		
		
	Clear canvas item after rendering font, fixes #23774
This commit is contained in:
		
							parent
							
								
									e30ce69cb4
								
							
						
					
					
						commit
						f436047cf5
					
				
					 1 changed files with 8 additions and 3 deletions
				
			
		|  | @ -845,15 +845,16 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c | |||
| 
 | ||||
| 	font->draw(canvas_item, pos, sampled_text); | ||||
| 
 | ||||
| 	VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
 | ||||
| 
 | ||||
| 	preview_done = false; | ||||
| 	VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture
 | ||||
| 	VS::get_singleton()->request_frame_drawn_callback(const_cast<EditorFontPreviewPlugin *>(this), "_preview_done", Variant()); | ||||
| 
 | ||||
| 	while (!preview_done) { | ||||
| 		OS::get_singleton()->delay_usec(10); | ||||
| 	} | ||||
| 
 | ||||
| 	VS::get_singleton()->canvas_item_clear(canvas_item); | ||||
| 
 | ||||
| 	Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); | ||||
| 	ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); | ||||
| 
 | ||||
|  | @ -878,7 +879,11 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c | |||
| 
 | ||||
| Ref<Texture> EditorFontPreviewPlugin::generate(const RES &p_from, const Size2 p_size) const { | ||||
| 
 | ||||
| 	return generate_from_path(p_from->get_path(), p_size); | ||||
| 	String path = p_from->get_path(); | ||||
| 	if (!FileAccess::exists(path)) { | ||||
| 		return Ref<Texture>(); | ||||
| 	} | ||||
| 	return generate_from_path(path, p_size); | ||||
| } | ||||
| 
 | ||||
| EditorFontPreviewPlugin::EditorFontPreviewPlugin() { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Juan Linietsky
						Juan Linietsky