[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Tom Jones

12/2/2004 11:21:00 PM

Hello,

I have searched high and low and now Im here. I am trying to get the exact
width of a character. I am using DrawString to draw characters next to each
other. And the issue is that MeasureString leaves space between the
character and the bounding rectangle.

I need a way to get the exact width of a character. Any help would be
appreciated...I have tried using AntiAliasGridFit and GenericTypographic.


5 Answers

Bob Powell

12/3/2004 12:03:00 AM

0

Use MeasureCharacterRanges

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

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

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

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





"Tom Jones" <csharpcoder2004@hotmail.com> wrote in message
news:epNK$VM2EHA.3500@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I have searched high and low and now Im here. I am trying to get the exact
> width of a character. I am using DrawString to draw characters next to
each
> other. And the issue is that MeasureString leaves space between the
> character and the bounding rectangle.
>
> I need a way to get the exact width of a character. Any help would be
> appreciated...I have tried using AntiAliasGridFit and GenericTypographic.
>
>


Tom Jones

12/3/2004 3:55:00 PM

0

Im replying to myself here. I figured out the problem...Thanks for pointing
me in the right direction Bob.

I had to set the string format to the following.
stringFormat = StringFormat.GenericTypographic;

stringFormat.FormatFlags =StringFormatFlags.FitBlackBox;



"Tom Jones" <csharpcoder2004@hotmail.com> wrote in message
news:uTswhjU2EHA.3820@TK2MSFTNGP11.phx.gbl...
> Bob,
>
> I tested out that idea yesterday and there is still space. Here is code
and
> a screenshot to show you what I mean. Thanks.
>
>
e.Graphics.TextRenderingHint=System.Drawing.Text.TextRenderingHint.AntiAlias
> GridFit ;
>
>
> string measureString = "h";
>
> CharacterRange[] characterRanges ={new CharacterRange(0, 1), };
>
> RectangleF layoutRect = new RectangleF(0.0F, 0.0F, 100000.0F, 100000.0F);
>
> StringFormat stringFormat = new StringFormat();
>
> stringFormat = StringFormat.GenericTypographic;
>
> stringFormat.SetMeasurableCharacterRanges(characterRanges);
>
> Region[] stringRegions = new Region[1];
>
> stringRegions = e.Graphics.MeasureCharacterRanges(measureString,
this.Font,
> layoutRect, stringFormat);
>
> RectangleF measureRect = stringRegions[0].GetBounds(e.Graphics);
>
> float Offset = measureRect.X;
>
> float Width = measureRect.Width;
>
> RectangleF rec=new RectangleF(10,10,Width,20);
>
> e.Graphics.DrawRectangle(Pens.Red,rec.X,rec.Y,rec.Width,rec.Height);
>
> e.Graphics.DrawString("h",this.Font,Brushes.Blue,rec);
>
> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> news:Oiil%23tM2EHA.3452@TK2MSFTNGP14.phx.gbl...
>
> > Use MeasureCharacterRanges
> >
> > --
> > Bob Powell [MVP]
> > Visual C#, System.Drawing
> >
> > Find great Windows Forms articles in Windows Forms Tips and Tricks
> > http://www.bobpowell.net/tips...
> >
> > Answer those GDI+ questions with the GDI+ FAQ
> > http://www.bobpowell.net/f...
> >
> > All new articles provide code in C# and VB.NET.
> > Subscribe to the RSS feeds provided and never miss a new article.
> >
> >
> >
> >
> >
> > "Tom Jones" <csharpcoder2004@hotmail.com> wrote in message
> > news:epNK$VM2EHA.3500@TK2MSFTNGP09.phx.gbl...
> > > Hello,
> > >
> > > I have searched high and low and now Im here. I am trying to get the
> exact
> > > width of a character. I am using DrawString to draw characters next to
> > each
> > > other. And the issue is that MeasureString leaves space between the
> > > character and the bounding rectangle.
> > >
> > > I need a way to get the exact width of a character. Any help would be
> > > appreciated...I have tried using AntiAliasGridFit and
> GenericTypographic.
> > >
> > >
> >
> >
>
>
>


Bob Powell

12/3/2004 4:39:00 PM

0

Remember that you must clone the GenericTypographic StringFormat object
otherwise any changes you make to it will remain for the next time you get
the GenericTypographic format. This can lead to confusion when it doesn't
behave like you think the "static" property should.

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

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

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

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





"Tom Jones" <csharpcoder2004@hotmail.com> wrote in message
news:eq84dBV2EHA.1188@tk2msftngp13.phx.gbl...
> Im replying to myself here. I figured out the problem...Thanks for
pointing
> me in the right direction Bob.
>
> I had to set the string format to the following.
> stringFormat = StringFormat.GenericTypographic;
>
> stringFormat.FormatFlags =StringFormatFlags.FitBlackBox;
>
>
>
> "Tom Jones" <csharpcoder2004@hotmail.com> wrote in message
> news:uTswhjU2EHA.3820@TK2MSFTNGP11.phx.gbl...
> > Bob,
> >
> > I tested out that idea yesterday and there is still space. Here is code
> and
> > a screenshot to show you what I mean. Thanks.
> >
> >
>
e.Graphics.TextRenderingHint=System.Drawing.Text.TextRenderingHint.AntiAlias
> > GridFit ;
> >
> >
> > string measureString = "h";
> >
> > CharacterRange[] characterRanges ={new CharacterRange(0, 1), };
> >
> > RectangleF layoutRect = new RectangleF(0.0F, 0.0F, 100000.0F,
100000.0F);
> >
> > StringFormat stringFormat = new StringFormat();
> >
> > stringFormat = StringFormat.GenericTypographic;
> >
> > stringFormat.SetMeasurableCharacterRanges(characterRanges);
> >
> > Region[] stringRegions = new Region[1];
> >
> > stringRegions = e.Graphics.MeasureCharacterRanges(measureString,
> this.Font,
> > layoutRect, stringFormat);
> >
> > RectangleF measureRect = stringRegions[0].GetBounds(e.Graphics);
> >
> > float Offset = measureRect.X;
> >
> > float Width = measureRect.Width;
> >
> > RectangleF rec=new RectangleF(10,10,Width,20);
> >
> > e.Graphics.DrawRectangle(Pens.Red,rec.X,rec.Y,rec.Width,rec.Height);
> >
> > e.Graphics.DrawString("h",this.Font,Brushes.Blue,rec);
> >
> > "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> > news:Oiil%23tM2EHA.3452@TK2MSFTNGP14.phx.gbl...
> >
> > > Use MeasureCharacterRanges
> > >
> > > --
> > > Bob Powell [MVP]
> > > Visual C#, System.Drawing
> > >
> > > Find great Windows Forms articles in Windows Forms Tips and Tricks
> > > http://www.bobpowell.net/tips...
> > >
> > > Answer those GDI+ questions with the GDI+ FAQ
> > > http://www.bobpowell.net/f...
> > >
> > > All new articles provide code in C# and VB.NET.
> > > Subscribe to the RSS feeds provided and never miss a new article.
> > >
> > >
> > >
> > >
> > >
> > > "Tom Jones" <csharpcoder2004@hotmail.com> wrote in message
> > > news:epNK$VM2EHA.3500@TK2MSFTNGP09.phx.gbl...
> > > > Hello,
> > > >
> > > > I have searched high and low and now Im here. I am trying to get the
> > exact
> > > > width of a character. I am using DrawString to draw characters next
to
> > > each
> > > > other. And the issue is that MeasureString leaves space between the
> > > > character and the bounding rectangle.
> > > >
> > > > I need a way to get the exact width of a character. Any help would
be
> > > > appreciated...I have tried using AntiAliasGridFit and
> > GenericTypographic.
> > > >
> > > >
> > >
> > >
> >
> >
> >
>
>


odonivin, PeeJay

7/25/2011 3:29:00 PM

0

On Jul 25, 8:31 am, GLOBALIST <free.tun...@gmail.com> wrote:
> On Jul 25, 7:14 am, "odonivin, PeeJay" <v203...@activist.com> wrote:
>
>
>
> > Terrorist proclaimed himself 'Darwinian,' not 'Christian' Norwegian's
> > manifesto shows Breivik not religious, having no personal faith
>
> > July 24, 2011
> > 7:09 pm Eastern
>
> > "...Piecing together Breivik's various posts on the Internet, many
> > media reports have characterized the terrorist – who says he was upset
> > over the multiculturalist policies stemming from Norway's Labour Party
> > – as a "right-wing, Christian fundamentalist."
>
> > Yet, while McVeigh rejected God altogether, Breivik writes in his
> > manifesto that he is not religious, has doubts about God's existence,
> > does not pray, but does assert the primacy of Europe's "Christian
> > culture" as well as his own pagan Nordic culture.
>
> > Breivik instead hails Charles Darwin, whose evolutionary theories
> > stand in contrast to the claims of the Bible, and affirms: "As for the
> > Church and science, it is essential that science takes an undisputed
> > precedence over biblical teachings. Europe has always been the cradle
> > of science, and it must always continue to be that way. Regarding my
> > personal relationship with God, I guess I'm not an excessively
> > religious man. I am first and foremost a man of logic. However, I am a
> > supporter of a monocultural Christian Europe."...."
>
> In other words: His thinking was that of Hitler's: protect the
> superior race-blond, blue-eyed Aryans, based on a strange concept of
> the Nordic religion, which they presumed to know.
There are similarities. Hitler and his Nazi movement was the result of
an extreme reaction against the perceived threat from International
Sociialism (Communism) which was blamed on the Jews.

"Hitler opposed both domestic and international socialism (USSR); he
also condemned Jews for being responsible..."

"Journal of Historical Review
The Jewish Role in the Bolshevik Revolution and Russia's Early Soviet
Regime
Assessing the Grim Legacy of Soviet Communism...

....How did the Bolsheviks, a small movement guided by the teachings of
German-Jewish social philosopher Karl Marx, succeed in taking control
of Russia and imposing a cruel and despotic regime on its people?..

....A Taboo Subject

Although officially Jews have never made up more than five percent of
the country's total population, they played a highly disproportionate
and probably decisive role in the infant Bolshevik regime, effectively
dominating the Soviet government during its early years
.
...With the notable exception of Lenin (Vladimir Ulyanov), most of the
leading Communists who took control of Russia in 1917-20 were Jews.
Leon Trotsky (Lev Bronstein) headed the Red Army and, for a time, was
chief of Soviet foreign affairs. Yakov Sverdlov (Solomon) was both the
Bolshevik party's executive secretary and -- as chairman of the
Central Executive Committee -- head of the Soviet government. Grigori
Zinoviev (Radomyslsky) headed the Communist International (Comintern),
the central agency for spreading revolution in foreign countries.
Other prominent Jews included press commissar Karl Radek (Sobelsohn),
foreign affairs commissar Maxim Litvinov (Wallach), Lev Kamenev
(Rosenfeld) and Moisei Uritsky.."


"Italian fascism and German Nazism reject liberalism, democracy and
Marxism.[65]..."

If you want to read more just google part of any of 'em between the
quotes and add your own quote marks and you should come up with
multiple sources.

odonivin, PeeJay

7/25/2011 3:39:00 PM

0

On Jul 25, 8:31 am, GLOBALIST <free.tun...@gmail.com> wrote:
> On Jul 25, 7:14 am, "odonivin, PeeJay" <v203...@activist.com> wrote:
>
>
>
> > Terrorist proclaimed himself 'Darwinian,' not 'Christian' Norwegian's
> > manifesto shows Breivik not religious, having no personal faith
>
> > July 24, 2011
> > 7:09 pm Eastern
>
> > "...Piecing together Breivik's various posts on the Internet, many
> > media reports have characterized the terrorist – who says he was upset
> > over the multiculturalist policies stemming from Norway's Labour Party
> > – as a "right-wing, Christian fundamentalist."
>
> > Yet, while McVeigh rejected God altogether, Breivik writes in his
> > manifesto that he is not religious, has doubts about God's existence,
> > does not pray, but does assert the primacy of Europe's "Christian
> > culture" as well as his own pagan Nordic culture.
>
> > Breivik instead hails Charles Darwin, whose evolutionary theories
> > stand in contrast to the claims of the Bible, and affirms: "As for the
> > Church and science, it is essential that science takes an undisputed
> > precedence over biblical teachings. Europe has always been the cradle
> > of science, and it must always continue to be that way. Regarding my
> > personal relationship with God, I guess I'm not an excessively
> > religious man. I am first and foremost a man of logic. However, I am a
> > supporter of a monocultural Christian Europe."...."
>
> In other words: His thinking was that of Hitler's: protect the
> superior race-blond, blue-eyed Aryans, based on a strange concept of
> the Nordic religion, which they presumed to know.

There are similarities. Hitler and his Nazi movement was the result of
an extreme reaction against the perceived threat from International
Sociialism (Communism) which was blamed on the Jews.

"Hitler opposed both domestic and international socialism (USSR); he
also condemned Jews for being responsible..."

"Journal of Historical Review
The Jewish Role in the Bolshevik Revolution and Russia's Early Soviet
Regime
Assessing the Grim Legacy of Soviet Communism...

....How did the Bolsheviks, a small movement guided by the teachings of
German-Jewish social philosopher Karl Marx, succeed in taking control
of Russia and imposing a cruel and despotic regime on its people?..

....A Taboo Subject

Although officially Jews have never made up more than five percent of
the country's total population, they played a highly disproportionate
and probably decisive role in the infant Bolshevik regime, effectively
dominating the Soviet government during its early years
.
...With the notable exception of Lenin (Vladimir Ulyanov), most of the
leading Communists who took control of Russia in 1917-20 were Jews.
Leon Trotsky (Lev Bronstein) headed the Red Army and, for a time, was
chief of Soviet foreign affairs. Yakov Sverdlov (Solomon) was both the
Bolshevik party's executive secretary and -- as chairman of the
Central Executive Committee -- head of the Soviet government. Grigori
Zinoviev (Radomyslsky) headed the Communist International (Comintern),
the central agency for spreading revolution in foreign countries.
Other prominent Jews included press commissar Karl Radek (Sobelsohn),
foreign affairs commissar Maxim Litvinov (Wallach), Lev Kamenev
(Rosenfeld) and Moisei Uritsky.."


"Italian fascism and German Nazism reject liberalism, democracy and
Marxism.[65]..."

If you want to read more just google part of any of 'em between the
quotes and add your own quote marks and you should come up with
multiple sources.