fortplot_tt_metrics Module

TrueType font metrics: scale factors, vertical/horizontal metrics, glyph offsets, and bounding boxes. Pure Fortran implementations operating directly on the font byte array via fortplot_tt_binary.



Functions

public pure function tt_scale_for_pixel_height(data, hhea, height) result(scale)

Compute scale factor to achieve a desired pixel height. Uses ascent - descent from the hhea table.

Arguments

Type IntentOptional Attributes Name
integer(kind=int8), intent(in) :: data(:)
integer, intent(in) :: hhea
real(kind=dp), intent(in) :: height

Return Value real(kind=dp)

public pure function tt_get_glyf_offset(data, loca, glyf, index_to_loc_format, num_glyphs, glyph_index) result(offset)

Get byte offset to a glyph in the glyf table. Returns -1 for empty glyphs or invalid indices.

Arguments

Type IntentOptional Attributes Name
integer(kind=int8), intent(in) :: data(:)
integer, intent(in) :: loca
integer, intent(in) :: glyf
integer, intent(in) :: index_to_loc_format
integer, intent(in) :: num_glyphs
integer, intent(in) :: glyph_index

Return Value integer


Subroutines

public pure subroutine tt_get_font_vmetrics(data, hhea, ascent, descent, line_gap)

Read vertical font metrics (unscaled) from the hhea table.

Arguments

Type IntentOptional Attributes Name
integer(kind=int8), intent(in) :: data(:)
integer, intent(in) :: hhea
integer, intent(out) :: ascent
integer, intent(out) :: descent
integer, intent(out) :: line_gap

public pure subroutine tt_get_glyph_hmetrics(data, hhea, hmtx, glyph_index, advance_width, left_side_bearing)

Read horizontal metrics for a glyph (unscaled) from the hmtx table. Glyphs beyond numOfLongHorMetrics share the last advance width.

Arguments

Type IntentOptional Attributes Name
integer(kind=int8), intent(in) :: data(:)
integer, intent(in) :: hhea
integer, intent(in) :: hmtx
integer, intent(in) :: glyph_index
integer, intent(out) :: advance_width
integer, intent(out) :: left_side_bearing

public pure subroutine tt_get_glyph_box(data, loca, glyf, index_to_loc_format, num_glyphs, glyph_index, x0, y0, x1, y1, found)

Get bounding box of a glyph in unscaled font coordinates.

Arguments

Type IntentOptional Attributes Name
integer(kind=int8), intent(in) :: data(:)
integer, intent(in) :: loca
integer, intent(in) :: glyf
integer, intent(in) :: index_to_loc_format
integer, intent(in) :: num_glyphs
integer, intent(in) :: glyph_index
integer, intent(out) :: x0
integer, intent(out) :: y0
integer, intent(out) :: x1
integer, intent(out) :: y1
logical, intent(out) :: found

public pure subroutine tt_get_glyph_bitmap_box(data, loca, glyf, index_to_loc_format, num_glyphs, glyph_index, scale_x, scale_y, ix0, iy0, ix1, iy1)

Get bitmap bounding box in pixel coordinates (y-flipped).

Arguments

Type IntentOptional Attributes Name
integer(kind=int8), intent(in) :: data(:)
integer, intent(in) :: loca
integer, intent(in) :: glyf
integer, intent(in) :: index_to_loc_format
integer, intent(in) :: num_glyphs
integer, intent(in) :: glyph_index
real(kind=dp), intent(in) :: scale_x
real(kind=dp), intent(in) :: scale_y
integer, intent(out) :: ix0
integer, intent(out) :: iy0
integer, intent(out) :: ix1
integer, intent(out) :: iy1