drawstring

XNA - How to change orientation of Drawing a List of Strings

浪尽此生 提交于 2019-12-11 02:41:53
问题 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 回答1: Something like this would make it a little easier to change later on: int y = startPointY; int x = startPointX; int switchAt = items.Count/2; //<--- or where ever you might want to break up the strings int max = 0; for(int i = 0; i < items.Count; i++) { spriteBatch.DrawString(font, items[i], new Vector2(x, y

Graphics.drawString() Draws Over My Old String

二次信任 提交于 2019-12-10 15:56:29
问题 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 class board extends JPanel implements Runnable { Thread animator; int count; public board() { this.setBackground( Color.WHITE ); count = 0; animator = new Thread( this ); animator.start(); } @Override public void run() { while( true ) { ++count;

TextRenderer.DrawText using GDI to render OTF Fonts?

谁都会走 提交于 2019-12-10 14:33:34
问题 I'm trying to draw text over a bitmap image and I've done some research and found that .NET/GDI+ doesn't support OTF fonts. I read somewhere that you could use TextRenderer.DrawText to render OTF fonts with GDI, but I can't seem to figure out how, nor does the quality compare to Graphics.DrawString in the least bit. First of all, is it possible to use OTF fonts at all in VS or did I read something incorrectly? Second, If the answer is TextRenderer.DrawText, how do I use the OTF fonts? It

Popping up a TextBox on mouse click over a PictureBox for adding custom note to picture

时光总嘲笑我的痴心妄想 提交于 2019-12-08 21:24:37
In my C# winforms application, I have a picturebox which some bitmap images can be loaded into it. What I want to do is if user clicks somewhere within picturebox, at the mouse location a small textbox will be appeared and user can add a custom text (note) to the picture. I know how to write a string into a bitmap file, but I couldnt find a way to POP UP a textbox at mouse location, and automaticly add the text to the image when user wrote something and hit enter key. How this textbox and its properties should be defined? Thanks. You could embed a control in a custom popup form, as shown below

The text is too bold by DrawString on C#

元气小坏坏 提交于 2019-12-07 13:11:37
问题 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. How to deal with this? public override void DrawTo(Graphics g, int x, int y, int flag) { if (flag == 1) { Pen dpen = new Pen(Color.FromArgb(128, 0, 0, 0), 1); dpen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; g.DrawRectangle(dpen, new

Disable word breaking when wrapping lines in .NET DrawString

左心房为你撑大大i 提交于 2019-12-07 12:19:37
问题 I am using .NET to draw a string into a limited space. I want the string to be as big as possible. I have no problem in the string breaking up into more lines (if it stays inside the rectangle). Now the problem: I don't want .NET to break the string in different lines in the middle of a word. For example string "Test" prints on a single line in a big font. String "Testing" should print on a single line in a smaller font (and not "Testi" on one line and "ng" on another) and string "Test Test"

The text is too bold by DrawString on C#

戏子无情 提交于 2019-12-05 22:37:26
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. How to deal with this? public override void DrawTo(Graphics g, int x, int y, int flag) { if (flag == 1) { Pen dpen = new Pen(Color.FromArgb(128, 0, 0, 0), 1); dpen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDot; g.DrawRectangle(dpen, new Rectangle(Bounds.X + x, Bounds.Y + y, Bounds.Width, Bounds.Height)); } if (!string.IsNullOrEmpty(Text)) {

Disable word breaking when wrapping lines in .NET DrawString

淺唱寂寞╮ 提交于 2019-12-05 19:59:35
I am using .NET to draw a string into a limited space. I want the string to be as big as possible. I have no problem in the string breaking up into more lines (if it stays inside the rectangle). Now the problem: I don't want .NET to break the string in different lines in the middle of a word. For example string "Test" prints on a single line in a big font. String "Testing" should print on a single line in a smaller font (and not "Testi" on one line and "ng" on another) and string "Test Test" should print on two lines in a fairly large font. Anybody got ideas on how to restrict .NET not to

How to position a python Reportlab table at position 10,100 and use drawString

≯℡__Kan透↙ 提交于 2019-12-05 07:06:07
问题 I am a python hobbyist and reportlab newbie. I know how to use drawString to put text at a particular place on a page, e.g.: c.drawString(10,100,"Welcome to Reportlab!") But I can't figure out how to place a table (which will only be a few lines long) so that the table begins at the same position as the c.drawString(10,100,"Welcome to Reportlab!"), which I will place elsewhere if I learn how to put my table there instead. I also can't figure out how to use drawString in the same script, since

Graphics.DrawString() vs TextRenderer.DrawText()

时光总嘲笑我的痴心妄想 提交于 2019-12-05 05:50:42
I am confused about these two methods. My understanding is that Graphics.DrawString() uses GDI+ and is a graphics-based implementation, while TextRenderer.DrawString() uses GDI and allows a large range of fonts and supports unicode. My issue is when I attempt to print decimal-based numbers as percentages to a printer. My research leads me to believe that TextRenderer is a better way to go. However, MSDN advises, "The DrawText methods of TextRenderer are not supported for printing. You should always use the DrawString methods of the Graphics class." My code to print using Graphics.DrawString is