Ticket #3379 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

Crash on using bitmap font and autofollow with mapscript C#

Reported by: getiem Owned by: tamas
Priority: normal Milestone: 6.0 release
Component: MapScript-C# Version: svn-trunk (development)
Severity: normal Keywords:
Cc:

Description

I'm running into problems with my mapscript C#. I had truetype fonts, but due to some restrictions I can't use them on the system anymore, so I switched to type Bitmap. This will work, but only if I switch off autofollow.

Case: I have lines with labels. I had these labels with truetype and with autofollow --> MS_TRUE:

Working part: Mapscript:

layerclass.label.color.setRGB(0, 0, 0); layerclass.label.font = "Arial"; layerclass.label.size = 10; //layerclass.label.size = (double)MS_BITMAP_FONT_SIZES.MS_SMALL; layerclass.label.force = mapscript.MS_TRUE; layerclass.label.type = MS_FONT_TYPE.MS_TRUETYPE; //layerclass.label.type = MS_FONT_TYPE.MS_BITMAP; layerclass.label.position = (int)MS_POSITIONS_ENUM.MS_UC; layerclass.label.autoangle = mapscript.MS_TRUE; layerclass.label.autofollow = mapscript.MS_TRUE;

This works.. resulting in mapfile (via mapObj.save()) and image: LABEL

ANGLE FOLLOW ANTIALIAS TRUE FONT "Arial" MAXSIZE 256 MINSIZE 4 SIZE 10 TYPE TRUETYPE BUFFER 0 COLOR 0 0 0 FORCE TRUE MINDISTANCE -1 MINFEATURESIZE -1 OFFSET 0 0 PARTIALS TRUE POSITION UC

END

NOT WORKING PART: However, if I change this to using the BITMAP fonttype, It gives me an error: Mapscript: layerclass.label.color.setRGB(0, 0, 0); //layerclass.label.font = "Arial"; //layerclass.label.size = 10; layerclass.label.size = (double)MS_BITMAP_FONT_SIZES.MS_SMALL; layerclass.label.force = mapscript.MS_TRUE; //layerclass.label.type = MS_FONT_TYPE.MS_TRUETYPE; layerclass.label.type = MS_FONT_TYPE.MS_BITMAP; layerclass.label.position = (int)MS_POSITIONS_ENUM.MS_UC; layerclass.label.autoangle = mapscript.MS_TRUE; layerclass.label.autofollow = mapscript.MS_TRUE; Resulting mapfile: LABEL

SIZE SMALL TYPE BITMAP BUFFER 0 COLOR 0 0 0 FORCE TRUE MINDISTANCE -1 MINFEATURESIZE -1 OFFSET 0 0 PARTIALS TRUE POSITION UC

END

Resulting Error when calling mapObj.draw() :

Attempted to read or write protected memory. This is often an indication that ot her memory is corrupt. (something with P/Invoke)

Using MS4W with mapserver 5.6.1. Using VS2008.

Attachments

Sample.rar Download (185.8 KB) - added by getiem 3 years ago.
Sample program.

Change History

Changed 3 years ago by getiem

Sample program.

Changed 3 years ago by getiem

To run sample program, be sure to add your own path environment to mapscript dll and to mapserver dll folder. I copied both in one folder, so I have only one reference. In normal situation you would reference two directories:

C:\ms4w\Apache\cgi-bin\ and C:\ms4w\Apache\cgi-bin\mapscript\csharp\ as environment variable in program.

Changed 3 years ago by getiem

  • status changed from new to closed
  • resolution set to wontfix

From Tamas:

Unfortunately the autofollow option is not supported with bitmap labels, so my best chance is to raise an exception or switch back to the non followed mode in this case to prevent from the memory corruption.

Best regards,

Tamas


My reply

Ok, its not possible. I could not find documentation or comments on this, on website or in code.

Best options: For me: - NO use of option autofollow anymore. For Mapserver - A decent exception is always better then the standard memory error exception. - A litle remark within the documentation would be nice.

Changed 3 years ago by tamas

  • status changed from closed to reopened
  • resolution wontfix deleted

I reopen this ticket because of the need of a specific error message.

Could you describe in more detail why should you switch to bitmap fonts instead of truetypes?

Changed 2 years ago by tamas

  • status changed from reopened to closed
  • version changed from 5.6 to svn-trunk (development)
  • resolution set to fixed
  • milestone changed from 5.6.2 release to 6.0 release

Added the error message if anglemode 'FOLLOW' is specified with bitmap fonts. (r11082)

Note: See TracTickets for help on using tickets.