foresight_enhanced
foresight_enhanced, gnuplot's enhanced text: the markup of titles, labels and key entries as styled runs.
As gnuplot 6.0 (its svg terminal): ^ a superscript and _ a subscript of the next character or {group}, at 0.8 times the size, raised 0.5 or lowered 0.3 of the current size (nested: again); {/Font:Bold=N text} changes the font (/Symbol the Greek letters, written here as Unicode letters where gnuplot writes the Symbol font), its size (=N absolute, *F relative), weight (:Bold) and style (:Italic); @ makes the next element take no room (the one after it written over it, as a@^b_c); & makes the next element invisible, keeping its room; ~a{.8-} overprints the second element on the first, raised by the fraction of the size; \ makes the next character literal. Widths come from the compiled-in fonts (foresight_font): each run in its face (its family, else the base one; its weight and style, or the base ones) at its size, kerned.
Source: src/lib/foresight_enhanced.F90
Dependencies
Contents
- enhanced_run
- style_state
- enhanced_runs
- sequence
- element
- font_spec
- put
- has_markup
- runs_width
- run_face
- markup_width
- markup_literal
- markup_plain
- markup_svg
- shown
- greek
- utf8_length
- characters
- number_of
- fixed
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
HEX | character(len=*) | parameter | Hexadecimal digits. |
Derived Types
enhanced_run
A piece of text in one style.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
size | real(kind=R8P) | Size, times the base size. | |
shift | real(kind=R8P) | Baseline offset up, times the base size. | |
back | real(kind=R8P) | Step back before it, times the base size. | |
bold | logical | Bold. | |
italic | logical | Italic. | |
hidden | logical | Invisible, its room kept (&). | |
phantom | logical | No room taken (@): the next run steps back over it. | |
symbol | logical | In the Symbol font: the Greek letters (Latin in text). | |
text | character(len=:) | allocatable | Text. |
family | character(len=:) | allocatable | Font family, empty for the default. |
style_state
The style of the text being read.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
size | real(kind=R8P) | Size, times the base size. | |
shift | real(kind=R8P) | Baseline offset up, times the base size. | |
bold | logical | Bold. | |
italic | logical | Italic. | |
hidden | logical | Invisible. | |
phantom | logical | No room taken. | |
symbol | logical | The Greek letters of the Symbol font. | |
family | character(len=:) | allocatable | Font family, empty for the default. |
Subroutines
enhanced_runs
The runs of the enhanced text.
Attributes: pure
subroutine enhanced_runs(text, runs)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text with markup. | |
runs | type(enhanced_run) | out | allocatable | Runs. |
Call graph
sequence
The elements from pos to the end of text, or to the } closing a group (group, pos left after it).
Attributes: pure, recursive
subroutine sequence(text, pos, state, runs, group)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
pos | integer(kind=I4P) | inout | Next character. | |
state | type(style_state) | in | Style. | |
runs | type(enhanced_run) | inout | allocatable | Runs. |
group | logical | in | Inside {...}. |
Call graph
element
One element at pos: a character, an escaped one, a {group}, a font group, or a markup construct. Code point.
Attributes: pure, recursive
subroutine element(text, pos, state, runs)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
pos | integer(kind=I4P) | inout | Next character. | |
state | type(style_state) | in | Style. | |
runs | type(enhanced_run) | inout | allocatable | Runs. |
Call graph
font_spec
/Font:Bold:Italic=N or a relative size *F after { (at pos, left on the text after the blank ending it): the style.
Attributes: pure
subroutine font_spec(text, pos, state)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. | |
pos | integer(kind=I4P) | inout | Next character. | |
state | type(style_state) | inout | Style. |
Call graph
put
Append piece in state, joined to the last run if the style is the same.
Attributes: pure
subroutine put(piece, state, runs)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
piece | character(len=*) | in | Text. | |
state | type(style_state) | in | Style. | |
runs | type(enhanced_run) | inout | allocatable | Runs. |
Call graph
Functions
has_markup
Whether text holds a character of the markup (^ _ { } @ & ~ \).
Attributes: pure
Returns: logical
function has_markup(text) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. |
Call graph
runs_width
Width of runs [base size], each run in its face (run_face) at its size; phantom runs take none (all do with all).
Attributes: pure
Returns: real(kind=R8P)
function runs_width(runs, all, base) result(w)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
runs | type(enhanced_run) | in | Runs. | |
all | logical | in | optional | Phantom runs counted. |
base | integer(kind=I4P) | in | optional | Base face (foresight_fontdata, 1-8), 1 if absent. |
Call graph
run_face
The face of run (foresight_fontdata, 1-8): its family if set, else the base face's; bold or italic if the run or the base face is.
Attributes: pure
Returns: integer(kind=I4P)
function run_face(run, base) result(face)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
run | type(enhanced_run) | in | Run. | |
base | integer(kind=I4P) | in | Base face, 1-8. |
Call graph
markup_width
Width of the enhanced text [px] at font_size, its runs in their faces (base, 1-8, the face of the text without markup; 1 if absent).
Attributes: pure
Returns: real(kind=R8P)
function markup_width(text, font_size, base) result(width)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text with markup. | |
font_size | real(kind=R8P) | in | Base font size [px]. | |
base | integer(kind=I4P) | in | optional | Base face. |
Call graph
markup_literal
The text read as it is by the enhanced text parser: every markup character escaped with a backslash (the noenhanced texts whose width is measured where the device cannot be told).
Attributes: pure
Returns: character(len=:)
function markup_literal(text) result(literal)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. |
markup_plain
The visible characters of the enhanced text, the markup dropped (the text devices; the Symbol font as its Latin letters, as gnuplot's dumb terminal).
Attributes: pure
Returns: character(len=:)
function markup_plain(text) result(plain)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text with markup. |
Call graph
markup_svg
The SVG <tspan> elements of the enhanced text at font_size [px], as gnuplot's svg terminal writes them: a font size and a dy where they change, dx stepping back, fill="none" for the invisible runs; the texts XML escaped. (No escape function as an argument: nvfortran 26.9 crashes passing a function with a deferred-length result, see foresight#3.)
Attributes: pure
Returns: character(len=:)
function markup_svg(text, font_size) result(svg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text with markup. | |
font_size | real(kind=R8P) | in | Base font size [px]. |
Call graph
shown
The text of run as drawn: the Greek letters in the Symbol font.
Attributes: pure
Returns: character(len=:)
function shown(run) result(text)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
run | type(enhanced_run) | in | Run. |
Call graph
greek
The letters of text as the Greek letters of the Symbol font (Adobe's encoding), in UTF-8, and the characters 160-255 as its symbols (\362 the integral, \245 infinity); others as they are.
Attributes: pure
Returns: character(len=:)
function greek(text) result(g)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Latin letters. |
Call graph
utf8_length
Bytes of the UTF-8 character starting with lead.
Attributes: pure
Returns: integer(kind=I4P)
function utf8_length(lead) result(n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lead | character(len=1) | in | First byte. |
Call graph
characters
Characters of the UTF-8 text (continuation bytes not counted).
Attributes: pure
Returns: integer(kind=I4P)
function characters(text) result(n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. |
Call graph
number_of
The leading decimal number of text, 0 if none.
Attributes: pure
Returns: real(kind=R8P)
function number_of(text) result(v)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | Text. |
Call graph
fixed
v with two decimals, no trailing zeros (gnuplot writes 9.6, -6.00).
Attributes: pure
Returns: character(len=:)
function fixed(v) result(s)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
v | real(kind=R8P) | in | Value. |
Call graph