Graphics.DrawString is a method in the .Net Framework's System.Drawing namespace, by which code can draw text onto an image in .Net code. This is mainly used in ASP.Net, as TextRenderer.DrawText (from System.Windows.Forms) provides more reliable functionality in Windows Forms applications.
Questions tagged [drawstring]
313 questions
2
votes
1 answer
Draw text on WriteableBitmap
I would like to draw some text on a WriteableBitmap. This doesn't seem possible, but I found converting WriteableBitmap to Bitmap in C# here and this.
Here's the call (with conversion method included, too):
// Draw dino names...
…

zetar
- 1,225
- 2
- 20
- 45
2
votes
2 answers
Unable to Create Image of Special Characters
I have written a imageHandler.ashx in c# which draw image of a text on a fly . Its takes a parameter string txt. The Handler is called from Asp.net page. At the time of calling, if text contains the character @ or any special character .it Does not…

Malik Rizwan
- 23
- 3
2
votes
1 answer
XNA - How to change orientation of Drawing a List of Strings
How do you Draw a list of strings with a spritebatch so that it looks like this;
Item1 Item2
Item3 Item4
Instead of Item 1 Item 2 Item 3 Item 4 or instead of:
Item1
Item2
Item3
Item4

TheQuantumBros
- 308
- 3
- 4
- 17
2
votes
2 answers
java Graphics2D quality of drawString
I have a question regarding the quality of the drawString function, currently I have this image:
Basically what you see in the bottom middle is a card drawn on 125% of it's size. The cards in the background are relatively 50% and 25% size.
However…

skiwi
- 66,971
- 31
- 131
- 216
2
votes
0 answers
How to use Graphics.DrawString with a font not installed in C#
Environment: Windows 7 Pro, C#, WinForms
I am successfully using Drawstring to write a text string to a PictureBox if the font is installed. <== Code below is working just fine...
I also want to be able to write a text string from a font file that…

Jason V
- 837
- 9
- 18
2
votes
2 answers
Trying to use drawString method to print a name
I'm just going through some basic tutorials at the moment. The current one wants a graphics program that draws your name in red. I've tried to make a NameComponent Class which extends JComponent, and uses the drawString() method to do this:
import…

John Dawson
- 443
- 3
- 10
- 28
2
votes
2 answers
Passing a string from database to drawString()
I have a database with all the values stored in a table. I want to print a name from the table using drawString() method. I hv created a resultset and the arraylist. Is there any way to pass a string from database in drawString method??
Please…

Ankur Sharma
- 53
- 1
- 6
2
votes
1 answer
How to color individual characters and maintain proper spacing / kerning / alignment?
I want to use Graphics.DrawString to draw characters using individual colors.
The problem is that each time I call DrawString, I have to know where to position it (either using a Point or a Rectangle) relative to the other characters.
This is almost…

Trevor Elliott
- 11,292
- 11
- 63
- 102
2
votes
1 answer
Java Swing's drawString shows an echo
I am not sure what I am doing wrong...
I wanted to make a JComponent showing a string with custom font, custom colors (including gradient background), etc. It works fine, but I see the bottom of the string in the upper-left part of my component. The…

PhiLho
- 40,535
- 6
- 96
- 134
2
votes
0 answers
DrawString EllipsisCharacter has different behavior in test program than production library?
I was drawing on a bitmap in a test program using the following code. The ellipsis worked as expected. I moved the code to a .dll called on our webserver, and the ellipsis behavior changed to have no '...' and to trim at the word boundary:
The text…

Joel McIntyre
- 83
- 2
- 5
2
votes
0 answers
Using text attributes for picture in Graphics2D object JAVA
I have a weird problem - I'm trying to write a text string over a transparent GIF picture.
I'm using awt Graphics2D object, and for some reason, I cannot affect the way the text looks - its color, its alignment and so on. Every time I use drawString…

Urit Lanzet
- 21
- 1
2
votes
4 answers
C# How to draw in front of objects?
How do you draw a string that is supposed to be on top of everything else?
Right now in my panel i have some user controls in Panel1.Controls. So i added this to the Paint method:
Graphics g = Panel1.CreateGraphics();
g.DrawString("BUSTED", new…

Patrick
- 1,763
- 5
- 18
- 16
2
votes
1 answer
How does one Read an external applications DrawText drawn text
I have been struggeling a long time with this question: "How does one Read an external applications DrawText drawn text?".
Im coding in C# right now.
It is not possible for me to use Optical Character Recogniniton and i would prefer not to Hook or…

user1593973
- 21
- 3
2
votes
2 answers
drawstring onclick method C#
I have some strings that I have drawn using DrawString
for (int j = 0; j < dt.Rows.Count; j++)
{
e.Graphics.DrawString(Convert.ToString(dt.Rows[j]["ID"]), drawFont, drawBrush, new…

Badmiral
- 1,549
- 3
- 35
- 74
2
votes
1 answer
How to achieve fine font scaling in .NET?
Microsoft Office does a very nice job when it comes to scaling of fonts. They can almost linearly be scaled in steps of 0.5 points (see image below).
Using Graphics.DrawString I was not able to reproduce this but I see distinct steps when scaling…

Paul B.
- 2,394
- 27
- 47