vkf_text Module

Text for vkframes: fonts (found by name on a search path, read once) and labels (text that always faces the screen).

A font is given as a file name (e.g. 'DejaVuSans.ttf', the default) or a path. A name is looked for in, in order: the directories of the VKFRAMES_FONT_PATH environment variable (separated by ':' or ';'), the fonts directory of the active conda/pixi environment (where pixi installs DejaVu), and the usual system font directories of macOS, Linux and Windows.


Uses

  • module~~vkf_text~~UsesGraph module~vkf_text vkf_text iso_c_binding iso_c_binding module~vkf_text->iso_c_binding module~vkf_files vkf_files module~vkf_text->module~vkf_files module~vkf_layer vkf_layer module~vkf_text->module~vkf_layer module~vkf_math vkf_math module~vkf_text->module~vkf_math module~vkf_layer->iso_c_binding iso_fortran_env iso_fortran_env module~vkf_math->iso_fortran_env

Used by

  • module~~vkf_text~~UsedByGraph module~vkf_text vkf_text module~vkf_frames vkf_frames module~vkf_frames->module~vkf_text module~vkf_sky vkf_sky module~vkf_sky->module~vkf_text module~vkf_window vkf_window module~vkf_window->module~vkf_text module~vkf_window->module~vkf_frames module~vkf_window->module~vkf_sky module~vkf_handles vkf_handles module~vkf_window->module~vkf_handles module~vkf_hud vkf_hud module~vkf_window->module~vkf_hud module~vkf_view vkf_view module~vkf_window->module~vkf_view module~vkf_artists vkf_artists module~vkf_artists->module~vkf_frames module~vkf_handles->module~vkf_frames module~vkf_handles->module~vkf_artists module~vkf_hud->module~vkf_frames module~vkf_line_segments vkf_line_segments module~vkf_line_segments->module~vkf_frames module~vkf_model vkf_model module~vkf_model->module~vkf_frames module~vkf_shadow vkf_shadow module~vkf_shadow->module~vkf_frames module~vkf_sphere vkf_sphere module~vkf_shadow->module~vkf_sphere module~vkf_terrain vkf_terrain module~vkf_shadow->module~vkf_terrain module~vkf_shapes vkf_shapes module~vkf_shapes->module~vkf_frames module~vkf_shapes->module~vkf_artists module~vkf_sphere->module~vkf_frames module~vkf_terrain->module~vkf_frames module~vkf_view->module~vkf_frames module~vkframes vkframes module~vkframes->module~vkf_frames module~vkframes->module~vkf_sky module~vkframes->module~vkf_window module~vkframes->module~vkf_artists module~vkframes->module~vkf_handles module~vkframes->module~vkf_hud module~vkframes->module~vkf_line_segments module~vkframes->module~vkf_model module~vkframes->module~vkf_shadow module~vkframes->module~vkf_shapes module~vkframes->module~vkf_sphere module~vkframes->module~vkf_terrain module~vkframes->module~vkf_view

Variables

Type Visibility Attributes Name Initial
integer, private, parameter :: VSG_BASELINE = 0

(vertical: the base line)

integer, private, parameter :: VSG_BOTTOM = 3

(vertical: bottom)

integer, private, parameter :: VSG_CENTER = 2

horizontal or vertical: center

integer, private, parameter :: VSG_LEFT = 1

(horizontal: left)

integer, private, parameter :: VSG_RIGHT = 3

(horizontal: right)

integer, private, parameter :: VSG_TOP = 1

(vertical: top)

character(len=*), public, parameter :: default_font = 'DejaVuSans.ttf'

the font used when none is given

type(font_entry), private, allocatable, save :: fonts(:)

Fonts read so far (each is read once; kept for the whole run).


Derived Types

type, private ::  font_entry

A font read (or looked for) by name.

Components

Type Visibility Attributes Name Initial
type(c_ptr), public :: font = c_null_ptr

its handle (null: not found or not read)

character(len=:), public, allocatable :: name

the font's name as given ('' replaced by default_font)


Functions

public function find_font(name) result(path)

The path of font name (a file name or a path), or '' if not found.

Arguments

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

a file name or a path

Return Value character(len=:), allocatable

public function get_font(name) result(font)

The font handle for name (found with find_font, read on first use); the default font if name is ''; null if it cannot be found or read.

Arguments

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

as find_font's ('': the default font)

Return Value type(c_ptr)

public function label_create(text, position, rgba, size, max_size, alignment, font_name) result(node)

A label node: text at position in color rgba, in font font_name ('' for the default), aligned by alignment (an ALIGN_* constant of vkf_frames). size > 0: size window units tall; size < 0: -size scene units tall, but at most max_size window units on screen. Null if the font is missing.

Arguments

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

the label's text

real(kind=wp), intent(in) :: position(3)

(the coordinates of the node it is put under)

real(kind=wp), intent(in) :: rgba(4)

color [r, g, b, a] (0 to 1)

real(kind=wp), intent(in) :: size

0: height in window units; < 0: -height in scene units

Read more…
real(kind=wp), intent(in) :: max_size

for size < 0: the largest height on screen (window units)

integer, intent(in) :: alignment

an ALIGN_* constant of vkf_frames

character(len=*), intent(in) :: font_name

font file ('' for the default)

Return Value type(c_ptr)

public function label_set_layout(node, position, size, max_size, alignment) result(ok)

Change label node's position, size, maximum size and alignment (as label_create's), in place. False on failure.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: node

a label_create node

real(kind=wp), intent(in) :: position(3)

as label_create's

real(kind=wp), intent(in) :: size

as label_create's

real(kind=wp), intent(in) :: max_size

as label_create's

integer, intent(in) :: alignment

an ALIGN_* constant of vkf_frames

Return Value logical


Subroutines

private pure subroutine vsg_alignment(alignment, h, v)

The horizontal and vertical alignments of vsg::StandardLayout for an ALIGN_* constant (vkf_frames: 0 left-top ... 8 right-bottom, 9 to 11 base line).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: alignment

an ALIGN_* constant of vkf_frames

integer, intent(out) :: h

VSG_* horizontal and vertical alignments

integer, intent(out) :: v

VSG_* horizontal and vertical alignments