Labels are totally wrong: fonts are mixed in the same label ! HELP...

40 views
Skip to first unread message

daniel...@gmail.com

unread,
Feb 28, 2020, 1:13:47 PM2/28/20
to cesium-dev
1. A concise explanation of the problem you're experiencing.
I'm using a custom font to display labels,
as you can see in the picture in the same label the standard serif font is "mixed" with my custom font

wrongFontLabels.JPG




2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

<style>
  @font-face {
            font-family: Acumin-bold;
            src: url("../fonts/Acumin-BdPro.otf") format("opentype");
        }
</style>

viewer.entities.add({
                                        position: Cesium.Cartesian3.fromDegrees(longitude, latitude),
                                        label: {
                                            text: result.city,
                                            font: '24px Acumin-bold',
                                            fillColor: Cesium.Color.WHITE,
                                            outlineColor: Cesium.Color.BLACK,
                                            outlineWidth: 3,
                                            style: Cesium.LabelStyle.FILL_AND_OUTLINE,
                                            verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                                            heightReference: Cesium.HeightReference.NONE,
                                            pixelOffset: new Cesium.Cartesian2(0, -5),
                                            translucencyByDistance: new Cesium.NearFarScalar(minDistance, 1.0,
                                                maxDistance, 0.0),
                                            disableDepthTestDistance: Number.POSITIVE_INFINITY,
                                        }
                                    });

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
To use a custom font for labels


4. The Cesium version you're using, your operating system and browser.
1.66


Scott Hunter

unread,
Feb 28, 2020, 1:24:14 PM2/28/20
to cesiu...@googlegroups.com
Your JavaScript code to create the labels is running before the browser has loaded the font. There are many ways to detect whether a font-face has loaded before running your application, for example: https://github.com/typekit/webfontloader or  https://usefulangle.com/post/74/javascript-dynamic-font-loading    

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cesium-dev/12593a87-1ca0-43dd-90d5-474244776552%40googlegroups.com.

daniel...@gmail.com

unread,
Mar 9, 2020, 9:31:01 AM3/9/20
to cesium-dev
Thnak-you Scott,
but this is not the problem.
I can't use my font neither waiting A LOT of time before to draw the label..
To unsubscribe from this group and stop receiving emails from it, send an email to cesiu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages