Center local file Text (GDI+) Source?

Gil

New Member
Is there a way to center a Text (GDI+) source when the content comes from a local txt file?

I want to put some text on my screen, have it centered, and have it STAY centered when the text being displayed changes. All I can find at the moment is to center the source box, but the left part of the box stays anchored. I want the center of the box to stay anchored.

See attached files for a visual. I centered the text box with the Beatles song playing. When the Stones song comes on (and the content of the text file I'm using changes), the box stays anchored at the left edge which means the text is still centered within the box, but it isn't centered on the screen.

My only possible workaround so far is to pad the text with spaces so that each line always has the same number of characters. But that workaround will only work with monospaced fonts. I'd really like to use a proportional font.

Any help, anyone?

"Gil"
 

Attachments

  • 2020-08-21 11_04_01-OBS 25.0.8 (64-bit, windows) - Profile_ CamUp - Scenes_ Untitled.png
    2020-08-21 11_04_01-OBS 25.0.8 (64-bit, windows) - Profile_ CamUp - Scenes_ Untitled.png
    271.2 KB · Views: 1,176
  • 2020-08-21 11_05_23-OBS 25.0.8 (64-bit, windows) - Profile_ CamUp - Scenes_ Untitled.png
    2020-08-21 11_05_23-OBS 25.0.8 (64-bit, windows) - Profile_ CamUp - Scenes_ Untitled.png
    274.5 KB · Views: 1,165

GeeMack

Member
Is there a way to center a Text (GDI+) source when the content comes from a local txt file?

In the "Properties" dialog for that text source there will be an option to "Use Custom Text Extents". Start by setting that to the dimensions of your screen, and in that same dialog box set "Alignment" and "Vertical Alignment" to "Center". That will keep the entire text centered in the screen even when you change the length or number of lines of the text.

To do some fine tuning from there, adjust those "Properties" settings, and adjust the source's placement with "Transform>" and "Edit Transform...". You should be able to tweak the location and alignment to suit any particular need.
 

Gil

New Member
GeeMack, thank you very much for the tips. I didn't know what the Custom Text Extents were all about. That got me part way there. I got the text box to stay put where I wanted it at the size I wanted, but I still couldn't get the text to center within the box. I could move the text rightward, but it still positioned the longest text line to start at the same location based on the leftmost character (if that makes any sense).

However, I was able to use a workaround. One of the four lines of text in the changeable source text file actually doesn't change. So I simply padded that line with enough spaces to ensure that line would be the longest line, fixing the rest of the centered lines in place.

Thanks again!
 
Top