webfont 11.2.26 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/NOTICE.md +165 -0
  2. package/README.md +302 -34
  3. package/dist/browser.js +4 -0
  4. package/dist/cli.mjs +893 -0
  5. package/dist/index.js +1 -507
  6. package/dist/parseTemplateOption-5T7rSw5J.mjs +20 -0
  7. package/dist/parseTemplateOption-BmH_pcQh.js +1 -0
  8. package/dist/renderTemplates-DvRlS58E.mjs +93 -0
  9. package/dist/renderTemplates-zCYCzeOt.js +1 -0
  10. package/dist/src/browser.d.ts +2 -0
  11. package/dist/src/index.d.ts +4 -2
  12. package/dist/src/lib/applyOptimizeSvgToGlyphs.d.ts +3 -0
  13. package/dist/src/lib/evenoddFillRule.d.ts +2 -0
  14. package/dist/src/lib/execCLI/index.d.ts +3 -4
  15. package/dist/src/lib/inputSource.d.ts +2 -0
  16. package/dist/src/lib/inputSourceUtils.d.ts +4 -0
  17. package/dist/src/lib/largeFontLigatures.d.ts +4 -0
  18. package/dist/src/lib/optimizeSvgGlyphs.d.ts +4 -0
  19. package/dist/src/lib/p-limit/index.d.ts +2 -0
  20. package/dist/src/lib/parseFormats.d.ts +4 -0
  21. package/dist/src/lib/parseTemplateOption.d.ts +2 -0
  22. package/dist/src/lib/runtimeEnvironment.d.ts +4 -0
  23. package/dist/src/lib/sfnt/flavor.d.ts +2 -0
  24. package/dist/src/lib/svgDiagnostics/diagnoseSvgContents.d.ts +12 -0
  25. package/dist/src/lib/svgFontOutput/emptyGlyphPaths.d.ts +3 -0
  26. package/dist/src/lib/svgTools/applySvgDiagnostics.d.ts +13 -0
  27. package/dist/src/lib/svgTools/applySvgTools.d.ts +14 -0
  28. package/dist/src/lib/svgTools/normalizeSvgToolsOptions.d.ts +2 -0
  29. package/dist/src/lib/svgicons2svgfont/index.d.ts +14 -0
  30. package/dist/src/lib/svgicons2svgfont/metadataFromSrcPath.d.ts +11 -0
  31. package/dist/src/lib/templateUnicodeRange.d.ts +4 -0
  32. package/dist/src/lib/ttf2eot/index.d.ts +2 -0
  33. package/dist/src/lib/ttfEncode.d.ts +5 -0
  34. package/dist/src/standalone/convertTtfInput.d.ts +3 -0
  35. package/dist/src/standalone/convertWebfontInput.d.ts +3 -0
  36. package/dist/src/standalone/defaultOptions.d.ts +3 -0
  37. package/dist/src/standalone/fetchWebfontUrl.d.ts +1 -0
  38. package/dist/src/standalone/generateSvgFont.d.ts +2 -0
  39. package/dist/src/standalone/getGlyphsDataFromInputs.d.ts +3 -0
  40. package/dist/src/standalone/glyphsData.d.ts +2 -2
  41. package/dist/src/standalone/index.d.ts +8 -3
  42. package/dist/src/standalone/inputMode.d.ts +9 -0
  43. package/dist/src/standalone/options.d.ts +3 -3
  44. package/dist/src/standalone/optionsFromGlyphs.d.ts +3 -0
  45. package/dist/src/standalone/renderTemplates.d.ts +10 -0
  46. package/dist/src/standalone/runSvgPipeline.d.ts +3 -0
  47. package/dist/src/standalone/templateFonts.d.ts +3 -0
  48. package/dist/src/standalone/toTtf.d.ts +4 -0
  49. package/dist/src/standalone/validateWebfontOptions.d.ts +6 -0
  50. package/dist/src/standalone/webfontFromGlyphs.d.ts +3 -0
  51. package/dist/src/types/DecompressedFont.d.ts +5 -0
  52. package/dist/src/types/Format.d.ts +4 -4
  53. package/dist/src/types/GlyphContentTransformFn.d.ts +2 -0
  54. package/dist/src/types/GlyphData.d.ts +2 -2
  55. package/dist/src/types/GlyphInput.d.ts +6 -0
  56. package/dist/src/types/GlyphMetadata.d.ts +1 -1
  57. package/dist/src/types/GlyphTransformFn.d.ts +2 -2
  58. package/dist/src/types/InitialOptions.d.ts +7 -4
  59. package/dist/src/types/MetadataProvider.d.ts +5 -0
  60. package/dist/src/types/OptionsBase.d.ts +12 -3
  61. package/dist/src/types/RenderedTemplate.d.ts +7 -0
  62. package/dist/src/types/Result.d.ts +16 -5
  63. package/dist/src/types/ResultConfig.d.ts +4 -0
  64. package/dist/src/types/SvgToolsOptions.d.ts +13 -0
  65. package/dist/src/types/TranscodedFont.d.ts +7 -0
  66. package/dist/src/types/WebfontFromGlyphsOptions.d.ts +11 -0
  67. package/dist/src/types/WebfontOptions.d.ts +39 -3
  68. package/dist/src/types/index.d.ts +8 -6
  69. package/package.json +65 -57
  70. package/templates/template.css.njk +6 -3
  71. package/templates/template.html.njk +15 -4
  72. package/templates/template.scss.njk +6 -3
  73. package/templates/template.styl.njk +6 -3
  74. package/dist/cli.js +0 -801
  75. package/dist/jest.config.d.ts +0 -3
  76. package/dist/src/cli/index.d.ts +0 -1
  77. package/dist/src/cli/index.test.d.ts +0 -1
  78. package/dist/src/cli/meow/index.d.ts +0 -104
  79. package/dist/src/index.test.d.ts +0 -1
  80. package/dist/src/standalone/index.test.d.ts +0 -1
