# Suggestion for alternative for calculating text resize in TextArea

**URL:** <https://forum.xojo.com/t/suggestion-for-alternative-for-calculating-text-resize-in-textarea/53720>\
**Category:** Getting Started\
**Created:** [May 8, 2020, 2:04pm UTC](https://forum.xojo.com/t/suggestion-for-alternative-for-calculating-text-resize-in-textarea/53720 "2020-05-08T14:04:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [May 8, 2020, 2:04pm UTC](https://forum.xojo.com/t/suggestion-for-alternative-for-calculating-text-resize-in-textarea/53720/1 "2020-05-08T14:04:14Z")

</div>

I use the graphics class to resize the text to fit within various windows the textarea. Currently I pass the area as an object to a method and resize the text there. I need a suggestion for an alternate process than resizing it in the object because it flashes on the screen while it is resizing.

I am told the Graphics class needs a control to do this resizing, so if there is a way to do this without a control, that would work.

I thought of creating a window strictly for making the calculations, but that seems impractical, because that means I’d need to keep this window active.

I also imagine I could have a TextArea off the window and use that for this calculation.

I also have not learned how to create anything by code, so that is a possibility.

Suggestions?

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [May 8, 2020, 2:20pm UTC](https://forum.xojo.com/t/suggestion-for-alternative-for-calculating-text-resize-in-textarea/53720/2 "2020-05-08T14:20:13Z")

</div>

Use `Window.BitmapForCaching` to get a properly constructed HiDPI aware image/graphics object for the window on it’s current screen.  
Using the text area coordinates, calculate the sizing of the text in the offscreen Graphics object from that picture.  
Set the text sizing once you’ve calculated it.

Does that work out any better?

---

<div class="post-metadata">

**Author:** ![Arthur\_Gabhart](https://forum.xojo.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@Arthur\_Gabhart](https://forum.xojo.com/u/Arthur_Gabhart)\
**Post date:** [May 8, 2020, 2:51pm UTC](https://forum.xojo.com/t/suggestion-for-alternative-for-calculating-text-resize-in-textarea/53720/3 "2020-05-08T14:51:58Z")

</div>

Thanks. I didn’t pay attention because it is for HIDPI.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [May 8, 2020, 3:12pm UTC](https://forum.xojo.com/t/suggestion-for-alternative-for-calculating-text-resize-in-textarea/53720/4 "2020-05-08T15:12:46Z")

</div>

> [@487759:@Arthur Gabhart](#):
>
> Thanks. I didn’t pay attention because it is for HIDPI. Does anything change if it’s normal graphics?

That’s why you grab the `Window.BitmapForCaching`, the Picture you get from that will be properly configured. You may have to experiment with HiDPI vs non-HiDPI to ensure calculations are correct for both. Getting the graphics object will look something like this:

```auto
dim tpicWindowRep as Picture = self.BitmapForCaching
dim g as Graphics = tpicWindowRep.Graphics
```

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [May 8, 2020, 3:15pm UTC](https://forum.xojo.com/t/suggestion-for-alternative-for-calculating-text-resize-in-textarea/53720/5 "2020-05-08T15:15:03Z")

</div>

Looks like you might have figured it out while I was working on that. I hope it helped and didn’t confuse.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 4:23pm UTC](https://forum.xojo.com/t/suggestion-for-alternative-for-calculating-text-resize-in-textarea/53720/6 "2021-04-29T16:23:59Z")

</div>


