XmbTextExtents(3)

🌸 XmbTextExtents(3) β€” XLIB FUNCTIONS 🌸

okay so welcome to the XLIB FUNCTIONS corner of the manual, bestie. this page is literally about three functions that compute text extents, and we’re gonna get into all the details without losing a single crumb. 🫢

πŸ’– NAME πŸ’–

XmbTextExtents, XwcTextExtents, Xutf8TextExtents β€” compute text extents. that’s the whole name section, short and iconic. ✨

🧚 SYNTAX 🧚

       int XmbTextExtents(XFontSet font_set, _Xconst char *string, int
              num_bytes, XRectangle *overall_ink_return, XRectangle
              *overall_logical_return);

       int XwcTextExtents(XFontSet font_set, _Xconst wchar_t *string, int
              num_wchars, XRectangle *overall_ink_return, XRectangle
              *overall_logical_return);

       int Xutf8TextExtents(XFontSet font_set, _Xconst char *string, int
              num_bytes, XRectangle *overall_ink_return, XRectangle
              *overall_logical_return);

πŸŽ€ ARGUMENTS πŸŽ€

  • font_set β€” Specifies the font set. yes bestie, that’s the font set in question. πŸ’…
  • num_bytes β€” Specifies the number of bytes in the string argument. count ’em in bytes, not vibes.
  • num_wchars β€” Specifies the number of characters in the string argument. this one counts characters, okay?
  • overall_ink_return β€” Returns the overall ink dimensions. πŸ–‹οΈ
  • overall_logical_return β€” Returns the overall logical dimensions. logic slay.
  • string β€” Specifies the character string. the actual text, periodt.

🌈 DESCRIPTION 🌈

Okay so XmbTextExtents, XwcTextExtents, and Xutf8TextExtents set the components of the overall_ink_return and overall_logical_return arguments you passed in. Specifically:

  • the components of overall_ink_return get set to the overall bounding box of the string’s image πŸ–ΌοΈ
  • the components of overall_logical_return get set to a logical bounding box for spacing purposes πŸ“

(respectively, bestie β€” don’t mix ’em up.)

They return the value returned by XmbTextEscapement, XwcTextEscapement, or Xutf8TextEscapement. These metrics are relative to the drawing origin of the string, using the fonts loaded for the specified font set. no cap.

If overall_ink_return is non-NULL, it is set to the bounding box of the string’s character ink. For a nondescending, horizontally drawn Latin character, the convention is that it sits entirely above the baseline β€” that is, overall_ink_return.height <= -overall_ink_return.y. For a nonkerned character, it’s entirely at, and to the right of, the origin β€” that is, overall_ink_return.x >= 0. A character consisting of a single pixel at the origin would set overall_ink_return fields y = 0, x = 0, width = 1, and height = 1. tiny pixel icon behavior, literally. 😭

If overall_logical_return is non-NULL, it is set to the bounding box that provides minimum spacing to other graphical features for the string. Other graphical features, for example, a border surrounding the text, should not intersect this rectangle. so like, give the text its personal space. 🫢

When the XFontSet has missing charsets, metrics for each unavailable character are taken from the default string returned by XCreateFontSet so that the metrics represent the text as it will actually be drawn.

⚠️ bestie, warning: the behavior for an invalid codepoint is undefined. undefined means don’t come crying to me when the vibes break β€” it’s not specified. πŸ’€

The function Xutf8TextExtents is an extension introduced by The XFree86 Project, Inc., in their 4.0.2 release. Its presence is indicated by the macro X_HAVE_UTF8_STRING. slay, now you can check for it.

πŸ‘‘ SEE ALSO πŸ‘‘

Go peep XmbTextEscapement(3) and XmbTextPerCharExtents(3), plus Xlib - C Language X Interface. iykyk. ✨


mwah πŸ’‹ that’s the page, bestie. footer flex: X Version 11, libX11 1.8.14, and XmbTextExtents(3) β€” iconic source/version energy, and no separate date printed in this one. πŸŽ€

πŸ“¦ where this page comes from