Lazarus

Programming => Graphics and Multimedia => Graphics => Topic started by: K.Bleijenberg on January 17, 2014, 11:23:44 am

Title: vertical text, characters too close to each other
Post by: K.Bleijenberg on January 17, 2014, 11:23:44 am
I'am using aggpas to draw a png in a command line tool (no dependency's on GDI or X11). I need to draw vertical text. In code I do:
agg^.font(fontFilePath,fontSize ,false,false,vectorFontCache,deg2rad(90));
agg is an instance of TAgg2D and fontfilepath is '/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf'
The output is not what I want. The characters are too close to each other (see attachment).
The size of the horizontal font is equal to the vertical font.
What can I do stretch the string?

Kees



Title: Re: vertical text, characters too close to each other
Post by: engkin on January 17, 2014, 04:06:18 pm
Quote
The size of the horizontal font is equal to the vertical font.
Are you sure? They don't seem so, check the attached image.
Title: Re: vertical text, characters too close to each other
Post by: K.Bleijenberg on January 19, 2014, 12:03:38 pm
Quote
The size of the horizontal font is equal to the vertical font.
Are you sure? They don't seem so, check the attached image.

Yes I' am sure.
I've investigated it further and more strange things happen:

I tried this
      with agg^ do
      begin
         fillColor(255,255,255);
         rectangle(0,imageHeight-1,imageWidth-1,0);
         fillColor(0,0,0);
         lineColor(0,0,0);
         font(fontFilePath,30,false,false,VectorFontCache);
         text(10,10,char_ptr('Blah'));
         font(fontFilePath,30,true,true,VectorFontCache);
         text(100,100,char_ptr('Blah'));
The first and second Blah look exactly the same. To me they are both bold and the second blah is definitely not italic.
if I run
        font(fontFilePath,30);
         text(10,10,char_ptr('Blah'));
         font(fontFilePath,30,true,true);
         text(100,100,'Blah');
Both blah's seems not bold and  not italic.


 
Title: Re: vertical text, characters too close to each other
Post by: engkin on January 19, 2014, 04:50:59 pm
Your problem is with the lineColor(0,0,0);. The default value is 255 for the alpha channel. Just change it to 0:
Code: [Select]
  lineColor(0,0,0,0);

Check the attached images. Both show increasing alpha values for the green line color. The first one has 255 for the alpha value of the red fill color, while the second image has 0 for the alpha value of the fill color. A letter B in the sample text denotes bold font, and a letter I for italic font.
Title: Re: vertical text, characters too close to each other
Post by: K.Bleijenberg on January 20, 2014, 05:51:03 pm
Your problem is with the lineColor(0,0,0);. The default value is 255 for the alpha channel. Just change it to 0:
Code: [Select]
  lineColor(0,0,0,0);

Check the attached images. Both show increasing alpha values for the green line color. The first one has 255 for the alpha value of the red fill color, while the second image has 0 for the alpha value of the fill color. A letter B in the sample text denotes bold font, and a letter I for italic font.

The linecolor was indeed the problem. The overlapping characters came from too much line width. Sometimes the problem was obscured by a wrong alpha value.
Thanks!

Kees
 
Title: Re: vertical text, characters too close to each other
Post by: Graeme on August 06, 2014, 08:13:50 am
I know this is an old post, but I thought posting the correct answer might help others in future.

      with agg^ do
      begin
         fillColor(255,255,255);
         rectangle(0,imageHeight-1,imageWidth-1,0);
         fillColor(0,0,0);
         lineColor(0,0,0);
         font(fontFilePath,30,false,false,VectorFontCache);
         text(10,10,char_ptr('Blah'));
...snip...

The first and second Blah look exactly the same. To me they are both bold...

Remember that AggPas is a vector based drawing library - so too for fonts. So drawing effects can be applied to fonts too - in this case drawing with an outline color. In the above code you are defining a text outline as well as a text fill color. So that is what makes the Bold and "fatter" effect. Maybe what you are looking for is just the text fill, without outlining the text.

eg:
Code: [Select]
    agg.FillColor(c1);
    agg.NoLine;  // don't outline the text
    agg.text(10,10,char_ptr('Blah'));

This will give you thinner text output.
TinyPortal © 2005-2018