Main Site Documentation

String display length


#1

how can I determine the length of a trutype font string in pixels ? I need to be able to right justify a string. Using UD700, UC5550


#2

I just came across this! It is there but I can’t remember what it was…

Let me check


#3

is it Graphics.MeasureString?


#4

no, that’s not it. I looked in system.drawing and ghielectroniscs.tinclr.drawing


#5

What are you looking to do that MeasureString doesn’t work? You can right-align using the void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format) overload, passing the desired alignment in the StringFormat parameter.


#6

This worked:

        RectangleF r = new RectangleF(150, 92, 150, 30);
        StringFormat s = new StringFormat();
        s.Alignment = StringAlignment.Far;
        scrn.DrawString("Gross: ", G.fontArial_12, G.BlackBrush, r, s);

Thanks!