ThinkGeo.com    |     Documentation    |     Premium Support

ZoomLevelSnappingMode and FontFamilyName

In ThinkGeo UI for Desktop (WinForms) version 10, the following code worked correctly, but in version 13 it no longer functions as expected.
Is there a way to fix this?

  1. ZoomLevelSnappingMode.None does not work in version 13

(Version 10)
winformsMap1.MinimumScale = 1f;
winformsMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.None;
winformsMap1.MapUnit = GeographyUnit.Meter;

(Version 13)
mapView.MinimumScale = 1f;
mapView.ZoomLevelSnappingMode = ZoomLevelSnappingMode.None; // Has no effect
mapView.MapUnit = GeographyUnit.Meter;

  1. In version 13, the FontFamilyName in CreateSimpleTextStyle is not applied

(Version 10)
vLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(“emd”, “Verdana”, 14, DrawingFontStyles.Bold, GeoColor.SimpleColors.Black);

(Version 13)
vLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyle.CreateSimpleTextStyle(“emd”, “Verdana”, 14, DrawingFontStyles.Black, GeoColors.Black);

Hi,

1. Regarding ZoomLevelSnappingMode

It’s not clear which exact version of v13 you’re using, but in v14, the ZoomLevelSnappingMode property has been deprecated. In the latest version (v14.3.2 as of now), the behavior is as follows:

  • When you set mapView.CurrentScale directly or call mapView.ZoomTo(scale), the map will stay at that exact scale.
  • Snapping occurs only when using mouse wheel or double-click zoom — in those cases, the map will snap to the predefined scales in mapView.ZoomScales.

I recommend updating to v14.3 and using programmatic zoom when precision matters, or could you clarify exactly what you’re trying to achieve with ZoomLevelSnappingMode.None?

2. Regarding FontFamilyName in CreateSimpleTextStyle

In v10, we used GDI+, which relied on Windows’ font management. In v13, we switched to Skia which handles fonts differently and more strictly. So it’s possible Skia might not be able to locate or use a font unless it’s correctly registered or accessible in a Skia-compatible way.

To verify that Skia can access “Verdana”, try the following test:

var typeface = SKTypeface.FromFamilyName("Verdana");
if (typeface == null)
    Console.WriteLine("Failed to load Verdana via Skia");
else
    Console.WriteLine("Loaded Verdana via Skia successfully");

If it fails, you can alternatively load it directly by path; if it does load it successfully, but the appearance still looks off, please clarify does it render with “Verdana” but look different from v10 (GDI+)? This will help us pinpoint whether it’s a font loading issue or just a rendering engine difference.

Thanks,
Ben

Thank you for your response. It was very helpful.

I’ve reviewed the additional items you requested.

The reason for using ZoomLevelSnappingMode.None:
The goal was to apply an arbitrary scale. As you confirmed in your response, we can directly set or call mapView.CurrentScale or mapView.ZoomTo(scale) in v14.3.2 to keep the map at that specific scale. We plan to consider upgrading to v14 if necessary.

Regarding the FontFamilyName application:
Executing the code you provided resulted in “Loaded Verdana via Skia successfully,” so the font is loading correctly. However, the appearance still looks odd compared to v10. I’m wondering if there is a way to make it look as close as possible to the way it appeared in v10.

Thank you very much for your prompt reply.

Any chance you can give me a side-by-side comparison, what it looks like for the same label in v10 vs v13 in your application?

review.zip (2.0 MB)

I’ve attached the following files for comparison:

  1. Comparison screenshot.pptx - This contains a screen capture of the comparison results.
  2. FontTest_v13.zip, FontTest_v10.zip - The source files.
  3. dat.zip - The sample data.
  4. font.zip - The fonts.

Hi JiHoon,

Thanks for the detailed info!

I see 2 issues here:

  1. The font size needs to be modified after upgrading to V13:
    a. The unit of GeoFont in V10 (GDI+) is “em size” while V13 uses “pixels” (Skia)
    b. The relationship between pixels and em size is: pixels = (emSize * DPI) / 72. For example, if emSize = 12, then pixels = (12 * 96) / 72 = 16.
    c. When upgrading to V12 and replacing GDI+ with Skia, we decided to use pixels instead of emSize for the fontSize to maintain consistency with the rendering engine.

  2. About the font issue:
    Giving the fact it looks the same for different account, I’m thinking maybe the font is not loaded successfully at all so fall back to the same default font. Can you try directly pass in the ttf to the textstyle as following instead of just using the name? Let me know if it works

vecLayerUmdBound.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyle.CreateSimpleTextStyle(“emd_nm”, @“d:\Downloads\review\font\12롯데마트드림Bold.ttf”, 18, DrawingFontStyles.Bold, GeoColors.Black);

  1. I couldn’t recreate your issue as your sample not showing correctly even after adding Korean to my system, I think it could be easier if you guys have a try on your end before making more setting changes. Anyway, let me know what you find out.

Thanks,
Ben

Comparison screenshot_2.zip (278.5 KB)

There has been no change to the results…
Please see the attached screenshot of the results

I appreciate your thoughtful feedback and review.

The following code will draw a given text to an image. Can you verify if the result is what you expected?

using SkiaSharp;

class Program
{
static void Main()
{
// Configuration: font path + text to render
string fontPath = @“d:\Downloads\review\font\12롯데마트드림Bold.ttf”; // Font file path
string text = “안녕하세요, 세계! Hello, World!”;
string outputPath = “output.png”;

    // Image parameters
    int imageWidth = 800;
    int imageHeight = 200;
    int fontSize = 72;

    if (!File.Exists(fontPath))
    {
        Console.WriteLine($"Font file not found: {fontPath}");
        return;
    }

    // Load the font
    using var typeface = SKTypeface.FromFile(fontPath);
    using var surface = SKSurface.Create(new SKImageInfo(imageWidth, imageHeight));
    var canvas = surface.Canvas;
    canvas.Clear(SKColors.White);

    // Create paint
    using var paint = new SKPaint
    {
        Typeface = typeface,
        TextSize = fontSize,
        IsAntialias = true,
        Color = SKColors.Black,
        TextAlign = SKTextAlign.Left
    };

    // Measure text bounds
    var bounds = new SKRect();
    paint.MeasureText(text, ref bounds);
    float x = 20;
    float y = (imageHeight + bounds.Height) / 2 - bounds.Top;

    // Draw the text
    canvas.DrawText(text, x, y, paint);

    // Save image
    using var image = surface.Snapshot();
    using var data = image.Encode(SKEncodedImageFormat.Png, 100);
    using var stream = File.OpenWrite(outputPath);
    data.SaveTo(stream);

    Console.WriteLine($"Image saved to: {Path.GetFullPath(outputPath)}");
}

}

The provided code executed successfully. The font has been applied correctly !!!

That’s great !!
Thank you so much. But how do I apply this to TextStyle.CreateSimpleTextStyle ?

Hi JiHoon

We fixed an issue in the latest beta, please pull the latest (14.4.0-beta064 ) and have another try.

Thanks,
Ben