@@ -1,3 +1,5 @@
1
- import { webfont } from "./standalone";
2
- export { webfont } from "./standalone";
1
+ import { webfont } from './standalone';
2
+ export { diagnoseGlyphsData, diagnoseSvgContents } from './lib/svgDiagnostics/diagnoseSvgContents';
3
+ export { webfont } from './standalone';
4
+ export type { SvgDiagnosticCode, SvgGlyphDiagnostic, SvgToolsOptions } from './types/SvgToolsOptions';
3
5
  export default webfont;
@@ -0,0 +1,3 @@
1
+ import { Config } from 'svgo';
2
+ import { GlyphData } from '../types/GlyphData';
3
+ export declare const applyOptimizeSvgToGlyphs: (glyphs: GlyphData[], svgoConfig?: Config) => GlyphData[];
@@ -0,0 +1,2 @@
1
+ export declare const hasEvenoddFillRule: (svgContents: string) => boolean;
2
+ export declare const evenoddFillRuleWarning: (srcPath: string) => string;
@@ -1,13 +1,12 @@
1
- /// <reference types="node" />
2
- import { ExecException } from "child_process";
3
- export declare type Output = {
1
+ import { ExecException } from 'child_process';
2
+ export type Output = {
4
3
  code?: number;
5
4
  error: ExecException | null;
6
5
  files: string[];
7
6
  stderr?: string;
8
7
  stdout?: string;
9
8
  };
10
- export declare type ExecCLI = (args?: string, destination?: string) => Promise<Output>;
9
+ export type ExecCLI = (_args?: string, _destination?: string) => Promise<Output>;
11
10
  /**
12
11
  * @name execCLI
13
12
  * @description Execute webfont CLI commands using child_process.
@@ -0,0 +1,2 @@
1
+ export { getInputExtension, getWebfontSourceBasename, isHttpUrl, resolveDecompressedFontBasenames, } from './inputSourceUtils';
2
+ export declare const resolveInputSources: (patterns: readonly string[]) => Promise<string[]>;
@@ -0,0 +1,4 @@
1
+ export declare const isHttpUrl: (value: string) => boolean;
2
+ export declare const getInputExtension: (source: string) => string;
3
+ export declare const getWebfontSourceBasename: (source: string) => string;
4
+ export declare const resolveDecompressedFontBasenames: (sources: readonly string[]) => string[];
@@ -0,0 +1,4 @@
1
+ /** Glyph count above which OpenType ligatures often hurt browser layout (Firefox / DirectWrite). */
2
+ export declare const LARGE_FONT_LIGATURE_GLYPH_THRESHOLD = 2000;
3
+ export declare const shouldWarnLargeFontLigatures: (glyphCount: number, ligaturesEnabled: boolean) => boolean;
4
+ export declare const formatLargeFontLigatureWarning: (glyphCount: number) => string;
@@ -0,0 +1,4 @@
1
+ import { Config } from 'svgo';
2
+ /** Conservative SVGO preset: cleanup cruft without rewriting paths or removing viewBox. */
3
+ export declare const defaultWebfontSvgoConfig: () => Config;
4
+ export declare const optimizeSvgContents: (contents: string, srcPath: string, config?: Config) => string;
@@ -0,0 +1,2 @@
1
+ import { default as pLimit } from 'p-limit';
2
+ export default pLimit;
@@ -0,0 +1,4 @@
1
+ import { Format, Formats } from '../types/Format';
2
+ export declare const assertValidFormat: (value: unknown) => Format;
3
+ export declare const parseFormatsList: (values: readonly unknown[]) => Formats;
4
+ export declare const assertFormatsOption: (formats: unknown) => Formats;
@@ -0,0 +1,2 @@
1
+ export type TemplateOption = string | string[];
2
+ export declare const normalizeTemplateOption: (template: unknown) => string[];
@@ -0,0 +1,4 @@
1
+ /** True in browser tabs and Web Workers (including Vite `process` polyfills). */
2
+ export declare const isBrowserOrWorkerRuntime: () => boolean;
3
+ /** True only in real Node.js — not in browser tabs or Web Workers. */
4
+ export declare const isNodeRuntime: () => boolean;
@@ -0,0 +1,2 @@
1
+ export type SfntFlavor = "otf" | "ttf";
2
+ export declare const getSfntFlavor: (buffer: Buffer) => SfntFlavor;
@@ -0,0 +1,12 @@
1
+ import { SvgGlyphDiagnostic } from '../../types/SvgToolsOptions';
2
+ export declare const hasStrokeOnlySvg: (svgContents: string) => boolean;
3
+ export declare const hasUnsupportedSvgElements: (svgContents: string) => boolean;
4
+ export declare const diagnoseSvgContents: (srcPath: string, svgContents: string) => SvgGlyphDiagnostic[];
5
+ export declare const diagnoseGlyphsData: (glyphs: ReadonlyArray<{
6
+ contents: string;
7
+ srcPath: string;
8
+ }>) => SvgGlyphDiagnostic[];
9
+ export declare const shouldLogDiagnostic: (diagnostic: SvgGlyphDiagnostic, options: {
10
+ diagnose?: boolean;
11
+ verbose?: boolean;
12
+ }) => boolean;
@@ -0,0 +1,3 @@
1
+ import { GlyphData } from '../../types/GlyphData';
2
+ export declare const findEmptySvgFontGlyphNames: (svgFont: string) => string[];
3
+ export declare const assertNonEmptySvgFontGlyphs: (svgFont: string, glyphsData: ReadonlyArray<Pick<GlyphData, "metadata" | "srcPath">>) => void;
@@ -0,0 +1,13 @@
1
+ import { GlyphData } from '../../types/GlyphData';
2
+ import { SvgGlyphDiagnostic } from '../../types/SvgToolsOptions';
3
+ export type SvgToolsReporter = (message: string) => void;
4
+ export type ApplySvgDiagnosticsResult = {
5
+ diagnostics: SvgGlyphDiagnostic[];
6
+ glyphs: GlyphData[];
7
+ };
8
+ export declare const applySvgDiagnosticsToGlyphs: (glyphsData: GlyphData[], svgToolsInput: {
9
+ diagnose?: boolean;
10
+ } | undefined, runtime?: {
11
+ reporter?: SvgToolsReporter;
12
+ verbose?: boolean;
13
+ }) => ApplySvgDiagnosticsResult;
@@ -0,0 +1,14 @@
1
+ import { GlyphData } from '../../types/GlyphData';
2
+ import { SvgGlyphDiagnostic, SvgToolsOptions } from '../../types/SvgToolsOptions';
3
+ import { SvgToolsReporter } from './applySvgDiagnostics';
4
+ export type { SvgToolsReporter } from './applySvgDiagnostics';
5
+ export type ApplySvgToolsResult = {
6
+ diagnostics: SvgGlyphDiagnostic[];
7
+ glyphs: GlyphData[];
8
+ };
9
+ export type ApplySvgToolsRuntime = {
10
+ reporter?: SvgToolsReporter;
11
+ /** When true, logs evenodd diagnostics even if svgTools.diagnose is off (backward compatible with --verbose). */
12
+ verbose?: boolean;
13
+ };
14
+ export declare const applySvgToolsToGlyphs: (glyphsData: GlyphData[], svgToolsInput: SvgToolsOptions | undefined, runtime?: ApplySvgToolsRuntime) => ApplySvgToolsResult;
@@ -0,0 +1,2 @@
1
+ import { SvgToolsOptions } from '../../types/SvgToolsOptions';
2
+ export declare const normalizeSvgToolsOptions: (svgTools?: SvgToolsOptions) => SvgToolsOptions | undefined;
@@ -0,0 +1,14 @@
1
+ import { SVGIcons2SVGFontStreamOptions, fileSorter, getMetadataService, SVGIcons2SVGFontStream } from 'svgicons2svgfont';
2
+ import { WebfontOptions } from '../../types';
3
+ export { fileSorter, getMetadataService, SVGIcons2SVGFontStream };
4
+ type MetadataServiceOptions = {
5
+ prependUnicode: boolean;
6
+ startUnicode: number;
7
+ };
8
+ export declare const getMetadataServiceOptions: (options: WebfontOptions) => MetadataServiceOptions;
9
+ /**
10
+ * Coerce `round` for svgicons2svgfont; accepts number or numeric string (CLI/config).
11
+ * Returns undefined for undefined/null/empty/non-numeric/non-finite inputs.
12
+ */
13
+ export declare const normalizeRoundOption: (round: string | number | null | undefined) => number | undefined;
14
+ export declare const getFontStreamOptions: (options: WebfontOptions) => Partial<SVGIcons2SVGFontStreamOptions>;
@@ -0,0 +1,11 @@
1
+ import { MetadataProvider } from '../../types/MetadataProvider';
2
+ type MetadataServiceOptions = {
3
+ prependUnicode: boolean;
4
+ startUnicode: number;
5
+ };
6
+ /**
7
+ * Browser-safe metadata lookup from a virtual `srcPath` (no `fs`, no file rename).
8
+ * Mirrors {@link https://github.com/nfroidure/svgicons2svgfont | svgicons2svgfont} filename rules.
9
+ */
10
+ export declare const createMetadataFromSrcPathService: (options?: Partial<MetadataServiceOptions>) => MetadataProvider;
11
+ export {};
@@ -0,0 +1,4 @@
1
+ import { GlyphMetadata } from '../types/GlyphMetadata';
2
+ export declare const collectCodePointsFromGlyphs: (glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => number[];
3
+ export declare const computeUnicodeRangeFromGlyphs: (glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => string | undefined;
4
+ export declare const resolveTemplateUnicodeRange: (unicodeRange: boolean | string | undefined, glyphs: readonly Pick<GlyphMetadata, "unicode">[]) => string | undefined;
@@ -0,0 +1,2 @@
1
+ declare const convertTtfToEot: (ttf: Buffer) => Buffer;
2
+ export default convertTtfToEot;
@@ -0,0 +1,5 @@
1
+ export declare const encodeTtfToEot: (buffer: Buffer) => Buffer;
2
+ export declare const encodeTtfToWoff: (buffer: Buffer, options?: {
3
+ metadata?: string;
4
+ }) => Buffer;
5
+ export declare const encodeTtfToWoff2: (buffer: Buffer) => Promise<Buffer>;
@@ -0,0 +1,3 @@
1
+ import { Result } from '../types/Result';
2
+ import { WebfontOptions } from '../types/WebfontOptions';
3
+ export declare const convertTtfInput: (fontFiles: readonly string[], options: WebfontOptions) => Promise<Result>;
@@ -0,0 +1,3 @@
1
+ import { Result } from '../types/Result';
2
+ import { WebfontOptions } from '../types/WebfontOptions';
3
+ export declare const convertWebfontInput: (fontFiles: readonly string[], options: WebfontOptions) => Promise<Result>;
@@ -0,0 +1,3 @@
1
+ import { WebfontOptions } from '../types/WebfontOptions';
2
+ /** Shared defaults for Node (`files`) and in-memory (`glyphs`) entry points. */
3
+ export declare const defaultWebfontOptions: () => Omit<WebfontOptions, "files">;
@@ -0,0 +1 @@
1
+ export declare const fetchWebfontFromUrl: (url: string) => Promise<Buffer>;
@@ -0,0 +1,2 @@
1
+ import { GlyphData, WebfontOptions } from '../types';
2
+ export declare const generateSvgFont: (glyphsData: GlyphData[], options: WebfontOptions) => Promise<string>;
@@ -0,0 +1,3 @@
1
+ import { GlyphData, WebfontOptions } from '../types';
2
+ import { GlyphInput } from '../types/GlyphInput';
3
+ export declare const getGlyphsDataFromInputs: (inputs: readonly GlyphInput[], options: WebfontOptions) => Promise<GlyphData[]>;
@@ -1,4 +1,4 @@
1
- import type { GlyphData, WebfontOptions } from "../types";
2
- declare type GlyphsDataGetter = (files: Array<GlyphData["srcPath"]>, options: WebfontOptions) => unknown;
1
+ import { GlyphData, WebfontOptions } from '../types';
2
+ type GlyphsDataGetter = (_files: Array<GlyphData["srcPath"]>, _options: WebfontOptions) => Promise<GlyphData[]>;
3
3
  export declare const getGlyphsData: GlyphsDataGetter;
4
4
  export {};
@@ -1,5 +1,10 @@
1
- import type { InitialOptions } from "../types";
2
- import type { Result } from "../types/Result";
3
- declare type Webfont = (initialOptions?: InitialOptions) => Promise<Result>;
1
+ import { cosmiconfig } from 'cosmiconfig';
2
+ import { InitialOptions } from '../types';
3
+ import { Result } from '../types/Result';
4
+ type CosmiconfigLoaded = NonNullable<Awaited<ReturnType<ReturnType<typeof cosmiconfig>["search"]>>>;
5
+ export declare const loadWebfontConfig: (options: {
6
+ configFile?: string;
7
+ }) => Promise<CosmiconfigLoaded | Record<string, never>>;
8
+ type Webfont = (_initialOptions?: InitialOptions) => Promise<Result>;
4
9
  export declare const webfont: Webfont;
5
10
  export default webfont;
@@ -0,0 +1,9 @@
1
+ import { Format } from '../types/Format';
2
+ export type InputMode = "empty" | "mixed" | "svg" | "ttf" | "webfont";
3
+ export declare const classifyInputFiles: (filePaths: readonly string[]) => InputMode;
4
+ export declare const assertSvgPipelineFormats: (formats: readonly Format[]) => void;
5
+ export declare const filterInputFilesByMode: (filePaths: readonly string[], mode: InputMode) => string[];
6
+ export type ConversionFormat = "otf" | "ttf";
7
+ export type TtfEncodeFormat = "eot" | "ttf" | "woff" | "woff2";
8
+ export declare const resolveTtfConversionFormats: (formats: readonly Format[]) => TtfEncodeFormat[];
9
+ export declare const resolveWebfontConversionFormats: (formats: readonly Format[]) => ConversionFormat[];
@@ -1,5 +1,5 @@
1
- import type { InitialOptions } from "../types/InitialOptions";
2
- import { WebfontOptions } from "../types/WebfontOptions";
3
- declare type OptionsGetter = (initialOptions?: InitialOptions) => WebfontOptions;
1
+ import { InitialOptions } from '../types/InitialOptions';
2
+ import { WebfontOptions } from '../types/WebfontOptions';
3
+ type OptionsGetter = (_initialOptions?: InitialOptions) => WebfontOptions;
4
4
  export declare const getOptions: OptionsGetter;
5
5
  export {};
@@ -0,0 +1,3 @@
1
+ import { WebfontFromGlyphsOptions } from '../types/WebfontFromGlyphsOptions';
2
+ import { WebfontOptions } from '../types/WebfontOptions';
3
+ export declare const getOptionsFromGlyphs: (initialOptions: WebfontFromGlyphsOptions) => WebfontOptions;
@@ -0,0 +1,10 @@
1
+ import { Format } from '../types/Format';
2
+ import { RenderedTemplate } from '../types/RenderedTemplate';
3
+ import { Result } from '../types/Result';
4
+ import { WebfontOptions } from '../types/WebfontOptions';
5
+ type RenderTemplatesResult = {
6
+ templates: RenderedTemplate[];
7
+ usedBuildInTemplate: boolean;
8
+ };
9
+ export declare const renderTemplates: (options: WebfontOptions, result: Pick<Result, "glyphsData" | "hash"> & Partial<Result>, formats: readonly Format[]) => RenderTemplatesResult;
10
+ export {};
@@ -0,0 +1,3 @@
1
+ import { GlyphData, WebfontOptions } from '../types';
2
+ import { Result } from '../types/Result';
3
+ export declare const runSvgPipeline: (glyphsData: GlyphData[], options: WebfontOptions) => Promise<Result>;
@@ -0,0 +1,3 @@
1
+ import { Format } from '../types/Format';
2
+ import { Result } from '../types/Result';
3
+ export declare const getTemplateFontBase64: (format: Format, result: Result) => string;
@@ -0,0 +1,4 @@
1
+ import { default as svg2ttf } from 'svg2ttf';
2
+ export type ToTtfOptions = Parameters<typeof svg2ttf>[1];
3
+ declare const toTtf: (svgFontString: string, options?: ToTtfOptions) => Buffer;
4
+ export default toTtf;
@@ -0,0 +1,6 @@
1
+ import { WebfontOptions } from '../types/WebfontOptions';
2
+ /**
3
+ * Runtime validation for merged webfont options (API, cosmiconfig, CLI).
4
+ * Rejects mis-typed or unknown format names before running a pipeline (#133).
5
+ */
6
+ export declare const validateWebfontOptions: (options: WebfontOptions) => WebfontOptions;
@@ -0,0 +1,3 @@
1
+ import { Result } from '../types/Result';
2
+ import { WebfontFromGlyphsOptions } from '../types/WebfontFromGlyphsOptions';
3
+ export declare const webfontFromGlyphs: (initialOptions: WebfontFromGlyphsOptions) => Promise<Result>;
@@ -0,0 +1,5 @@
1
+ export type DecompressedFont = {
2
+ source: string;
3
+ ttf?: Buffer;
4
+ otf?: Buffer;
5
+ };
@@ -1,9 +1,9 @@
1
- export declare type Format = "eot" | "woff" | "woff2" | "svg" | "ttf";
2
- export declare type Formats = Array<Format>;
3
- declare type FormatOption = {
1
+ export type Format = "eot" | "otf" | "woff" | "woff2" | "svg" | "ttf";
2
+ export type Formats = Array<Format>;
3
+ type FormatOption = {
4
4
  copyright: null;
5
5
  ts: null;
6
6
  version: null;
7
7
  };
8
- export declare type FormatsOptions = Partial<Record<Format, FormatOption>>;
8
+ export type FormatsOptions = Partial<Record<Format, FormatOption>>;
9
9
  export {};
@@ -0,0 +1,2 @@
1
+ import { GlyphData } from './GlyphData';
2
+ export type GlyphContentTransformFn = (_glyph: GlyphData) => string | Promise<string>;
@@ -1,5 +1,5 @@
1
- import { GlyphMetadata } from "./GlyphMetadata";
2
- export declare type GlyphData = {
1
+ import { GlyphMetadata } from './GlyphMetadata';
2
+ export type GlyphData = {
3
3
  contents: string;
4
4
  metadata?: GlyphMetadata;
5
5
  srcPath: string;
@@ -0,0 +1,6 @@
1
+ export type GlyphInput = {
2
+ /** SVG source text. */
3
+ contents: string;
4
+ /** Logical path or filename used for metadata (defaults to `icon.svg`). */
5
+ srcPath?: string;
6
+ };
@@ -1,4 +1,4 @@
1
- export declare type GlyphMetadata = {
1
+ export type GlyphMetadata = {
2
2
  name: string;
3
3
  /**
4
4
  * @example
@@ -1,2 +1,2 @@
1
- import { GlyphMetadata } from "./GlyphMetadata";
2
- export declare type GlyphTransformFn = (obj: GlyphMetadata) => GlyphMetadata | Promise<GlyphMetadata>;
1
+ import { GlyphMetadata } from './GlyphMetadata';
2
+ export type GlyphTransformFn = (_obj: GlyphMetadata) => GlyphMetadata | Promise<GlyphMetadata>;
@@ -1,7 +1,10 @@
1
- import { GlyphTransformFn } from "./GlyphTransformFn";
2
- import { OptionsBase } from "./OptionsBase";
3
- export declare type InitialOptions = OptionsBase & {
4
- filePath?: string;
1
+ import { GlyphContentTransformFn } from './GlyphContentTransformFn';
2
+ import { GlyphTransformFn } from './GlyphTransformFn';
3
+ import { MetadataProvider } from './MetadataProvider';
4
+ import { OptionsBase } from './OptionsBase';
5
+ export type InitialOptions = OptionsBase & {
5
6
  files: string | Array<string>;
7
+ glyphContentTransformFn?: GlyphContentTransformFn;
6
8
  glyphTransformFn?: GlyphTransformFn;
9
+ metadataProvider?: MetadataProvider;
7
10
  };
@@ -0,0 +1,5 @@
1
+ export type FileMetadata = {
2
+ name: string;
3
+ unicode?: string | string[];
4
+ };
5
+ export type MetadataProvider = (srcPath: string, callback: (error: Error | null, metadata?: FileMetadata) => void) => void;
@@ -1,11 +1,13 @@
1
- import { Formats } from "./Format";
2
- export declare type OptionsBase = {
1
+ import { TemplateOption } from '../lib/parseTemplateOption';
2
+ import { Formats } from './Format';
3
+ import { SvgToolsOptions } from './SvgToolsOptions';
4
+ export type OptionsBase = {
3
5
  configFile?: string;
4
6
  dest?: string;
5
7
  destCreate?: boolean;
6
8
  fontName?: string | unknown;
7
9
  formats?: Formats;
8
- template?: "css" | string;
10
+ template?: TemplateOption;
9
11
  templateClassName?: string | unknown;
10
12
  templateFontPath?: string;
11
13
  templateFontName?: string | unknown;
@@ -26,5 +28,12 @@ export declare type OptionsBase = {
26
28
  prependUnicode?: boolean | unknown;
27
29
  metadata?: unknown;
28
30
  sort?: boolean;
31
+ ligatures?: boolean;
29
32
  addHashInFontUrl?: boolean | unknown;
33
+ unicodeRange?: boolean | string | unknown;
34
+ optimizeSvg?: boolean | unknown;
35
+ svgoConfig?: unknown;
36
+ templateFontLigatures?: boolean | unknown;
37
+ /** Alpha. SVG diagnostics and optional pre-conversion fixes. */
38
+ svgTools?: SvgToolsOptions;
30
39
  };
@@ -0,0 +1,7 @@
1
+ export type RenderedTemplate = {
2
+ /** Original template option (built-in name or custom path). */
3
+ template: string;
4
+ content: string;
5
+ /** Built-in template id when applicable (css, html, scss, …). */
6
+ builtIn?: string;
7
+ };
@@ -1,15 +1,26 @@
1
- /// <reference types="node" />
2
- import { GlyphData } from "./GlyphData";
3
- import { OptionsBase } from "./OptionsBase";
4
- export declare type Result = {
5
- config?: OptionsBase;
1
+ import { DecompressedFont } from './DecompressedFont';
2
+ import { GlyphData } from './GlyphData';
3
+ import { RenderedTemplate } from './RenderedTemplate';
4
+ import { ResultConfig } from './ResultConfig';
5
+ import { SvgGlyphDiagnostic } from './SvgToolsOptions';
6
+ import { TranscodedFont } from './TranscodedFont';
7
+ export type { DecompressedFont } from './DecompressedFont';
8
+ export type { TranscodedFont } from './TranscodedFont';
9
+ export type Result = {
10
+ config?: ResultConfig;
11
+ decompressedFonts?: DecompressedFont[];
12
+ transcodedFonts?: TranscodedFont[];
6
13
  eot?: Buffer;
7
14
  glyphsData?: Array<GlyphData>;
8
15
  hash?: string;
16
+ otf?: Buffer;
9
17
  svg?: string | Buffer;
10
18
  template?: string;
19
+ templates?: RenderedTemplate[];
11
20
  ttf?: Buffer;
12
21
  usedBuildInTemplate?: boolean;
13
22
  woff?: Buffer;
14
23
  woff2?: Buffer;
24
+ /** Alpha. Populated when `svgTools.diagnose` is enabled. */
25
+ svgDiagnostics?: SvgGlyphDiagnostic[];
15
26
  };
@@ -0,0 +1,4 @@
1
+ import { WebfontOptions } from './WebfontOptions';
2
+ export type ResultConfig = WebfontOptions & {
3
+ filePath?: string;
4
+ };
@@ -0,0 +1,13 @@
1
+ export type SvgDiagnosticCode = "evenodd-fill-rule" | "stroke-only" | "unsupported-element";
2
+ export type SvgGlyphDiagnostic = {
3
+ code: SvgDiagnosticCode;
4
+ message: string;
5
+ srcPath: string;
6
+ };
7
+ /** Alpha. SVG diagnostics for the icon-font pipeline (see ADR 0011 — no bundled stroke-to-fill fixes). */
8
+ export type SvgToolsOptions = {
9
+ /** Scan source SVGs for known icon-font incompatibilities and report warnings. */
10
+ diagnose?: boolean;
11
+ /** Optional sink for diagnostic log lines (for example a web worker or test spy). */
12
+ onMessage?: (message: string) => void;
13
+ };
@@ -0,0 +1,7 @@
1
+ export type TranscodedFont = {
2
+ source: string;
3
+ eot?: Buffer;
4
+ ttf?: Buffer;
5
+ woff?: Buffer;
6
+ woff2?: Buffer;
7
+ };
@@ -0,0 +1,11 @@
1
+ import { GlyphContentTransformFn } from './GlyphContentTransformFn';
2
+ import { GlyphInput } from './GlyphInput';
3
+ import { GlyphTransformFn } from './GlyphTransformFn';
4
+ import { MetadataProvider } from './MetadataProvider';
5
+ import { OptionsBase } from './OptionsBase';
6
+ export type WebfontFromGlyphsOptions = OptionsBase & {
7
+ glyphs: GlyphInput[];
8
+ glyphContentTransformFn?: GlyphContentTransformFn;
9
+ glyphTransformFn?: GlyphTransformFn;
10
+ metadataProvider?: MetadataProvider;
11
+ };
@@ -1,7 +1,43 @@
1
- import type { FormatsOptions } from "./Format";
2
- import type { InitialOptions } from "./InitialOptions";
1
+ import { Config as SvgoConfig } from 'svgo';
2
+ import { TemplateOption } from '../lib/parseTemplateOption';
3
+ import { Formats, FormatsOptions } from './Format';
4
+ import { GlyphContentTransformFn } from './GlyphContentTransformFn';
5
+ import { GlyphTransformFn } from './GlyphTransformFn';
6
+ import { InitialOptions } from './InitialOptions';
7
+ import { MetadataProvider } from './MetadataProvider';
8
+ import { SvgToolsOptions } from './SvgToolsOptions';
3
9
  export interface WebfontOptions extends InitialOptions {
10
+ centerHorizontally: boolean;
11
+ descent: number;
12
+ fixedWidth: boolean;
13
+ fontHeight: unknown;
14
+ fontId: unknown;
15
+ fontName: string;
16
+ fontStyle: string;
17
+ fontWeight: string;
18
+ formats: Formats;
4
19
  formatsOptions: FormatsOptions;
20
+ glyphTransformFn?: GlyphTransformFn;
21
+ glyphContentTransformFn?: GlyphContentTransformFn;
22
+ ligatures: boolean;
5
23
  maxConcurrency: number;
6
- metadataProvider: null;
24
+ metadata: unknown;
25
+ metadataProvider?: MetadataProvider;
26
+ normalize: boolean;
27
+ prependUnicode: boolean;
28
+ round: string | number;
29
+ sort: boolean;
30
+ startUnicode: number;
31
+ template?: TemplateOption;
32
+ templateCacheString?: unknown;
33
+ templateClassName?: unknown;
34
+ templateFontName?: unknown;
35
+ templateFontPath: string;
36
+ verbose: boolean;
37
+ addHashInFontUrl?: boolean;
38
+ unicodeRange?: boolean | string;
39
+ optimizeSvg?: boolean;
40
+ svgoConfig?: SvgoConfig;
41
+ templateFontLigatures?: boolean;
42
+ svgTools?: SvgToolsOptions;
7
43
  }
@@ -1,6 +1,8 @@
1
- export type { Format } from "../types/Format";
2
- export type { GlyphMetadata } from "./GlyphMetadata";
3
- export type { GlyphTransformFn } from "./GlyphTransformFn";
4
- export type { GlyphData } from "./GlyphData";
5
- export type { InitialOptions } from "./InitialOptions";
6
- export type { WebfontOptions } from "./WebfontOptions";
1
+ export type { Format, FormatsOptions } from '../types/Format';
2
+ export type { GlyphContentTransformFn } from './GlyphContentTransformFn';
3
+ export type { GlyphData } from './GlyphData';
4
+ export type { GlyphMetadata } from './GlyphMetadata';
5
+ export type { GlyphTransformFn } from './GlyphTransformFn';
6
+ export type { InitialOptions } from './InitialOptions';
7
+ export type { MetadataProvider } from './MetadataProvider';
8
+ export type { WebfontOptions } from './WebfontOptions';