MCPcopy Index your code
hub / github.com/jimp-dev/jimp / processBitmapFont

Function processBitmapFont

plugins/plugin-print/src/load-bitmap-font.ts:138–165  ·  view source on GitHub ↗
(file: string, font: LoadedFont)

Source from the content-addressed store, hash-verified

136export type ResolveBmFont = Omit<BmFont, "pages"> & Pick<RawFont, "pages">;
137
138export async function processBitmapFont(file: string, font: LoadedFont) {
139 const chars: Record<string, BmCharacter> = {};
140 const kernings: Record<string, BmKerning> = {};
141
142 for (let i = 0; i < font.chars.length; i++) {
143 const char = font.chars[i]!;
144 chars[String.fromCharCode(char.id)] = char;
145 }
146
147 for (let i = 0; i < font.kernings.length; i++) {
148 const firstString = String.fromCharCode(font.kernings[i]!.first);
149
150 kernings[firstString] = kernings[firstString]! || {};
151 kernings[firstString]![String.fromCharCode(font.kernings[i]!.second)] =
152 font.kernings[i]!.amount;
153 }
154
155 return {
156 ...font,
157 chars,
158 kernings,
159 pages: await Promise.all(
160 font.pages.map(async (page) =>
161 CharacterJimp.read(path.join(path.dirname(file), page))
162 )
163 ),
164 };
165}

Callers 1

loadFontFunction · 0.85

Calls 1

readMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…