473,386 Members | 1,699 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,386 software developers and data experts.

Scale fonts

Hi,
anyone knows if a Font can be scaled only in one dimension (width or height).
The result would be a Font that would have the same height and double wide,
for
example.
Thanks
May 28 '07 #1
1 2477
On Mon, 28 May 2007 03:51:02 -0700, iklarri
<ik*****@discussions.microsoft.comwrote:
anyone knows if a Font can be scaled only in one dimension (width or
height).
The result would be a Font that would have the same height and double
wide,
for example.
I'm not aware of any way to do this directly from a Font. But you can
create a temporary bitmap to which to draw, and set the transform for the
Graphics obtained from that bitmap to do the scaling for you. For example:

void DrawScaledString(Graphics gfx, string str, Font font, Brush
brush, PointF ptf, float scaleX, float scaleY)
{
SizeF szf = gfx.MeasureString(str, font);
Bitmap bmp = new Bitmap((int)Math.Ceiling(szf.Width * scaleX),
(int)Math.Ceiling(szf.Height * scaleY), gfx);

using (Graphics gfxT = Graphics.FromImage(bmp))
{
gfxT.Transform = new
System.Drawing.Drawing2D.Matrix(scaleX, 0, 0, scaleY, 0, 0);
gfxT.DrawString(str, font, brush, new PointF());
}

gfx.DrawImage(bmp, ptf);
}

Hope that helps.

Pete
May 28 '07 #2

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

Similar topics

3
by: News Central | last post by:
I resize a control in a Form wth Scale mode set to vbInches. However, the control's size changes in different screen resolution, I thought that if Scale mode is set to vbInchs, then the control...
48
by: Bulba! | last post by:
I'll soon start development of a specialized small app and need to choose GUI for it. I have narrowed the choice to wxPython/PythonCard and QT/PyQT (buying commercial licenses is not a big...
1
by: Jack Charbonneau | last post by:
I have a bunch of custom fonts installed on my system. For instance if I look at the font drop-down in word pad I see about 90 fonts, but if I build an app using VS.Net, add a label, and try to...
11
by: Curious Angel | last post by:
Hi, I have a version of my resume that is (almost) web ready and I'm pleased with its appearance on the screen (well, sort of heh heh, it's my first HTML). I also created a tighter, scaled-down...
0
by: LaidBack Bill | last post by:
My application allows the user to select fonts. I fill in a combo box control with the available fonts by looping through all System.Fonts: ' Get all the screen fonts ReDim...
4
by: L | last post by:
Hi there, Does C# support OpenType fonts? My c# application is not recognizing OpenType fonts. Thanks, Lalasa.
4
by: Aaron Gray | last post by:
Is there anyway to get a list of all the availiable fonts in Javascript ? Aaron
2
by: Luc | last post by:
I saw a few posts on this newsgroup about it but nothing to help me resolve this problem: We designed a window in .NET on a platform using small fonts (120 ppp). But this window will run on...
12
by: ctclibby | last post by:
Hi all Have a customer that wants a specific font included in her web page design; Comic Sans MS. This is one of the MS core fonts. The problem I have is that some of the *nix browsers do NOT...
2
by: AliR \(VC++ MVP\) | last post by:
I'm trying to write a RTF render code in C#. I have the code in C++/MFC and it works fine, but I have run into a problem with the C# code. I think the C# code is from Microsoft, and I added...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.