473,387 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

text border

Hi,

I am trying to apply text border to some text I am drawing.
I obtained some code from Bob Powells GDI+ FAQ but it seems that the text
border is draw from outside inwards, that is the letter thickness decreases.
What I need is for the border to be drawn from outside outwards, so the
letter thickness stays the same but the border is drawn on the outside.

Also I have problem when drawing against a white or light coloured
background whereby the text border is not drawn very well and looks messy.

Code:

backBuffer=new Bitmap(this.ClientSize.Width,this.ClientSize.Heigh t);
Graphics g = Graphics.FromImage(backBuffer);
// back rectangle
Rectangle backRectangle = new Rectangle(0, 0, panel1.Width, panel1.Height);
SolidBrush backBrush = new SolidBrush(Color.WhiteSmoke);
// Create background fill
g.FillRectangle(backBrush,backRectangle);
// Create the actual graphics path that is going to be used
GraphicsPath path = new GraphicsPath();
Pen penBorder = new Pen(Color.Black, borderSize);
path.AddString("Test Text",
new FontFamily("Tw Cen MT"), (int)System.Drawing.FontStyle.Regular, textSize
+ borderSize,
new Point(x, y), StringFormat.GenericTypographic);
// Get the bounds so we can inflate it and draw the background rectangle
RectangleF rect = path.GetBounds();
rect.Inflate(2.0f, 2.0f);
// Draw the background rectangle
g.FillRectangle(brush, rect);
// Draw the text using the graphics path
g.FillPath(new SolidBrush(Color.White), path);
g.DrawPath(penBorder, path);
g.Dispose();
// Copy the back buffer to the screen
e.Graphics.DrawImageUnscaled(backBuffer, 0, 0);
Mar 12 '07 #1
0 1310

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Lui Ali | last post by:
Hello, Problem: I want to get the whole text between the opening tag <%OPTIONAL%> and the closing tag <%/OPTIONAL%>. The right block is found by (and contains) the placeholder...
6
by: no0bodyhome | last post by:
One of the properties I have is: border-top-width: 30px I'd like to put some text on this border; align it and such. It is part of more complicated floating column text-box I'm working on...
4
by: anatushi | last post by:
Hi, im looking for help on how to add a text fader to my website, usually i'm working with css but in this case i need to add java script to make it work, that wasn't the problem but somehow it...
1
by: IkBenHet | last post by:
Hello, I found this script to create a simple rich text form (http://programmabilities.com/xml/index.php?id=17): <html> <head> <title>Rich Text Editor</title> </head> <body>
1
by: Basso | last post by:
Hello, I'd like to add a progressive number to upper-left corner on every TH element avoiding cell text reposition. // TH props table.quadroData th { text-align: center; background-color:...
5
by: simon_s_li | last post by:
Hi, I have 5 fields in line where I need to drag and drop the text from one field to another field and then all the fields need to re-order themselves. So for instance if I drag the text in...
2
by: george.leithead | last post by:
Hi all, I have a very strange problem! In following Web page (which is generated from a CMS System), the navigation to the left 'dissapears' when you roll the mouse over the links? It does not...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
3
by: happyse27 | last post by:
Hi All, I wanted to align the text box for user registration but the code just wont budge... Kindly advise what is wrong? Cheers... Andrew <HTML>
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.