foresight_font
foresight_font, gnuplot's font specs ("family:Bold:Italic,size") per text element, and their SVG attributes.
As gnuplot 6.0's svg terminal: the size after the first comma, :Bold and :Italic (or bold, italic) the weight and the style, the rest the family. A family is written to the SVG as given (the reader's fonts render it); font files (a path, .ttf) and gnuplot's mbfont: sets are not families an SVG can name: left out, as an empty family is.
Widths come from the compiled-in faces (foresight_fontdata): Liberation Sans (Arial's metrics) for the sans families and every family foresight does not have, Latin Modern Roman for the serif ones (family_face), each in four faces (regular, bold, italic, bold italic); text_advance sums the advance widths of a UTF-8 text and the kerning of its pairs, a character Liberation Sans lacks taken from Latin Modern, one no face has counting 0.556 em.
Source: src/lib/foresight_font.F90
Dependencies
Contents
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
FAMILY_SANS | integer(kind=I4P) | parameter | Liberation Sans, faces 1-4. |
FAMILY_SERIF | integer(kind=I4P) | parameter | Latin Modern Roman, faces 5-8. |
MISSING_ADVANCE | real(kind=R8P) | parameter | Advance of a character no face has [em]. |
Derived Types
font_object
A text element's font: a size, a family, the weight and the style; unset parts take the page's.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
size | real(kind=R8P) | Size [px], 0 the page's. | |
family | character(len=48) | CSS family, empty the page's. | |
bold | logical | Bold. | |
italic | logical | Italic. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
is_set | pass(self) | Whether any part is set. |
size_px | pass(self) | The size [px], the page's if unset. |
Subroutines
family_face
The compiled-in family standing for the CSS family (case and blanks ignored): Latin Modern Roman for serif, Latin Modern Roman, LM Roman, CMU Serif, Computer Modern; Liberation Sans for every other one, known telling whether the family is one of Liberation Sans' (empty, sans, sans-serif, Arial, Helvetica, Liberation Sans, Arimo) or a fallback.
Attributes: pure
subroutine family_face(family, index, known)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
family | character(len=*) | in | CSS family. | |
index | integer(kind=I4P) | out | FAMILY_SANS or FAMILY_SERIF. | |
known | logical | out | The family is compiled in (not a fallback). |
Call graph
decode
The code point of the UTF-8 character at byte k of text and its bytes (a malformed byte: its own code).
Attributes: pure
subroutine decode(text, k, code, n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | UTF-8 text. | |
k | integer(kind=I4P) | in | First byte. | |
code | integer(kind=I4P) | out | Code point. | |
n | integer(kind=I4P) | out | Bytes. |
Call graph
Functions
is_set
Whether any part of the font is set.
Attributes: elemental
Returns: logical
function is_set(self) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(font_object) | in | Font. |
Call graph
size_px
The size [px]: the font's, or page if unset.
Attributes: elemental
Returns: real(kind=R8P)
function size_px(self, page) result(size)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(font_object) | in | Font. | |
page | real(kind=R8P) | in | Page font size [px]. |
Call graph
font_of
The font of gnuplot's spec "family:Bold:Italic,size" (each part optional: ",8", ":Bold", "Times,14").
Attributes: pure
Returns: type(font_object)
function font_of(spec) result(font)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
spec | character(len=*) | in | Font spec. |
Call graph
font_attributes
The SVG attributes of font (leading blank each), its size size [px] if set (0: none): font-size, font-family (quoted when it holds a blank), font-weight, font-style.
Attributes: pure
Returns: character(len=:)
function font_attributes(font, size) result(text)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
font | type(font_object) | in | Font. | |
size | real(kind=R8P) | in | Size to write [px], 0 for none. |
Call graph
face_of
The compiled-in face (foresight_fontdata, 1-8) of font: its family (family_face), weight and style.
Attributes: elemental
Returns: integer(kind=I4P)
function face_of(font) result(face)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
font | type(font_object) | in | Font. |
Call graph
text_advance
The width of the UTF-8 text set in face at size, in the unit of size: the advance widths of its characters and the kerning of each pair. A character a sans face lacks is taken from the serif face of the same style (Latin Modern, whose data holds the math symbols), not kerned; one no face has counts 0.556 em.
Attributes: pure
Returns: real(kind=R8P)
function text_advance(text, face, size) result(width)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
text | character(len=*) | in | UTF-8 text. | |
face | integer(kind=I4P) | in | Face (foresight_fontdata, 1-8). | |
size | real(kind=R8P) | in | Font size (em). |
Call graph