# Advance property in bounding box returned by textBounds

**URL:** <https://discourse.processing.org/t/advance-property-in-bounding-box-returned-by-textbounds/43735>\
**Category:** Beginners\
**Created:** [January 23, 2024, 12:00am UTC](https://discourse.processing.org/t/advance-property-in-bounding-box-returned-by-textbounds/43735 "2024-01-23T00:00:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabiopettinati](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/fabiopettinati/32/15727_2.png) [@fabiopettinati](https://discourse.processing.org/u/fabiopettinati)\
**Post date:** [January 23, 2024, 12:00am UTC](https://discourse.processing.org/t/advance-property-in-bounding-box-returned-by-textbounds/43735/1 "2024-01-23T00:00:56Z")

</div>

The bounding box returned by textBounds() has the expected properties (x, y, h, w) and one more that surprised me: “advance”. What does it do? When would I use it? There is no documentation on this item.

Thanks!

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [January 23, 2024, 12:22am UTC](https://discourse.processing.org/t/advance-property-in-bounding-box-returned-by-textbounds/43735/2 "2024-01-23T00:22:57Z")

</div>

> <https://github.com/processing/p5.js/blob/v1.9.0/src/typography/p5.Font.js#L217-L227>

The only place I’ve found prop _advance_ is accessed is inside method **textBounds()** itself:

> <https://github.com/processing/p5.js/blob/v1.9.0/src/typography/p5.Font.js#L229-L236>

---

<div class="post-metadata">

**Author:** ![fabiopettinati](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/fabiopettinati/32/15727_2.png) [@fabiopettinati](https://discourse.processing.org/u/fabiopettinati)\
**Post date:** [January 23, 2024, 10:02am UTC](https://discourse.processing.org/t/advance-property-in-bounding-box-returned-by-textbounds/43735/3 "2024-01-23T10:02:11Z")

</div>

Thanks for looking into that

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [January 23, 2024, 10:03am UTC](https://discourse.processing.org/t/advance-property-in-bounding-box-returned-by-textbounds/43735/4 "2024-01-23T10:03:16Z")

</div>

It is used to help control horizontal placement of the text based on the current text alignment set by the user.

We can see that the value of `result.w + result.advance` is passed as the fifth parameter in the `_handleAlignment` method call.

The function header shows that this parameter is called `textWidth`  
` _handleAlignment(renderer, line, x, y, textWidth) {`

I doubt whether you can find much use for this in your own sketches.

In my limited experience of low level font usage (Java) the term advance is used to measure the width of the text just printed and is used to _advance_ the horizontal text drawing position for subsequent text printing.
