ThinkGeo.com    |     Documentation    |     Premium Support

Migrating from v13 to v14

You can just add blankCircleStyle to the layer as a separate style (instead of part of the TextStyle).

If you are creating a style for cluster points, it’s better to use a ClusterPointStyle, where you can input an UnClusteredPointStyle, ClusteredPointStyle and a TextStyle, like following.

     var clusterPointStyle = new ClusterPointStyle(unclusteredPointStyle, textStyle)
     {
         MinimumFeaturesPerCellToCluster = 2,
         ClusteredPointStyle = clusteredPointStyle
     };

We have a sample in HowDoI, please check it out.

Thanks Ben, I took the first approach which is adding the point style as separate layer style.
I found that for the TextStyle, some characters are not showing in the latest version.
In below example, those should be ‘99+’ are not showing correctly.

Hi Jimmy, are you using “Segoe UI”? can you run the following piece of code, which writes “90+” to an image, and use the font you were using in your application, and let me know if the generated image looks good?

            SkiaGeoCanvas canvas = new SkiaGeoCanvas();
            var geoImage = new GeoImage(800, 800);
            canvas.BeginDrawing(geoImage, new RectangleShape(-1000, 1000, 1000, -1000), GeographyUnit.Meter);
            var geoFont = new GeoFont("Segoe UI", 120, DrawingFontStyles.Bold);
            canvas.DrawText("90+", geoFont,GeoBrushes.White, GeoPens.Black, new ScreenPointF[]{new ScreenPointF(400, 400)}, DrawingLevel.LabelLevel, 0, 0, DrawingTextAlignment.Center );
            canvas.EndDrawing();

            geoImage.Save("d:\\test\\result.png");

yes, and it just not working after updating the library.
I guess Segoe UI does not exist in android / iOS, after switch to sans-serif, the character is successfully generated in android (not tested in iOS yet).

However, it looks I cannot use my custom font, I have initialized my fonts but no one work in generating the image

builder.ConfigureFonts(fonts =>
{
fonts.AddFont(“OpenSans-Regular.ttf”, “OpenSansRegular”);
fonts.AddFont(“Bold.otf”, “BoldFontStyle”);
fonts.AddFont(“ExtraLight.otf”, “ExtraLightFontStyle”);
fonts.AddFont(“Light.otf”, “LightFontStyle”);
fonts.AddFont(“Medium.otf”, “MediumFontStyle”);
fonts.AddFont(“Regular.otf”, “RegularFontStyle”);
fonts.AddFont(“SemiBold.otf”, “SemiBoldFontStyle”);
});

Hi Jimmy,

Here’s why it behaves this way and how to fix it:

1. "Segoe UI" doesn’t exist on Android / iOS

When the requested font doesn’t exist, Skia falls back based on the first character .
In "90+" , it found NotoSansCJKsc-Regular , which handles 9 and 0 , but not + , so it showed a tofu block.

2. ConfigureFonts(...) only applies to MAUI UI controls

It does not apply to SkiaSharp (used by ThinkGeo for rendering). Skia needs a real font file, not the MAUI font alias. If the font files are under Resources/Fonts and marked as MauiFont , use something like:

string fontPath = await GetFontTempFilePathAsync("OpenSans-Regular.ttf");

var textStyle = new TextStyle(
    "Name",
    new GeoFont(fontPath, 12, DrawingFontStyles.Bold),
    GeoBrushes.DarkRed
);
public static async Task<string> GetFontTempFilePathAsync(string fileName)
{
    var cacheDir = FileSystem.CacheDirectory;
    var targetPath = Path.Combine(cacheDir, fileName);

    if (File.Exists(targetPath))
        return targetPath;

    Directory.CreateDirectory(cacheDir);

    using var src = await FileSystem.OpenAppPackageFileAsync(fileName);
    using var dest = File.Create(targetPath);
    await src.CopyToAsync(dest);

    return targetPath;
}

You raised a very valid point — the current font related API is a bit confusing and may behave differently across platforms. Let us think about it how to improve it. We will keep you posted.

Thanks,
Ben