export type GetApiFontsFontGlyphArgs = {font: string, glyph: string}; export type GetApiFontsFontGlyphOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * This endpoint is used by map libre to retrieve the fonts. They are separated by font and unicode block * * GET /fonts/{font}/{glyph} */ export const getApiFontsFontGlyph = async (args: GetApiFontsFontGlyphArgs, options?: GetApiFontsFontGlyphOptions) => { const {baseUrl = "https://demo.osrd.fr/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/fonts/${encodeURIComponent(String(args.font))}/${encodeURIComponent(String(args.glyph))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };