fortplot_mathtext Module

Mathematical text rendering with superscripts and subscripts Supports matplotlib-like syntax: x^2, y_i, x_{text}, y^{superscript}



Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: ELEMENT_NORMAL = 0
integer, public, parameter :: ELEMENT_SUPERSCRIPT = 1
integer, public, parameter :: ELEMENT_SUBSCRIPT = 2
integer, public, parameter :: ELEMENT_SQRT = 3

Derived Types

type, public ::  mathtext_element_t

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: text
integer, public :: element_type = ELEMENT_NORMAL
real(kind=wp), public :: font_size_ratio = 1.0_wp
real(kind=wp), public :: vertical_offset = 0.0_wp

Functions

public function parse_mathtext(input_text) result(elements)

Parse mathematical text into renderable elements

Arguments

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

Return Value type(mathtext_element_t), allocatable, (:)

public function calculate_mathtext_width(elements, base_font_size) result(total_width)

Calculate total width of mathematical text elements This function signature is used by text_rendering but implementation moved there

Arguments

Type IntentOptional Attributes Name
type(mathtext_element_t), intent(in) :: elements(:)
real(kind=wp), intent(in) :: base_font_size

Return Value integer

public function calculate_mathtext_height(elements, base_font_size) result(total_height)

Calculate total height of mathematical text elements This function signature is used by text_rendering but implementation moved there

Arguments

Type IntentOptional Attributes Name
type(mathtext_element_t), intent(in) :: elements(:)
real(kind=wp), intent(in) :: base_font_size

Return Value integer


Subroutines

public subroutine render_mathtext_elements(image_data, width, height, x, y, elements, r, g, b, base_font_size)

Render mathematical text elements to image This function signature is used by text_rendering but implementation moved there

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
type(mathtext_element_t), intent(in) :: elements(:)
integer(kind=1), intent(in) :: r
integer(kind=1), intent(in) :: g
integer(kind=1), intent(in) :: b
real(kind=wp), intent(in) :: base_font_size