Skip to content

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

@CommanderStorm

Description

@CommanderStorm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions