Prev: IComparable
Next: Simple hack to get $1000 to your home
From: Tony Johansson on 16 Jun 2010 04:59 Hello! Here I have a piece of code where code marked with 1 and 2 give identical text but code marked with 3 doesn't give the same size of the text. Even if I change code marked with 3 from 12pt to 33pt the same size of text is displayed. Have I missed something here. private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = this.CreateGraphics(); // 1 Font f = new Font("Arial", 12, FontStyle.Bold); // 2 FontFamily ff = new FontFamily("Arial"); // 2 Font f = new Font(ff, 12, FontStyle.Bold); // 3 FontConverter converter = new FontConverter(); // 3 Font f = (Font)converter.ConvertFromString("Arial, 12pt, FontStyle.Bold"); g.DrawString("Hello, World!", f, Brushes.Blue, 10, 10); } //Tony
From: kndg on 16 Jun 2010 05:25 On 6/16/2010 4:59 PM, Tony Johansson wrote: > [...] > // 3 FontConverter converter = new FontConverter(); > // 3 Font f = (Font)converter.ConvertFromString("Arial, 12pt, > FontStyle.Bold"); You are using incorrect format for the converter to parse. It should be formatted as: Font f = (Font)converter.ConvertFromString("Arial, 12pt, style=Bold");
From: Tony Johansson on 16 Jun 2010 12:16 "kndg" <reply(a)this.newsgroup> skrev i meddelandet news:hva5h7$92s$1(a)news.eternal-september.org... > On 6/16/2010 4:59 PM, Tony Johansson wrote: >> [...] >> // 3 FontConverter converter = new FontConverter(); >> // 3 Font f = (Font)converter.ConvertFromString("Arial, 12pt, >> FontStyle.Bold"); > > You are using incorrect format for the converter to parse. It should be > formatted as: > > Font f = (Font)converter.ConvertFromString("Arial, 12pt, style=Bold"); No you example doesn't give correct font because it's very different from code marked with 1 and 2 //Tony
From: Jeff Johnson on 16 Jun 2010 15:17 "Tony Johansson" <johansson.andersson(a)telia.com> wrote in message news:%23Qa328WDLHA.1368(a)TK2MSFTNGP06.phx.gbl... >>> [...] >>> // 3 FontConverter converter = new FontConverter(); >>> // 3 Font f = (Font)converter.ConvertFromString("Arial, 12pt, >>> FontStyle.Bold"); >> >> You are using incorrect format for the converter to parse. It should be >> formatted as: >> >> Font f = (Font)converter.ConvertFromString("Arial, 12pt, style=Bold"); > > No you example doesn't give correct font because it's very different from > code marked with 1 and 2 Care to define "different"?
From: Tony Johansson on 16 Jun 2010 16:58
"Jeff Johnson" <i.get(a)enough.spam> skrev i meddelandet news:hvb80v$s2u$1(a)news.eternal-september.org... > "Tony Johansson" <johansson.andersson(a)telia.com> wrote in message > news:%23Qa328WDLHA.1368(a)TK2MSFTNGP06.phx.gbl... > >>>> [...] >>>> // 3 FontConverter converter = new FontConverter(); >>>> // 3 Font f = (Font)converter.ConvertFromString("Arial, 12pt, >>>> FontStyle.Bold"); >>> >>> You are using incorrect format for the converter to parse. It should be >>> formatted as: >>> >>> Font f = (Font)converter.ConvertFromString("Arial, 12pt, style=Bold"); >> >> No you example doesn't give correct font because it's very different from >> code marked with 1 and 2 > > Care to define "different"? At least different size of the text. //Tony |