mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 13:32:45 +00:00 
			
		
		
		
	LibPDF: Make truetype ascent adjustment more local
It's only used in this function. No behavior change.
This commit is contained in:
		
							parent
							
								
									4e0fe9d9d0
								
							
						
					
					
						commit
						84d1e3956f
					
				
					 1 changed files with 6 additions and 6 deletions
				
			
		|  | @ -76,8 +76,11 @@ void TrueTypeFont::set_font_size(float font_size) | |||
|     m_font = m_font->with_size((font_size * POINTS_PER_INCH) / DEFAULT_DPI); | ||||
| } | ||||
| 
 | ||||
| static void do_draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint position, float width, u32 unicode, Gfx::Font const& font, ColorOrStyle const& style) | ||||
| static void do_draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint point, float width, u32 unicode, Gfx::Font const& font, ColorOrStyle const& style) | ||||
| { | ||||
|     // Undo shift in Glyf::Glyph::append_simple_path() via OpenType::Font::rasterize_glyph().
 | ||||
|     auto position = point.translated(0, -font.pixel_metrics().ascent); | ||||
| 
 | ||||
|     if (style.has<Color>()) { | ||||
|         painter.draw_glyph(position, unicode, font, style.get<Color>()); | ||||
|     } else { | ||||
|  | @ -92,9 +95,6 @@ PDFErrorOr<void> TrueTypeFont::draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint | |||
| { | ||||
|     auto style = renderer.state().paint_style; | ||||
| 
 | ||||
|     // Undo shift in Glyf::Glyph::append_simple_path() via OpenType::Font::rasterize_glyph().
 | ||||
|     auto position = point.translated(0, -m_font->pixel_metrics().ascent); | ||||
| 
 | ||||
|     // 5.5.5 Character Encoding, Encodings for TrueType Fonts
 | ||||
|     u32 unicode; | ||||
| 
 | ||||
|  | @ -129,7 +129,7 @@ PDFErrorOr<void> TrueTypeFont::draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint | |||
|         auto char_name = effective_encoding->get_name(char_code); | ||||
|         u32 unicode = glyph_name_to_unicode(char_name).value_or(char_code); | ||||
|         if (m_font->contains_glyph(unicode)) { | ||||
|             do_draw_glyph(painter, position, width, unicode, *m_font, style); | ||||
|             do_draw_glyph(painter, point, width, unicode, *m_font, style); | ||||
|             return {}; | ||||
|         } | ||||
| 
 | ||||
|  | @ -159,7 +159,7 @@ PDFErrorOr<void> TrueTypeFont::draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint | |||
|         unicode = glyph_name_to_unicode(char_name).value_or(char_code); | ||||
|     } | ||||
| 
 | ||||
|     do_draw_glyph(painter, position, width, unicode, *m_font, style); | ||||
|     do_draw_glyph(painter, point, width, unicode, *m_font, style); | ||||
|     return {}; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Nico Weber
						Nico Weber