fortplot_text Module



Functions

public function init_text_system() result(success)

Initialize STB TrueType font system with robust font discovery

Arguments

None

Return Value logical

public function find_font_by_name(font_name, font_path) result(found)

Find font by name in typical system locations

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: font_name
character(len=256), intent(out) :: font_path

Return Value logical

public function find_any_available_font(font_path) result(found)

Find any available font using same priority order as system initialization

Arguments

Type IntentOptional Attributes Name
character(len=256), intent(out) :: font_path

Return Value logical

public function calculate_text_width(text) result(width)

Calculate the pixel width of text using STB TrueType with UTF-8 support

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: text

Return Value integer

public function calculate_text_height(text) result(height)

Calculate the pixel height of text using STB TrueType

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: text

Return Value integer

public function get_font_ascent_ratio() result(ratio)

Get the ratio of font ascent to total height This is used to properly center text vertically

Arguments

None

Return Value real(kind=wp)


Subroutines

public subroutine cleanup_text_system()

Clean up STB TrueType font system

Arguments

None

public subroutine render_text_to_image(image_data, width, height, x, y, text, r, g, b)

Render text to image using STB TrueType with UTF-8 support

Arguments

Type IntentOptional Attributes Name
integer(kind=1), intent(inout) :: image_data(*)
integer, intent(in) :: width
integer, intent(in) :: height
integer, intent(in) :: x
integer, intent(in) :: y
character(len=*), intent(in) :: text
integer(kind=1), intent(in) :: r
integer(kind=1), intent(in) :: g
integer(kind=1), intent(in) :: b

public subroutine render_rotated_text_to_image(image_data, width, height, x, y, text, r, g, b, angle)

Render rotated text to PNG image using STB TrueType with UTF-8 support

Arguments

Type IntentOptional Attributes Name
integer(kind=1), intent(inout) :: image_data(*)
integer, intent(in) :: width
integer, intent(in) :: height
integer, intent(in) :: x
integer, intent(in) :: y
character(len=*), intent(in) :: text
integer(kind=1), intent(in) :: r
integer(kind=1), intent(in) :: g
integer(kind=1), intent(in) :: b
real(kind=wp), intent(in) :: angle

public subroutine get_font_metrics(ascent_pixels, descent_pixels, line_gap_pixels, success)

Get font metrics in pixels for current font

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(out) :: ascent_pixels
real(kind=wp), intent(out) :: descent_pixels
real(kind=wp), intent(out) :: line_gap_pixels
logical, intent(out) :: success