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.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | name |
as find_font's ('': the default font) |
function get_font(name) result(font) character(len=*), intent(in) :: name !! as find_font's ('': the default font) type(c_ptr) :: font type(font_entry), allocatable :: tmp(:) character(len=:), allocatable :: key, path integer :: k key = trim(name) if (len(key) == 0) key = default_font font = c_null_ptr if (allocated(fonts)) then do k = 1, size(fonts) if (fonts(k)%name == key) then font = fonts(k)%font return end if end do end if path = find_font(key) if (len(path) == 0) then write(*, '(a)') 'vkframes: font '//key//' not found (set VKFRAMES_FONT_PATH)' else font = vkf_font_read(path, len(path, kind=c_int)) end if ! remember the result (also a failure, so it is not looked for again) if (.not. allocated(fonts)) allocate(fonts(0)) allocate(tmp(size(fonts) + 1)) tmp(1:size(fonts)) = fonts tmp(size(tmp))%name = key tmp(size(tmp))%font = font call move_alloc(tmp, fonts) end function get_font