tangrams / tangram

WebGL map rendering engine for creative cartography
https://tangram.city
MIT License
2.2k stars 290 forks source link

Error loading external fonts #771

Open ianthetechie opened 3 years ago

ianthetechie commented 3 years ago

TANGRAM VERSION:

Tangram v0.21.1

ENVIRONMENT:

macOS Big Sur running Firefox 83.

TO REPRODUCE THE ISSUE, FOLLOW THESE STEPS:

Add an external font to my scene file like so:

fonts:
  Open Sans Regular: external

RESULT:

Tangram v0.21.1 [error]: Scene.load() failed to load "scene.yaml": can't assign to property "url" on "external": not an object TypeError: can't assign to property "url" on "external": not an object

EXPECTED RESULT:

Per https://tangrams.readthedocs.io/en/master/Syntax-Reference/fonts/#external, it looks like external fonts are supported via this syntax. However, it looks like the current JS (https://github.com/tangrams/tangram/blob/990d2608c7dce2c3801c2cfd676e5c2e5b74c743/src/scene/scene_loader.js#L131) now assumes that there will be an object with a URL property.

bcamper commented 3 years ago

Yikes, you're right, external fonts do appear to have been broken for some quite awhile 😬 It's an easy fix. I almost wonder if this functionality should just be deprecated, but it does have a logical use, for example in cases where you have brand-specific font you're already loading in your app and don't want to duplicate resources.

bcamper commented 3 years ago

Fixed in master but usually keep issues open until shipped in a production release.

ianthetechie commented 3 years ago

No worries. I'm not convinced I need the feature either, but I was trying some stuff out and noticed that it was busted ;) Thanks for the quick fix!