Antkeeper  0.0.1
Public Member Functions | List of all members
type::ft_typeface Class Reference

Typeface implementation using the FreeType library. More...

#include <ft-typeface.hpp>

Inheritance diagram for type::ft_typeface:
type::typeface

Public Member Functions

 ft_typeface (FT_Library library, FT_Face face, std::unique_ptr< std::vector< FT_Byte >> file_buffer)
 Creates a FreeType typeface. More...
 
virtual ~ft_typeface ()
 Destroys a FreeType typeface. More...
 
virtual bool has_kerning () const
 Returns true if the typeface contains kerning information, false otherwise. More...
 
virtual bool get_metrics (float height, font_metrics &metrics) const
 Gets metrics for a font of the specified size. More...
 
virtual bool get_metrics (float height, char32_t code, glyph_metrics &metrics) const
 Gets metrics for a glyph in a font of the specified size. More...
 
virtual bool get_bitmap (float height, char32_t code, std::vector< std::byte > &bitmap, std::uint32_t &bitmap_width, std::uint32_t &bitmap_height) const
 Gets a bitmap of a glyph in a font of the specified size. More...
 
virtual bool get_kerning (float height, char32_t first, char32_t second, math::fvec2 &offset) const
 Gets the kerning offset for a pair of glyphs. More...
 
- Public Member Functions inherited from type::typeface
 typeface (typeface_style style, int weight)
 Creates a typeface, setting its style and weight. More...
 
 typeface ()
 Creates an empty typeface. More...
 
virtual ~typeface ()=default
 Destroys a typeface. More...
 
void set_style (typeface_style style)
 Sets the style of the typeface. More...
 
void set_weight (int weight)
 Sets the weight of the typeface. More...
 
typeface_style get_style () const noexcept
 Returns the style of the typeface. More...
 
int get_weight () const noexcept
 Returns the weight of the typeface. More...
 
const std::unordered_set< char32_t > & get_charset () const noexcept
 Returns the set of characters supported by the typeface. More...
 

Additional Inherited Members

- Protected Attributes inherited from type::typeface
std::unordered_set< char32_t > charset
 

Detailed Description

Typeface implementation using the FreeType library.

See also
type::typeface

Definition at line 36 of file ft-typeface.hpp.

Constructor & Destructor Documentation

◆ ft_typeface()

type::ft_typeface::ft_typeface ( FT_Library  library,
FT_Face  face,
std::unique_ptr< std::vector< FT_Byte >>  file_buffer 
)

Creates a FreeType typeface.

Parameters
libraryPointer to a FreeType library instance.
facePointer to the FreeType object instance.
file_bufferFile buffer containing FreeType face data.

Build charset

Definition at line 26 of file ft-typeface.cpp.

◆ ~ft_typeface()

type::ft_typeface::~ft_typeface ( )
virtual

Destroys a FreeType typeface.

Definition at line 42 of file ft-typeface.cpp.

Member Function Documentation

◆ get_bitmap()

bool type::ft_typeface::get_bitmap ( float  height,
char32_t  code,
std::vector< std::byte > &  bitmap,
std::uint32_t &  bitmap_width,
std::uint32_t &  bitmap_height 
) const
virtual

Gets a bitmap of a glyph in a font of the specified size.

Parameters
[in]heightHeight of the font, in pixels.
[in]codeUTF-32 character code of a glyph.
[out]bitmapGlyph bitmap data.
Returns
true if glyph bitmap data was returned, false otherwise.

Implements type::typeface.

Definition at line 99 of file ft-typeface.cpp.

◆ get_kerning()

bool type::ft_typeface::get_kerning ( float  height,
char32_t  first,
char32_t  second,
math::fvec2 offset 
) const
virtual

Gets the kerning offset for a pair of glyphs.

Parameters
[in]heightHeight of the font, in pixels.
[in]firstUTF-32 character code of the first glyph.
[in]secondUTF-32 character code of the second glyph.
[out]offsetKerning offset.
Returns
true if a kerning offset was returned, false otherwise.

Implements type::typeface.

Definition at line 123 of file ft-typeface.cpp.

◆ get_metrics() [1/2]

bool type::ft_typeface::get_metrics ( float  height,
char32_t  code,
glyph_metrics metrics 
) const
virtual

Gets metrics for a glyph in a font of the specified size.

Parameters
[in]heightHeight of the font, in pixels.
[in]codeUTF-32 character code of a glyph.
[out]metricsGlyph metrics.
Returns
true if glyph metrics were returned, false otherwise.

Implements type::typeface.

Definition at line 72 of file ft-typeface.cpp.

◆ get_metrics() [2/2]

bool type::ft_typeface::get_metrics ( float  height,
font_metrics metrics 
) const
virtual

Gets metrics for a font of the specified size.

Parameters
[in]heightHeight of the font, in pixels.
[out]metricsFont metrics.
Returns
true if font metrics were returned, false otherwise.

Implements type::typeface.

Definition at line 53 of file ft-typeface.cpp.

◆ has_kerning()

bool type::ft_typeface::has_kerning ( ) const
virtual

Returns true if the typeface contains kerning information, false otherwise.

Implements type::typeface.

Definition at line 48 of file ft-typeface.cpp.


The documentation for this class was generated from the following files: