Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support martins' /catalog-api for font discovery #961

Open
CommanderStorm opened this issue Dec 15, 2024 · 1 comment
Open

Support martins' /catalog-api for font discovery #961

CommanderStorm opened this issue Dec 15, 2024 · 1 comment

Comments

@CommanderStorm
Copy link

CommanderStorm commented Dec 15, 2024

Created from:

Closely related to:

Problem

Maputnik currenlly does request /font/%7Bfontstack%7D/%7Brange%7D to query for fonts if ran against maplibre/martin.
This is the case because the orinal font url is /font/{fontstack}/{range}.
As the .pbf ending that maputnik assumes does not exist, the replacement on line 30 below does not happen.

Related PR on martins side which we did not get done yet:

Maputnik expects to recieve an array of possible fontstacks.

Feature Request

would it be possible to request these 3 URLs in paralel and accept the first successfull response or would the overhead be too high on the maputnik side?:

  • (idk which software this is) original URL
  • (idk which software this is, its not tileserver-gl) /fontstack.json
  • (tileserver-gl) replace(normPathPart, '.json')
  • (martin) /catalog

Alternatives

We could handle this in martin. I am unsure what is the best option here.
A hybrid approach would be to drop the .pbf requirement in below code and implement serving under the replace(normPathPart, '.json')-Url in martin

Additional Context

export function downloadGlyphsMetadata(urlTemplate: string, cb: (...args: any[]) => void) {
if(!urlTemplate) return cb([])
// Special handling because Tileserver GL serves the fontstacks metadata differently
// https://github.com/klokantech/tileserver-gl/pull/104#issuecomment-274444087
const urlObj = npmurl.parse(urlTemplate);
const normPathPart = '/%7Bfontstack%7D/%7Brange%7D.pbf';
if(urlObj.pathname === normPathPart) {
urlObj.pathname = '/fontstacks.json';
} else {
urlObj.pathname = urlObj.pathname!.replace(normPathPart, '.json');
}
const url = npmurl.format(urlObj);
loadJSON(url, [], cb)
}

CC @nyurik @artyomb

Note

PS: I have a bit of time in my cristmas break to look into implementing this.
I think I am missing a bit of context as the code relevant seems a bit strange

@nyurik
Copy link
Member

nyurik commented Dec 15, 2024

I would prefer to rely on the /catalog API, or possibly even query multiple endpoints - and see which one gives real result - and use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants