mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:12:45 +00:00 
			
		
		
		
	LibGfx: Make Font::preferred_line_height() more correct
Return a float, and fix a bogus calculation of ascender + descender.
This commit is contained in:
		
							parent
							
								
									43a10674d0
								
							
						
					
					
						commit
						2a61d66b0a
					
				
					 8 changed files with 10 additions and 10 deletions
				
			
		|  | @ -130,7 +130,7 @@ void TextTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event) | |||
|     painter.translate(editor_layer_location(*layer)); | ||||
|     auto typed_text = m_text_editor->text(); | ||||
|     auto text_width = max<int>(m_selected_font->width(typed_text), m_selected_font->width(" "sv)); | ||||
|     auto text_height = m_selected_font->preferred_line_height() * max<int>(static_cast<int>(m_text_editor->line_count()), 1); | ||||
|     auto text_height = static_cast<int>(ceilf(m_selected_font->preferred_line_height() * max<int>(static_cast<int>(m_text_editor->line_count()), 1))); | ||||
|     auto text_location = editor_stroke_position(m_add_text_position, 1); | ||||
| 
 | ||||
|     // Since ImageEditor can be zoomed in/out, we need to be able to render the preview properly scaled
 | ||||
|  | @ -238,7 +238,7 @@ void TextTool::apply_text_to_layer() | |||
| 
 | ||||
|     auto demo_text = m_text_editor->text(); | ||||
|     auto text_width = m_selected_font->width(demo_text); | ||||
|     auto text_height = m_selected_font->preferred_line_height() * static_cast<int>(m_text_editor->line_count()); | ||||
|     auto text_height = static_cast<int>(ceilf(m_selected_font->preferred_line_height() * static_cast<int>(m_text_editor->line_count()))); | ||||
| 
 | ||||
|     painter.set_font(*m_selected_font); | ||||
|     auto text_rect = Gfx::Rect<int>(m_add_text_position, { static_cast<int>(ceilf(text_width)), text_height }); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling