mdraw_text_extents(3m17n)

πŸ“¦
version 1.8.4 Β· 2 versions
, in debian trixie, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

mdraw_text_extents β€” bestie, the NAME line is literally just the function name and a lonely little dash. No description. The manpage authors said "figure it out πŸ’…" and honestly? We respect the minimalism.


πŸŽ€ SYNOPSIS πŸŽ€

int mdraw_text_extents (MFrame * frame, MText * mt, int from, int to,
       MDrawControl * control, MDrawMetric * overall_ink_return, MDrawMetric *
       overall_logical_return, MDrawMetric * overall_line_return)

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so picture this: you need to know how many pixels wide some text is gonna be. That's the whole vibe. The mdraw_text_extents() function computes the width of the text between from and to of M-text mt when it gets drawn on a window of frame frame using the mdraw_text_with_control() function with the drawing control object control. Measuring before you draw. Main character behaviour, fr fr. πŸ”₯

Now, the three return-y parameters are where it gets juicy, and they're all optional β€” pass NULL and that one just doesn't happen, no hard feelings:

  • overall_ink_return β€” if it's not NULL, this function also computes the bounding box of the character ink of the M-text, and stores the results in the members of the structure pointed to by overall_ink_return. And listen β€” if the M-text has a face specifying a surrounding box, that box gets included in the bounding box too. It's giving "we counted the outfit, not just the person." πŸ‘‘
  • overall_logical_return β€” if it's not NULL, this function also computes the bounding box that provides minimum spacing to other graphical features (such as the surrounding box) for the M-text, and stores the results in the members of the structure pointed to by overall_logical_return. Personal space. Boundaries. We love to see it. 🫢
  • overall_line_return β€” if it's not NULL, this function also computes the bounding box that provides minimum spacing to the other M-text drawn, and stores the results in the members of the structure pointed to by overall_line_return. And here's the cute little conditional: this is a union of overall_ink_return and overall_logical_return if the members min_line_ascent, min_line_descent, max_line_ascent, and max_line_descent of control are all zero. All four of them. Every single one. Zero. 🌸

🌈 RETURN VALUE 🌈

This function returns the width of the text to be drawn in the unit of pixels. That's the headline number, bestie. πŸ“

But wait β€” if control->two_dimensional is nonzero and the text is drawn in multiple physical lines, it returns the width of the widest line. Widest line wins. That's the rule. πŸ‘‘

And if an error occurs, it returns -1 and assigns an error code to the external variable merror_code. So like, check for that. πŸ’€


πŸ’œ ERRORS πŸ’œ

  • MERROR_RANGE β€” that's the one. The only one listed. She's alone but she's iconic. 😭

Copyright (C) 2001 Information-technology Promotion Agency (IPA)

Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License <http://www.gnu.org/licenses/fdl.html>.


and that's the whole page, bestie!! 🫢✨ this was Version 1.8.4, dated Mon Sep 25 2023, and it lives in section 3m17n of The m17n Library manual. go forth and measure ur pixels, u absolute legend πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from