scimesh 0.3.4
Headless CPU-only 3D software renderer for scientific mesh visualization
Loading...
Searching...
No Matches
scimesh::GlyphBitmap Struct Reference

One rasterized glyph: an 8-bit coverage bitmap plus placement info. More...

#include <font.h>

Public Member Functions

bool empty () const
 Whether this glyph has no pixels to draw (e.g. a space).
 
uint8_t at (int x, int y) const
 Coverage value at pixel (x, y), 0-255. No bounds checking.
 

Public Attributes

int width = 0
 Bitmap width in pixels.
 
int height = 0
 Bitmap height in pixels.
 
int x_offset = 0
 Horizontal offset from the pen position to the bitmap's left edge.
 
int y_offset = 0
 Vertical offset from the baseline to the bitmap's top edge.
 
float advance = 0.0f
 Pen advance for this glyph, in pixels.
 
std::vector< uint8_t > coverage
 Coverage values, row-major, width * height entries.
 

Detailed Description

One rasterized glyph: an 8-bit coverage bitmap plus placement info.

The bitmap is a single-channel (coverage) image: 0 means fully transparent, 255 means the pixel is fully covered by the glyph. Coverage values are fractional, which is what gives text its anti-aliasing.

Placement follows the usual TrueType convention: the glyph is drawn with its bitmap top left corner at (pen_x + x_offset, baseline_y + y_offset), where the y axis points down. Because the y offsets are negative for glyphs that sit above the baseline, the renderer draws at baseline_y + y_offset.

See also
Font::glyph()

Definition at line 91 of file font.h.

Member Function Documentation

◆ at()

uint8_t scimesh::GlyphBitmap::at ( int  x,
int  y 
) const
inline

Coverage value at pixel (x, y), 0-255. No bounds checking.

Definition at line 117 of file font.h.

◆ empty()

bool scimesh::GlyphBitmap::empty ( ) const
inline

Whether this glyph has no pixels to draw (e.g. a space).

Definition at line 114 of file font.h.

Member Data Documentation

◆ advance

float scimesh::GlyphBitmap::advance = 0.0f

Pen advance for this glyph, in pixels.

Definition at line 108 of file font.h.

◆ coverage

std::vector<uint8_t> scimesh::GlyphBitmap::coverage

Coverage values, row-major, width * height entries.

Definition at line 111 of file font.h.

◆ height

int scimesh::GlyphBitmap::height = 0

Bitmap height in pixels.

Definition at line 96 of file font.h.

◆ width

int scimesh::GlyphBitmap::width = 0

Bitmap width in pixels.

Definition at line 93 of file font.h.

◆ x_offset

int scimesh::GlyphBitmap::x_offset = 0

Horizontal offset from the pen position to the bitmap's left edge.

Definition at line 99 of file font.h.

◆ y_offset

int scimesh::GlyphBitmap::y_offset = 0

Vertical offset from the baseline to the bitmap's top edge.

Negative for glyphs above the baseline (the common case), since screen y coordinates grow downwards.

Definition at line 105 of file font.h.


The documentation for this struct was generated from the following file: