mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:02:46 +00:00 
			
		
		
		
	LibGfx: Introduce with_size method for Font
This commit is contained in:
		
							parent
							
								
									d910dd345e
								
							
						
					
					
						commit
						1cc8895e4b
					
				
					 5 changed files with 16 additions and 0 deletions
				
			
		|  | @ -381,6 +381,11 @@ DeprecatedString BitmapFont::variant() const | |||
|     return builder.to_deprecated_string(); | ||||
| } | ||||
| 
 | ||||
| RefPtr<Font> BitmapFont::with_size(float point_size) const | ||||
| { | ||||
|     return Gfx::FontDatabase::the().get(family(), point_size, weight(), width(), slope()); | ||||
| } | ||||
| 
 | ||||
| Font const& Font::bold_variant() const | ||||
| { | ||||
|     if (m_bold_variant) | ||||
|  |  | |||
|  | @ -125,6 +125,8 @@ public: | |||
|     DeprecatedString qualified_name() const override; | ||||
|     DeprecatedString human_readable_name() const override { return DeprecatedString::formatted("{} {} {}", family(), variant(), presentation_size()); } | ||||
| 
 | ||||
|     virtual RefPtr<Font> with_size(float point_size) const override; | ||||
| 
 | ||||
| private: | ||||
|     BitmapFont(DeprecatedString name, DeprecatedString family, u8* rows, u8* widths, bool is_fixed_width, | ||||
|         u8 glyph_width, u8 glyph_height, u8 glyph_spacing, u16 range_mask_size, u8* range_mask, | ||||
|  |  | |||
|  | @ -197,6 +197,8 @@ public: | |||
|     virtual DeprecatedString qualified_name() const = 0; | ||||
|     virtual DeprecatedString human_readable_name() const = 0; | ||||
| 
 | ||||
|     virtual RefPtr<Font> with_size(float point_size) const = 0; | ||||
| 
 | ||||
|     Font const& bold_variant() const; | ||||
| 
 | ||||
| private: | ||||
|  |  | |||
|  | @ -123,6 +123,11 @@ u8 ScaledFont::glyph_fixed_width() const | |||
|     return glyph_metrics(glyph_id_for_code_point(' ')).advance_width; | ||||
| } | ||||
| 
 | ||||
| RefPtr<Font> ScaledFont::with_size(float point_size) const | ||||
| { | ||||
|     return adopt_ref(*new Gfx::ScaledFont(*m_font, point_size, point_size)); | ||||
| } | ||||
| 
 | ||||
| Gfx::FontPixelMetrics ScaledFont::pixel_metrics() const | ||||
| { | ||||
|     return m_pixel_metrics; | ||||
|  |  | |||
|  | @ -67,6 +67,8 @@ public: | |||
|     virtual DeprecatedString qualified_name() const override { return DeprecatedString::formatted("{} {} {} {}", family(), presentation_size(), weight(), slope()); } | ||||
|     virtual DeprecatedString human_readable_name() const override { return DeprecatedString::formatted("{} {} {}", family(), variant(), presentation_size()); } | ||||
| 
 | ||||
|     virtual RefPtr<Font> with_size(float point_size) const override; | ||||
| 
 | ||||
| private: | ||||
|     NonnullRefPtr<VectorFont> m_font; | ||||
|     float m_x_scale { 0.0f }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Aliaksandr Kalenik
						Aliaksandr Kalenik