Expand description
Built-in font metrics lookup tables and text/label sizing ported from Graphviz 16.1.0
(lib/common/textspan_lut.c, lib/common/textspan.c, lib/common/ps_font_equiv.h,
and lib/common/labels.c).
Structs§
- Label
Subst Context - Context for Graphviz object-based escape sequence substitution (
\N,\G,\T,\H,\E,\L). - Postscript
Font Alias - PostScript font alias entry (
PostscriptAliasinlib/common/textspan.h). - Text
Label Layout - Measured layout of a multiline Graphviz label in points.
- Text
Line Layout - Measured layout of a single line within a multiline text label.
Enums§
- Text
Justify - Horizontal justification of a single line in a Graphviz label.
Constants§
- DEFAULT_
FONT_ NAME - Default font family name in Graphviz (
Times-Roman). - DEFAULT_
FONT_ SIZE - Default font size in points (
14.0). - DEFAULT_
LABEL_ FONT_ SIZE - Default head/tail label font size in points (
11.0). - LINESPACING
- Line spacing multiplier (
1.20) fromlib/common/const.h. - MIN_
FONT_ SIZE - Minimum allowed font size in points (
1.0). - POSTSCRIPT_
FONT_ ALIASES - Standard PostScript font equivalence table (
postscript_alias[]fromlib/common/textspan.c, generated fromps_font_equiv.hbyscripts/gen-font-tables.py).
Functions§
- charset_
is_ latin1 - Returns
trueif a graph’scharsetattribute selects Latin-1 (findCharsetinlib/common/input.c:latin-1,latin1,l1,ISO-8859-1,ISO_8859-1,ISO8859-1,ISO-IR-100, case-insensitively). - convert_
label_ text - The label text conversion of
make_labelfor a graph of charsetcs(latin1ToUTF8for Latin-1,htmlEntityUTF8otherwise). - decode_
html_ entities - Decodes HTML character entity references, matching
htmlEntityUTF8inlib/common/utils.c(kept under its historical name for existing callers). - estimate_
text_ size - Estimates the
(width, height)in points of a single-line text span for a givenfont_nameandfont_size, matchingestimate_textspan_sizeinlib/common/textspan.c. - estimate_
text_ size_ styled estimate_textspan_sizefromlib/common/textspan.cwith explicitbold/italicflags (HTML_BF/HTML_IF):(fontsize * width_1pt, fontsize * LINESPACING).- estimate_
text_ width_ 1pt estimate_text_width_1ptfromlib/common/textspan_lut.c: width oftextat 1pt.- html_
entity_ utf8 htmlEntityUTF8fromlib/common/utils.c: replaces HTML entities (&,{,{) by their UTF-8 encoding. Works on the input’s bytes (seecrate::charset): a lead byte without its continuation bytes, or a byte>= 0xF8, is converted as if it were Latin-1, with C’s once-per-graph warning.- latin1_
to_ utf8 latin1ToUTF8fromlib/common/utils.c(used whencharset=latin1): translates HTML entities and re-encodes every byte>= 0x7Fof the input (seecrate::charset) as if it were a Latin-1 code point.- make_
simple_ label make_simple_labelfromlib/common/labels.c: splitstext(already object- and entity-substituted) into lines on\n,\l,\rand literal newlines, reducing every other\ctoc.width/heightare C’slp->dimen.- make_
simple_ label_ cs make_simple_labelfor a graph of charsetcs. C scans bytes; withcharset=big5a byte in0xA1..=0xFEtakes the next byte with it, so that byte is never an escape.- make_
text_ label - Plain-text branch of
make_labelfromlib/common/labels.c: object escape substitution, charset conversion (latin1ToUTF8forcharset=latin1, elsehtmlEntityUTF8) andmake_simple_label. - measure_
multiline_ label - Measures a multiline Graphviz label for a node named
node_name. - measure_
multiline_ label_ with_ context - Measures a multiline plain-text Graphviz label in the charset of the graph being laid
out (
charset::current); seemake_text_label. - strdup_
and_ subst_ obj strdup_and_subst_objfromlib/common/labels.c: object escapes plus\\->\(used forURL,tooltip,id, … attributes).- substitute_
object_ escapes - Substitutes Graphviz object escapes (
\N,\G,\T,\H,\E,\L) while preserving line-formatting escapes (\n,\l,\r,\\) formake_simple_label; this isstrdup_and_subst_obj0(str, obj, 0)fromlib/common/labels.c. - translate_
postscript_ fontname translate_postscript_fontnamefromlib/common/textspan.c:bsearchof the alias table withstrcasecmp. The name is used verbatim (no trimming), as in C.