Backend-agnostic text rendering using STB TrueType Provides iso_c_binding interface to stb_truetype.h functions
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer, | public, | parameter | :: | STB_SUCCESS | = | 1 | |
| integer, | public, | parameter | :: | STB_ERROR | = | 0 | 
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(c_ptr), | public | :: | data_ptr | = | c_null_ptr | ||
| integer(kind=c_int), | public | :: | fontstart | = | 0 | ||
| integer(kind=c_int), | public | :: | numGlyphs | = | 0 | ||
| type(c_ptr), | public | :: | private_data | = | c_null_ptr | 
Initialize font from file path
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(stb_fontinfo_t), | intent(inout) | :: | font_info | |||
| character(len=*), | intent(in) | :: | font_file_path | 
Calculate scale factor for desired pixel height
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(stb_fontinfo_t), | intent(in) | :: | font_info | |||
| real(kind=wp), | intent(in) | :: | pixel_height | 
Find glyph index for Unicode codepoint
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(stb_fontinfo_t), | intent(in) | :: | font_info | |||
| integer, | intent(in) | :: | codepoint | 
Allocate and render character bitmap
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(stb_fontinfo_t), | intent(in) | :: | font_info | |||
| real(kind=wp), | intent(in) | :: | scale_x | |||
| real(kind=wp), | intent(in) | :: | scale_y | |||
| integer, | intent(in) | :: | codepoint | |||
| integer, | intent(out) | :: | width | |||
| integer, | intent(out) | :: | height | |||
| integer, | intent(out) | :: | xoff | |||
| integer, | intent(out) | :: | yoff | 
Clean up font resources
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(stb_fontinfo_t), | intent(inout) | :: | font_info | 
Get vertical font metrics in unscaled coordinates
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(stb_fontinfo_t), | intent(in) | :: | font_info | |||
| integer, | intent(out) | :: | ascent | |||
| integer, | intent(out) | :: | descent | |||
| integer, | intent(out) | :: | line_gap | 
Get horizontal character metrics in unscaled coordinates
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(stb_fontinfo_t), | intent(in) | :: | font_info | |||
| integer, | intent(in) | :: | codepoint | |||
| integer, | intent(out) | :: | advance_width | |||
| integer, | intent(out) | :: | left_side_bearing | 
Get bounding box for character bitmap
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(stb_fontinfo_t), | intent(in) | :: | font_info | |||
| integer, | intent(in) | :: | codepoint | |||
| real(kind=wp), | intent(in) | :: | scale_x | |||
| real(kind=wp), | intent(in) | :: | scale_y | |||
| integer, | intent(out) | :: | ix0 | |||
| integer, | intent(out) | :: | iy0 | |||
| integer, | intent(out) | :: | ix1 | |||
| integer, | intent(out) | :: | iy1 | 
Render character into provided buffer
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(stb_fontinfo_t), | intent(in) | :: | font_info | |||
| integer(kind=c_int8_t), | intent(inout), | target | :: | output_buffer(*) | ||
| integer, | intent(in) | :: | out_w | |||
| integer, | intent(in) | :: | out_h | |||
| integer, | intent(in) | :: | out_stride | |||
| real(kind=wp), | intent(in) | :: | scale_x | |||
| real(kind=wp), | intent(in) | :: | scale_y | |||
| integer, | intent(in) | :: | codepoint | 
Free bitmap allocated by stb_get_codepoint_bitmap
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(c_ptr), | intent(in) | :: | bitmap_ptr |