I determined font metrics with my old code:
GetTextMetrics pic.hdc, text_metrics
internal_leading = text_metrics.tmInternalLeading
total_hgt = text_metrics.tmHeight
text_hgt = total_hgt - internal_leading
text_wid = pic.ScaleX(pic.TextWidth("Text")), pic.ScaleMode, vbPixels)
I cant figure out the font metrics correctly with teechart. My results seem to be wrong:
Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw
text_hgt = g.TextHeight("Text") ' without leading
text_wid = g.TextWidth("Text")
total_hgt = ? 'with leading
End Sub
Font Metrics
Re: Font Metrics
The g.textwidth worked for centering and positioning text.
Re: Font Metrics
Hello lilo,
I am glad that you can find a solution . And also, can help you, take a look in this thread, where are working with alignment of Text.
Thanks,
I am glad that you can find a solution . And also, can help you, take a look in this thread, where are working with alignment of Text.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Font Metrics
I also need to determine textheight in pixels. I am getting inconsistent results using this code:
Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw
text_hgt = g.TextHeight("Text")
End Sub
The result is given in some other units, usually something like thousands of units for 34 font.size text. How can I get the textheight in pixels?
Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw
text_hgt = g.TextHeight("Text")
End Sub
The result is given in some other units, usually something like thousands of units for 34 font.size text. How can I get the textheight in pixels?
Re: Font Metrics
Hello lilo,
I think you have two ways to get Height of Text :
First , using g.TextHeight,as you do, so it returns values in pixels Text Height or Width:
Second, using MeasureString method that returns Text Size in pixels, too:
For us this methods returns a correctly values (height and width) that text have, but if you can find a inconsistency with results, please explain exactly what is it? And why can not you consider correct, the values do you get?
Thanks,
I think you have two ways to get Height of Text :
First , using g.TextHeight,as you do, so it returns values in pixels Text Height or Width:
Code: Select all
void tChart1_AfterDraw(object sender, Graphics3D g)
{
g.Font.Size = 10;
this.Text = g.TextHeight("Text").ToString() + "," + g.TextWidth("Text").ToString();
}
Code: Select all
void tChart1_AfterDraw(object sender, Graphics3D g)
{
g.Font.Size = 10;
SizeF fontSize = g.MeasureString(g.Font, "Text");
this.Text= fontSize.ToString();
}
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |