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
5
votes
1 answer
C# single font character size?
This is not about the size of a string.
I specify a font for drawing strings. And now I need the exact width of 1 character in pixels. I only allow fonts that have static char-width (W and i have the same width when drawn). If I use "Consolas" with…

Bitterblue
- 13,162
- 17
- 86
- 124
5
votes
2 answers
Gdiplus DrawString draws transparent text over Remote Desktop
I'm drawing text into a DIB section off-screen bitmap, which is 32bit deep and uses the alpha channel (ARGB). I draw pixels directly to memory. Then, I create a Gdiplus Graphics object, pass my memory DC to it, and draw text using…

digory doo
- 1,978
- 2
- 23
- 37
4
votes
0 answers
How to convert Unicode text into a Bitmap
I need to convert a text containing Unicode chars into a Bitmap that could have a transparent background as well.
I found and tried different posts like this, this, or this, but no one seems to work for me.
I found also this post that suggests using…

ilCosmico
- 1,319
- 15
- 26
4
votes
1 answer
Why different font rendering with graphics.drawString() and a default JLabel with ClearType?
Why has the displayed GUI different font style/rendering with graphics.drawString() and a default JLabel with activated cleartype? And how can i fix it?

tomkpunkt
- 1,393
- 2
- 15
- 24
4
votes
1 answer
Redraw strings in CardLayout
I have made a game using CardLayout and have one JPanel for the leaderboard. In leaderboard, I read two files (one with names, one with times), sort them and draw the top 5 fastest times like this:
private void setBoard(){
reset();
…

Faiq
- 41
- 7
4
votes
4 answers
Graphics.drawString() Draws Over My Old String
I'm working on simple counter. My problem is that drawString() method draws new string over the old one. How to clear the old one before? Code...
package foobar;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
public…

daGrevis
- 21,014
- 37
- 100
- 139
4
votes
2 answers
How to draw unicode string using C# graphics.DrawString
I'm trying to send khmer script(unicode) string to printer using PrintDocument provided by the .NET framework.
Unfortunately it seems to me that the Graphics.DrawString() does not render khmer script correctly.
Platform: Windows 7 Ultimate
IDE: VS…

lchanmann
- 357
- 2
- 10
4
votes
2 answers
Graphics.Drawstring looks nice in PictureBox but horrible in a Bitmap
I am trying to use DrawString to write text as an image and then rotate it 90 degrees. It works fine with both a bitmap or directly on a PictureBox, but the big difference is in the quality. The PictureBox text drawn has great quality and looks…

Dan
- 905
- 4
- 10
- 16
4
votes
1 answer
Receipt printing in roll paper
I searched for a lot in google and did not find what i actually wanted. I got following code, which will print the variable name. I got a Epson Dot Matrix Printer and Roll Paper (Endless continuous paper).
My problem is that, after printing name…

vinrav
- 371
- 3
- 12
4
votes
3 answers
The text is too bold by DrawString on C#
I have use GDI DrawString method to draw text. When the program is running, the text on the screen seems very good, however once I saved the files to image, the font will be bolder than before. The normal will be bold, the bold will be much bolder.…

SuperBerry
- 1,193
- 1
- 12
- 28
4
votes
2 answers
Drawing text in vb.net to match a menu item
I'd like to put a number in the left-hand margin of a menu item in vb.net 2010, but it seems this can only be set to an image. So, I've been trying to create an image with the number I want there using Graphics.DrawString(). I've tried various ways,…

dsl101
- 1,715
- 16
- 36
4
votes
3 answers
Why JFrame is empty after my graphics
Why JFrame is empty after my graphics
package javaGame;
import java.awt.Graphics;
import javax.swing.JFrame;
public class javaGame extends JFrame {
public javaGame (){
setVisible(true);
setSize(250,250);
…

alibabaei12
- 161
- 1
- 2
- 9
4
votes
2 answers
PdfSharp: Text height/positioning problem
Whether I use XTextFormatter or not, I get the same error about the LayoutRectangle having to have a height of 0 or something like this.
new PdfSharp.Drawing.Layout.XTextFormatter(_gfx).DrawString(text
, new PdfSharp.Drawing.XFont(fontName,…

Will Marcouiller
- 23,773
- 22
- 96
- 162
4
votes
2 answers
Make drawstring partially bold
Good morning.
I have created a custom treeview control that paints a normal treeview onto the screen, plus various other things. During the paint event I draw the node.text string to the treeview control using the following method.
node.text =…

Matt Skeldon
- 577
- 8
- 23
4
votes
3 answers
PdfSharp XGraphics.DrawString not working for Right-To-Left Languages like Persian
I'm working with PdfSharp to create some pdf files. Everything works fine except when I try to put some text into the file in a right-to-left language (e.g., Persian) using Drawstring method. Although I choose Unicode encoding in XPdfFontOptions and…

Mojingo
- 43
- 1
- 4