473,569 Members | 2,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a new font via tranformation

k
Hi,

I'm trying to migrate from Java to C# and have encountered a problem.

I can't seem to find a way to create (ultra)condense d fonts for later
use in a program. In Java I had a really nice method
some_font.deriv eFont(AffineTra nsform), which would return a new font.
(AffineTransfor m was just a simple 3x3 matrix)

I'll be most grateful for the help.

Regards,
Karol

Nov 2 '06 #1
3 3315
This method doesn't exist for .NET fonts. You can create a font with a
specific point size but these may be grid-fitted so the quality will go down
pretty quickly below 8 points.

If you want to draw really tiny fonts with the benefit of some antialiasing
you can use a matrix to shange the drawing scale but you will need to treat
fonts and drawing objects differently.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"k" <va***@wp.plwro te in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Hi,

I'm trying to migrate from Java to C# and have encountered a problem.

I can't seem to find a way to create (ultra)condense d fonts for later
use in a program. In Java I had a really nice method
some_font.deriv eFont(AffineTra nsform), which would return a new font.
(AffineTransfor m was just a simple 3x3 matrix)

I'll be most grateful for the help.

Regards,
Karol

Nov 2 '06 #2
k
Thank you for your fast response.

A word of explanation: I don't need to use tiny fonts but very narrow
ones (e.g. Courier new 12, with 40% of the original width) for printing
reports.

I'm now trying to transform the Graphics object. It works, but the
quality is very poor. Here is a sample code:

private void printDocument1_ PrintPage(objec t sender,
System.Drawing. Printing.PrintP ageEventArgs e)
{
Font fo = new Font("Courier new", 12, FontStyle.Regul ar););
SolidBrush br = new SolidBrush(Colo r.Black);
e.Graphics.Scal eTransform(0.4f , 1f);
e.Graphics.Draw String("N", fo, br, 30, 30);
e.HasMorePages = false;
}

The difference in quality of a print with and without the
transformation is very noticeable - I can provide samples if
required.

I've tried
e.Graphics.Text RenderingHint = TextRenderingHi nt.ClearTypeGri dFit;
before drawing the string but without visible results.

Regards,
Karol

Bob Powell [MVP] napisal(a):
This method doesn't exist for .NET fonts. You can create a font with a
specific point size but these may be grid-fitted so the quality will go down
pretty quickly below 8 points.

If you want to draw really tiny fonts with the benefit of some antialiasing
you can use a matrix to shange the drawing scale but you will need to treat
fonts and drawing objects differently.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"k" <va***@wp.plwro te in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
Hi,

I'm trying to migrate from Java to C# and have encountered a problem.

I can't seem to find a way to create (ultra)condense d fonts for later
use in a program. In Java I had a really nice method
some_font.deriv eFont(AffineTra nsform), which would return a new font.
(AffineTransfor m was just a simple 3x3 matrix)

I'll be most grateful for the help.

Regards,
Karol
Nov 2 '06 #3
The trouble is, in a case such as this, that the fonts are constructed
at 100% size yet the placement of the pixels in the font is affected by
the transform.

The use of the cleartype antialiasing method will work on the local font
data but the pixels will be displaced according to the transform and so
will look as horrible as before.

The only thing I can suggest is that low-level construction of the font
via interop and the use of a logfont may give you the control you seek
but it won't include cleartype so you'll be stuck with the lower quality
aliased glyphs.

In other words, no net gain.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

k wrote:
Thank you for your fast response.

A word of explanation: I don't need to use tiny fonts but very narrow
ones (e.g. Courier new 12, with 40% of the original width) for printing
reports.

I'm now trying to transform the Graphics object. It works, but the
quality is very poor. Here is a sample code:

private void printDocument1_ PrintPage(objec t sender,
System.Drawing. Printing.PrintP ageEventArgs e)
{
Font fo = new Font("Courier new", 12, FontStyle.Regul ar););
SolidBrush br = new SolidBrush(Colo r.Black);
e.Graphics.Scal eTransform(0.4f , 1f);
e.Graphics.Draw String("N", fo, br, 30, 30);
e.HasMorePages = false;
}

The difference in quality of a print with and without the
transformation is very noticeable - I can provide samples if
required.

I've tried
e.Graphics.Text RenderingHint = TextRenderingHi nt.ClearTypeGri dFit;
before drawing the string but without visible results.

Regards,
Karol

Bob Powell [MVP] napisal(a):
>This method doesn't exist for .NET fonts. You can create a font with a
specific point size but these may be grid-fitted so the quality will go down
pretty quickly below 8 points.

If you want to draw really tiny fonts with the benefit of some antialiasing
you can use a matrix to shange the drawing scale but you will need to treat
fonts and drawing objects differently.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"k" <va***@wp.plwro te in message
news:11******* *************** @b28g2000cwb.go oglegroups.com. ..
>>Hi,

I'm trying to migrate from Java to C# and have encountered a problem.

I can't seem to find a way to create (ultra)condense d fonts for later
use in a program. In Java I had a really nice method
some_font.der iveFont(AffineT ransform), which would return a new font.
(AffineTransf orm was just a simple 3x3 matrix)

I'll be most grateful for the help.

Regards,
Karol
Jan 31 '07 #4

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

Similar topics

4
2958
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text email by creating a text file, with content following certain format, and saving that file into the correct '..\mailroot\pickup' folder, and it is...
1
1257
by: Tomislav Jakopec | last post by:
Hi to all! I have one (or more) problem. I set up a system to provide web access to legacy application. Legacy application run at RISC mashine, web server is tomcat an linux. Response time is very bad (1000 - 3000 ms). First, I think it is RISC fault, but after few test I found out that RISC time (invoke method) id app. 300 ms and...
12
4157
by: enak | last post by:
I have found some code that shows how to convert an html form to Word. The message said to simply put the following in the Page_load: Response.ContentType = "application/ms-word" Response.AddHeader("content-disposition", "inline; filename=BP_CaseStatus.doc") Now all I should have to do is create the page just like I would if I were...
2
1254
by: Zyrthofar Blackcloak | last post by:
Hello everyone! I just wanted to know how I can create a font from bitmaps in memory (currently in an array), or from GDI+. I want to be able to use that font in a textbox, for example. I have searched a bit on msdn and google, but didn't find anything useful. A hint or a link would be appreciated :) Thank you all
4
2739
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. It should put a blue and yellow box on the page with "This is a test" as part of the picture. But what I get is a broken Gif. The other problem is...
11
2412
by: Michael7 | last post by:
Hi everyone, Me again, been a while since I've been here, but I'm back again needing help with a simple thing. I've searched for help on creating a footer, but all the help I've found, was absolutely nothing like what I was looking for. Could anyone help me with the very simple issue of creating a footer? I'm trying to create it on...
2
20134
by: uamusa | last post by:
I am Dynamically generating a proposal(report) in MS Word. By default the Paragraph Alignment is "Left". For the First 6 Paragraphs I set the Alignment to "Center", and then when attempting to switch back to "Left" aligned for remaining paragraphs, the text within the Word document remained Centered. I'm using: VS2008 w/ .NET Framework 3.5,...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.