unable to change the layer font

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

unable to change the layer font

krishna_s
Hello all, i am using php mapscript to label the layer on a map, i am able
to set it from the mapfile but when i do it from the php mapscript file it
doesnt change the font and the font size, heres how the php mapscript looks
like

$map = ms_newMapObj($map_path."states.map");

$layername = $map->getLayerByName("states");
$layername->set("labelitem","cty_county");
$class = $layername->getClass(0);
$style = ms_newStyleObj($class);
$style->backgroundcolor->setRGB(255,255,255);
$style->color->setRGB(100,220,220);
$style->outlinecolor->setRGB(100,0,0);

$class1 = ms_newClassObj($layername);
$class1->label->set("font","verdana");
$class1->label->set("size","tiny");

Even though i comment the font and size attributes in the mapfile, it shows
me the default output but not the changes that i want with the font and the
font size.

Any suggestions please ...

--kris
Reply | Threaded
Open this post in threaded view
|

Re: unable to change the layer font

Dylan Keon-3
On 1/24/06, krishna S <[hidden email]> wrote:

> Hello all, i am using php mapscript to label the layer on a map, i am able
> to set it from the mapfile but when i do it from the php mapscript file it
> doesnt change the font and the font size, heres how the php mapscript looks
> like
>
> $map = ms_newMapObj($map_path."states.map");
>
> $layername = $map->getLayerByName("states");
> $layername->set("labelitem","cty_county");
> $class = $layername->getClass(0);
> $style = ms_newStyleObj($class);
> $style->backgroundcolor->setRGB(255,255,255);
> $style->color->setRGB(100,220,220);
> $style->outlinecolor->setRGB(100,0,0);
>
> $class1 = ms_newClassObj($layername);
> $class1->label->set("font","verdana");
> $class1->label->set("size","tiny");
>
> Even though i comment the font and size attributes in the mapfile, it shows
> me the default output but not the changes that i want with the font and the
> font size.
>
> Any suggestions please ...
>
> --kris

LOL - I just replied to your other email.  If you want to use a
truetype font you need to do the following:

$class1->label->set(type, MS_TRUETYPE);
$class1->label->set(size, 8);

You must define the font type as truetype, and give it an integer size.

--Dylan
Reply | Threaded
Open this post in threaded view
|

Re: unable to change the layer font

krishna_s
In reply to this post by krishna_s
Thanks for your reply, i didnt see your other email ...

I tried with what ever you told but it doesnt change the output ...

ANy suggestions ...
Reply | Threaded
Open this post in threaded view
|

Re: unable to change the layer font

akrherz
In reply to this post by krishna_s
On Tue, 24 Jan 2006, krishna S wrote:

> Hello all, i am using php mapscript to label the layer on a map, i am
> able to set it from the mapfile but when i do it from the php mapscript
> file it doesnt change the font and the font size, heres how the php
> mapscript looks like
>
> $map = ms_newMapObj($map_path."states.map");
>
> $layername = $map->getLayerByName("states");
> $layername->set("labelitem","cty_county");
> $class = $layername->getClass(0);
> $style = ms_newStyleObj($class);
> $style->backgroundcolor->setRGB(255,255,255);
> $style->color->setRGB(100,220,220);
> $style->outlinecolor->setRGB(100,0,0);
>
> $class1 = ms_newClassObj($layername);
> $class1->label->set("font","verdana");
> $class1->label->set("size","tiny");

I am not sure what else may be wrong, but you need to use MS_TINY

http://mapserver.gis.umn.edu/docs/reference/mapscript/index_html#label-size-bitmap-only

  $class1->label->set("size", MS_TINY);

the string 'tiny' is not sufficient, IIRC.

daryl

--
/**
  * Daryl Herzmann ([hidden email])
  * Program Assistant -- Iowa Environmental Mesonet
  * http://mesonet.agron.iastate.edu
  */
Reply | Threaded
Open this post in threaded view
|

Re: unable to change the layer font

