Hi,
I'm trying to draw some text in my picture, I normally use a Rectangle and set the Text property, but this time I don't want a background to the text. What should I use? I also don't want a border, so setting the DrawStyle of the Rectangle to Edge isn't any good. I tried a PointText, but the font is all horrible, couldn't work out why.
I've attached the file showing the result using PointText. When I use a Rectangle with Text it looks nice
var label = new PointText();
label.Location = picture.PointDeviceToElement(new Vector(distanceFromLeftToRuler - tickLineLength - 10, heightInPixels));
label.Text = HTMLtoRTF.ConvertToUnicode(value);
label.TextAppearance = new Prodige.Drawing.Styles.TextAppearance() { SizeUnit = System.Drawing.GraphicsUnit.Millimeter, Size = 3f / picture.Scaling.X };
label.TextAppearance.HorizontalAlignment = System.Drawing.StringAlignment.Far;
label.TextAppearance.VerticalAlignment = System.Drawing.StringAlignment.Center;
What am I doing wrong?
Thanks,
Euan
PointText
Moderators: Frank Hileman, Anne Szyjan
- Frank Hileman
- Site Admin
- Posts: 1400
- Joined: Sun Jul 25, 2004 8:16 pm
- Location: California
- Contact:
Re: PointText
Hello Euan,
Usually when there is a problem like this, I try drawing an Element in the designer, where I can control all properties via the property grid. This is much faster than changing code and re-running the program.
In this case, I can think of only these potential problems:
Usually when there is a problem like this, I try drawing an Element in the designer, where I can control all properties via the property grid. This is much faster than changing code and re-running the program.
In this case, I can think of only these potential problems:
- The text created via your ConvertToUnicode method.
- Some unequal scaling or a strange shearing transformation applied to the text. This scaling may be on the Element itself, or it may be at a higher level.
- The font may be wacky.
- The Elements are doubled? There is a strange effect as if things are drawn twice.
- You are drawing into a transparent bitmap and then drawing that bitmap on another surface. There is a known flaw with the ClearText algorithm in GDI+ whereby the algorithm cuts "holes" in transparent bitmaps (sets pixel areas to have no opacity). This is most evident when using the TranslucentForm, but it can occur in other circumstances. In this case, the work around is to reduce the opacity of the TextAppearance color slightly (.99 or so). Such a small change in opacity fixes the bug.
Frank Hileman
http://www.vgdotnet.com
http://www.vgdotnet.com
- Frank Hileman
- Site Admin
- Posts: 1400
- Joined: Sun Jul 25, 2004 8:16 pm
- Location: California
- Contact:
Re: PointText
Hello Euan,
I could not reproduce the problem. I did note you are using Millimeters as a size unit. This is rare. I don't know if there is any bug with this unit, but world coordinates are generally the best unit, as they are independent of DPI.
Regards,
I could not reproduce the problem. I did note you are using Millimeters as a size unit. This is rare. I don't know if there is any bug with this unit, but world coordinates are generally the best unit, as they are independent of DPI.
Regards,
Frank Hileman
http://www.vgdotnet.com
http://www.vgdotnet.com
Re: PointText
Hi Frank,
yes, it seemed to be related to the Millimeters size unit. All ok now
thanks,
Euan
yes, it seemed to be related to the Millimeters size unit. All ok now
thanks,
Euan