Questions tagged [drawstring]

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.

313 questions
1
vote
2 answers

Java Graphics.drawString doesn't always work

Has anyone ever run into this issue before? Sometimes the string displays, sometimes half of it, sometimes none of it. The issue is worsened when using VolatileImage instead of BufferedImage as a backbuffer. public class Game3D { public static void…
Colby
  • 452
  • 4
  • 19
1
vote
2 answers

Java - Join Multiple drawString's in Swing

In Swing, in a panel, I use paintComponent to draw strings with different coordinates using Graphics2D: g2.drawString("one", 0, 0); g2.drawString("two", 50, 50); Is there a way to combine the multiple resulting drawings into one drawString? Edit: I…
Devan Somaia
  • 645
  • 1
  • 8
  • 21
1
vote
1 answer

How do I use a custom font with Slick's UnicodeFont class?

I am using this code, which was snipped and modified from the Slick Wiki Unicode tutorial: UnicodeFont menuFont = new UnicodeFont("/fonts/mailrays.ttf", 8, false, false); menuFont.addAsciiGlyphs(); menuFont.addGlyphs(400,…
michael.orchard
  • 486
  • 4
  • 16
1
vote
1 answer

String formatted using String.Format not displaying in Print Preview

I'm trying to create a print function with a corresponding print preview. For some reason, any string I create with String.Format will NOT show up on the print preview! Use the code snippet below as an example: Dim strTemp As String strTemp =…
Todd Bauer
  • 219
  • 1
  • 7
  • 15
1
vote
1 answer

Swing issue, drawing on a JTabbedPane

i'm having hard time trying to understand and solve a problem while drawing on a JPanel within a JTabbedPane Basically i have this small app that draws stats graphics, its a simple JFrame with a JTabbedPane in it. Now, the JTabbedPane has 2 tabs,…
JBoy
  • 5,398
  • 13
  • 61
  • 101
1
vote
2 answers

How to use Graphics out side the paint() method in my Java applet?

I want to use drawString() once a button is pushed to draw the answer on my applet but I can't figure it out. I have try many ways to do and my program compiles but won't drawString() when the button is pushed please help. import…
Brandon Cruz
  • 11
  • 1
  • 2
1
vote
3 answers

How to get Words length and height, when drawing the images on a canvas in GDI+

I draw a string on a canvas, using GDI+ in C++. Is there any API to get the out layer (width, height ) of a string in a certain font? Thanks very much! Many thanks to Windows programmer's solution. I wrote the following code. Bitmap…
user25749
  • 4,825
  • 14
  • 61
  • 83
1
vote
1 answer

Get the dimensions of a characters knowing all the details on the font

I need to create bitmaps of characters depending on a specified font. When they specify a font, they are specifying: Font (e.g. Microsoft Sans Serif) Font style (e.g. Bold) Size (e.g. 14) Effects (e.g. Stikeout) Script (e.g. Western) Knowing…
Freesnöw
  • 30,619
  • 30
  • 89
  • 138
1
vote
4 answers

XNA SpriteFont with multiple colors?

Is there a way to draw a text with multiple colored horizontal areas? As an example I want to draw the text "Hello" with the lower half in red and the upper in green. The text to use has to be dynamic. With a normal Texture I would just use the Draw…
michael
  • 479
  • 1
  • 4
  • 8
1
vote
0 answers

C# DrawString is Adding Outline or Drop Shadow to Certain Fonts at Certain Sizes

I'm using C# DrawString to draw text on an image background which is output as a TIFF for printing. For some fonts at some sizes, the DrawString method is adding a border around the text. Both of these examples are drawn using the same code, just…
1
vote
0 answers

C# DrawString with StringFormatFlags: How to Flip Vertical Orientation?

I'm drawing strings on an image and saving it as a TIFF. I need to orient the text like this: desired output I'm using this code to create the string format: formatFlags = (StringFormatFlags.NoClip | StringFormatFlags.DirectionVertical |…
1
vote
1 answer

how do I center align drawstring bmp from text input in picturebox c#

I'm a beginner writing a simple windows desktop form app with a textbox that user types into and then clickbutton converts that text into a bitmap that is shown in a picturebox (that is only 96 x 64 pixels as it displays on an LED display…
Unwired4
  • 25
  • 3
1
vote
0 answers

Compact long string with PathEllipsis in .Net

I have following string, which i am drawing in one of my treeview control using DrawString. @haTEST sadasd asd asd asd asd asd asd asd ### adssad asd asd asd asd asd asdasdasd The treeview is drawing the above string like following: Now,i want to…
AmitSri
  • 1,209
  • 1
  • 20
  • 48
1
vote
1 answer

Get the position where drawn text is truncated by GraphicsPath.DrawString

I have a couple of methods that draw outlined text. The details of this are unimportant, but it serves to illustrate the problem: (source code from Graphics DrawPath produces unexpected results when rendering text) Private Sub FillTextSolid(g As…
stigzler
  • 793
  • 2
  • 12
  • 29
1
vote
1 answer

How can I make drawString faster in Windows 10?

My ancient application leans heavily on drawString. It's at least 20 times slower in Windows 10. Are there ways to speed up drawing text in Windows? The following code illustrates the difference. import javax.swing.*; import java.awt.*; public…
orange
  • 13
  • 2