krishna_s
In reply to this post by krishna_s
Thanks for your reply daryl, i have one more question too, i want to set
the font size in integer values and not really in tiny or medium terms, so
i guess we need to use the MS_TRUETYPE right, for that i set the fontset
but when i give any font it gives an error, here is the code snippet

$map_path="C:\Apache2\htdocs\mapserverdata\map_files\\";
$fontset = "C:\projects\mapserver-4.6.2\fonts\fonts.list";
$map = ms_newMapObj($map_path."states.map");
$map->setFontSet($fontset);

$class->label->set(type, MS_TRUETYPE);
$class->label->set(font, 'arial');
$class->label->set(size, 6);
 it gives me the following error

Warning: [MapServer Error]: msGetLabelSize(): Could not find/open font,
i am not sure where i am wrong ...

Thanks for your time ....
--kris
Reply | Threaded
Open this post in threaded view
|

Re: unable to change the layer font

Dylan Keon-3
On 01/24/2006 03:48 PM, krishna S wrote:

> Thanks for your reply daryl, i have one more question too, i want to set
> the font size in integer values and not really in tiny or medium terms, so
> i guess we need to use the MS_TRUETYPE right, for that i set the fontset
> but when i give any font it gives an error, here is the code snippet
>
> $map_path="C:\Apache2\htdocs\mapserverdata\map_files\\";
> $fontset = "C:\projects\mapserver-4.6.2\fonts\fonts.list";
> $map = ms_newMapObj($map_path."states.map");
> $map->setFontSet($fontset);
>
> $class->label->set(type, MS_TRUETYPE);
> $class->label->set(font, 'arial');
> $class->label->set(size, 6);
>  it gives me the following error
>
> Warning: [MapServer Error]: msGetLabelSize(): Could not find/open font,
> i am not sure where i am wrong ...
>
> Thanks for your time ....
> --kris

Kris,

Do you have a font named "arial" defined in
C:\projects\mapserver-4.6.2\fonts\fonts.list?  What does that line look
like?

--Dylan
Reply | Threaded
Open this post in threaded view
|

Re: unable to change the layer font

krishna_s
In reply to this post by krishna_s
yeah i have a font named arial in the fonts.list file,

arial       arial.ttf

i have even changed it to

arial       "C:\WINNT\Fonts\arial.ttf"

but no luck, i have searched about this error in the mapserver forums and
everyone says its because of the not giving the full path which i specified
in my mapscript file ....

Thanks for your time .....
Reply | Threaded
Open this post in threaded view
|

Re: unable to change the layer font

Stephen Woodbridge
krishna S wrote:
> yeah i have a font named arial in the fonts.list file,
>
> arial       arial.ttf
>
> i have even changed it to
>
> arial       "C:\WINNT\Fonts\arial.ttf"

try:

arial    c:/WINNT/Fonts/arial.ttf

>
> but no luck, i have searched about this error in the mapserver forums and
> everyone says its because of the not giving the full path which i specified
> in my mapscript file ....
>
> Thanks for your time .....
>
Reply | Threaded
Open this post in threaded view
|

Re: unable to change the layer font {Scanned}

Siki Zoltan
In reply to this post by krishna_s
Hi Krishna,

Try to change \ to / e.g. C:/WINNT/Fonts/arial.ttf

Zoltan

On Tue, 24 Jan 2006, krishna S wrote:

> yeah i have a font named arial in the fonts.list file,
>
> arial       arial.ttf
>
> i have even changed it to
>
> arial       "C:\WINNT\Fonts\arial.ttf"
>
> but no luck, i have searched about this error in the mapserver forums and
> everyone says its because of the not giving the full path which i specified
> in my mapscript file ....
>
> Thanks for your time .....
>
Reply | Threaded
Open this post in threaded view
|

Re: unable to change the layer font

krishna_s
In reply to this post by krishna_s
Thanks for your reply guys, i removed the quotes and it worked ......

Thanks again

--kris