mdraw_text_extents(3m17n)
β¨ 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 notNULL, 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 byoverall_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 notNULL, 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 byoverall_logical_return. Personal space. Boundaries. We love to see it. π«Άoverall_line_returnβ if it's notNULL, 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 byoverall_line_return. And here's the cute little conditional: this is a union ofoverall_ink_returnandoverall_logical_returnif the membersmin_line_ascent,min_line_descent,max_line_ascent, andmax_line_descentofcontrolare 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 π
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
- debian trixie: m17n-docs 1.8.4-1
- ubuntu noble: m17n-docs 1.8.4-1
- ubuntu questing: m17n-docs 1.8.4-1
- ubuntu resolute: m17n-docs 1.8.4-1build1
- ubuntu stonking: m17n-docs 1.8.4-1build1
- Copyright (C) 2001 Information-technology Promotion Agency (IPA)
- Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms