diff --git a/VERSION b/VERSION index e9d5322..189554c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.35 \ No newline at end of file +0.0.36 \ No newline at end of file diff --git a/dist/js/class/FontGenerator.d.ts b/dist/js/class/FontGenerator.d.ts index 64c1576..5760fb6 100644 --- a/dist/js/class/FontGenerator.d.ts +++ b/dist/js/class/FontGenerator.d.ts @@ -1,4 +1,17 @@ declare class FontGenerator { + /** + * Configuration for the TypeScript compiler. + */ + private config; + /** + * Default configuration for the TypeScript compiler. + */ + private static defaultConfig; + /** + * Constructs an instance with merged configuration of default and custom options. + * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. + */ + constructor(customConfig?: any); generateFonts(sourceDirectory: string, outputDiectory: string): Promise; } export default FontGenerator; diff --git a/dist/js/class/FontGenerator.js b/dist/js/class/FontGenerator.js index 1657d39..ff6ca28 100644 --- a/dist/js/class/FontGenerator.js +++ b/dist/js/class/FontGenerator.js @@ -1,5 +1,8 @@ "use strict"; // class/FontGenerator.ts +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; Object.defineProperty(exports, "__esModule", { value: true }); // Copyright 2023 Scape Agency BV // Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,81 +18,32 @@ Object.defineProperty(exports, "__esModule", { value: true }); // Import // ============================================================================ var fantasticon_1 = require("fantasticon"); +var fantasticon_config_js_1 = __importDefault(require("../config/fantasticon.config.js")); // ============================================================================ // Classes // ============================================================================ class FontGenerator { + /** + * Default configuration for the TypeScript compiler. + */ + static { this.defaultConfig = fantasticon_config_js_1.default; } + // private static defaultConfig: CompilerOptions = tsConfig; + /** + * Constructs an instance with merged configuration of default and custom options. + * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. + */ + constructor(customConfig = {}) { + this.config = { + ...FontGenerator.defaultConfig, + ...customConfig + }; + } async generateFonts(sourceDirectory, outputDiectory) { const config = { + ...this.config, // RunnerMandatoryOptions inputDir: sourceDirectory, // (required) - outputDir: outputDiectory, // (required) - // RunnerOptionalOptions - name: 'icon.gl', - fontTypes: [ - fantasticon_1.FontAssetType.TTF, // TTF = "ttf" - fantasticon_1.FontAssetType.WOFF, // WOFF = "woff" - fantasticon_1.FontAssetType.WOFF2, // WOFF2 = "woff2" - fantasticon_1.FontAssetType.EOT, // EOT = "eot" - fantasticon_1.FontAssetType.SVG, // SVG = "svg" - ], - assetTypes: [ - fantasticon_1.OtherAssetType.CSS, // CSS = "css", - fantasticon_1.OtherAssetType.SCSS, // SCSS = "scss", - fantasticon_1.OtherAssetType.SASS, // SASS = "sass", - fantasticon_1.OtherAssetType.HTML, // HTML = "html", - fantasticon_1.OtherAssetType.JSON, // JSON = "json", - fantasticon_1.OtherAssetType.TS, // TS = "ts" - ], - formatOptions: { - // woff: { - // // Woff Extended Metadata Block - see https://www.w3.org/TR/WOFF/#Metadata - // metadata: '...' - // }, - // ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions; - // svg?: SvgOptions; // type SvgOptions = Omit; - json: { - indent: 4 - }, - ts: { - // select what kind of types you want to generate - // (default `['enum', 'constant', 'literalId', 'literalKey']`) - types: ['enum', 'constant', 'literalId', 'literalKey'], - // render the types with `'` instead of `"` (default is `"`) - singleQuotes: false, - // customise names used for the generated types and constants - enumName: 'icon_gl', - constantName: 'MY_CODEPOINTS' - // literalIdName: 'IconId', - // literalKeyName: 'IconKey' - } - }, - pathOptions: { - json: './dist/font/icon.gl.json', - css: './dist/font/icon.gl.css', - scss: './dist/font/icon.gl.scss', - woff: './dist/font/icon.gl.woff', - woff2: './dist/font/icon.gl.woff2' - }, - // codepoints: { - // 'chevron-left': 57344, // decimal representation of 0xe000 - // 'chevron-right': 57345, - // 'thumbs-up': 57358, - // 'thumbs-down': 57359, - // }, - // fontHeight: number; - // descent: number; - // normalize: boolean; - // round: number; - selector: '.igl', - // tag: string; - // Use our custom Handlebars templates - // templates: { - // css: './build/font/icon.gl.css.hbs', - // scss: './build/font/icon.gl.scss.hbs' - // }, - prefix: 'igl', - fontsUrl: './fonts' + outputDir: outputDiectory }; try { await (0, fantasticon_1.generateFonts)(config); diff --git a/dist/js/config/fantasticon.config.d.ts b/dist/js/config/fantasticon.config.d.ts new file mode 100644 index 0000000..c6798ab --- /dev/null +++ b/dist/js/config/fantasticon.config.d.ts @@ -0,0 +1,2 @@ +declare const fantasticonConfig: any; +export default fantasticonConfig; diff --git a/dist/js/config/fantasticon.config.js b/dist/js/config/fantasticon.config.js new file mode 100644 index 0000000..b2d6493 --- /dev/null +++ b/dist/js/config/fantasticon.config.js @@ -0,0 +1,159 @@ +"use strict"; +// config/fantasticon.config.ts +Object.defineProperty(exports, "__esModule", { value: true }); +// Copyright 2023 Scape Agency BV +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ============================================================================ +// Import +// ============================================================================ +var fantasticon_1 = require("fantasticon"); +const fantasticonConfig = { + // RunnerOptionalOptions + name: 'icon.gl', + fontTypes: [ + fantasticon_1.FontAssetType.TTF, // TTF = "ttf" + fantasticon_1.FontAssetType.WOFF, // WOFF = "woff" + fantasticon_1.FontAssetType.WOFF2, // WOFF2 = "woff2" + fantasticon_1.FontAssetType.EOT, // EOT = "eot" + fantasticon_1.FontAssetType.SVG, // SVG = "svg" + ], + assetTypes: [ + fantasticon_1.OtherAssetType.CSS, // CSS = "css", + fantasticon_1.OtherAssetType.SCSS, // SCSS = "scss", + fantasticon_1.OtherAssetType.SASS, // SASS = "sass", + fantasticon_1.OtherAssetType.HTML, // HTML = "html", + fantasticon_1.OtherAssetType.JSON, // JSON = "json", + fantasticon_1.OtherAssetType.TS, // TS = "ts" + ], + formatOptions: { + // woff: { + // // // Woff Extended Metadata Block - see https://www.w3.org/TR/WOFF/#Metadata + // // metadata: '...' + // // }, + // // ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions; + // // svg?: SvgOptions; // type SvgOptions = Omit; + json: { indent: 4 }, + ts: { + // select what kind of types you want to generate + // (default `['enum', 'constant', 'literalId', 'literalKey']`) + // render the types with `'` instead of `"` (default is `"`) + singleQuotes: false, + enumName: 'icon_gl', + // customise names used for the generated types and constants + constantName: 'MY_CODEPOINTS' + // literalIdName: 'IconId', + } + }, + pathOptions: { + json: './dist/font/icon.gl.json', + css: './dist/font/icon.gl.css', + scss: './dist/font/icon.gl.scss', + woff: './dist/font/icon.gl.woff', + woff2: './dist/font/icon.gl.woff2' + }, + // codepoints: { + // 'chevron-left': 57344, // decimal representation of 0xe000 + // 'chevron-right': 57345, + // 'thumbs-up': 57358, + // 'thumbs-down': 57359, + // }, + // fontHeight: number; + // descent: number; + // normalize: boolean; + // round: number; + selector: '.igl', + // tag: string; + // Use our custom Handlebars templates + // templates: { + // css: './build/font/icon.gl.css.hbs', + // scss: './build/font/icon.gl.scss.hbs' + // }, + prefix: 'icon', + fontsUrl: './fonts' +}; +exports.default = fantasticonConfig; +// export const fontConfig = { +// // RunnerMandatoryOptions +// inputDir: sourceDirectory, // (required) +// outputDir: outputDiectory, // (required) +// // RunnerOptionalOptions +// name: 'icon.gl', +// fontTypes: [ +// FontAssetType.TTF, // TTF = "ttf" +// FontAssetType.WOFF, // WOFF = "woff" +// FontAssetType.WOFF2, // WOFF2 = "woff2" +// FontAssetType.EOT, // EOT = "eot" +// FontAssetType.SVG, // SVG = "svg" +// ], +// assetTypes: [ +// OtherAssetType.CSS, // CSS = "css", +// OtherAssetType.SCSS, // SCSS = "scss", +// OtherAssetType.SASS, // SASS = "sass", +// OtherAssetType.HTML, // HTML = "html", +// OtherAssetType.JSON, // JSON = "json", +// OtherAssetType.TS, // TS = "ts" +// ], +// formatOptions: { +// // woff: { +// // // Woff Extended Metadata Block - see https://www.w3.org/TR/WOFF/#Metadata +// // metadata: '...' +// // }, +// // ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions; +// // svg?: SvgOptions; // type SvgOptions = Omit; +// json: { indent: 4 } , +// // ts: { +// // // select what kind of types you want to generate +// // // (default `['enum', 'constant', 'literalId', 'literalKey']`) +// // types: ['enum', 'constant', 'literalId', 'literalKey'], +// // // render the types with `'` instead of `"` (default is `"`) +// // singleQuotes: false, +// // // customise names used for the generated types and constants +// // enumName: 'icon_gl', +// // constantName: 'MY_CODEPOINTS' +// // // literalIdName: 'IconId', +// // // literalKeyName: 'IconKey' +// // } +// }, +// pathOptions: { +// json: './dist/font/icon.gl.json', +// css: './dist/font/icon.gl.css', +// scss: './dist/font/icon.gl.scss', +// woff: './dist/font/icon.gl.woff', +// woff2: './dist/font/icon.gl.woff2', +// }, +// // codepoints: { +// // 'chevron-left': 57344, // decimal representation of 0xe000 +// // 'chevron-right': 57345, +// // 'thumbs-up': 57358, +// // 'thumbs-down': 57359, +// // }, +// // fontHeight: number; +// // descent: number; +// // normalize: boolean; +// // round: number; +// selector: '.igl', +// // tag: string; +// // Use our custom Handlebars templates +// // templates: { +// // css: './build/font/icon.gl.css.hbs', +// // scss: './build/font/icon.gl.scss.hbs' +// // }, +// prefix: 'igl', +// fontsUrl: './fonts', +// // Customize generated icon IDs (unavailable with `.json` config file) +// // getIconId: ({ +// // basename, // `string` - Example: 'foo'; +// // relativeDirPath, // `string` - Example: 'sub/dir/foo.svg' +// // absoluteFilePath, // `string` - Example: '/var/icons/sub/dir/foo.svg' +// // relativeFilePath, // `string` - Example: 'foo.svg' +// // index // `number` - Example: `0` +// // }) => [index, basename].join('_') // '0_foo' +// }; diff --git a/dist/package.json b/dist/package.json index ba3f571..a42b063 100644 --- a/dist/package.json +++ b/dist/package.json @@ -1,6 +1,6 @@ { "name": "pack.gl", - "version": "0.0.35", + "version": "0.0.36", "description": "Package Builder.", "keywords": [ "pack.gl", diff --git a/dist/ts/class/FontGenerator.ts b/dist/ts/class/FontGenerator.ts index e840e0e..d7b24f5 100644 --- a/dist/ts/class/FontGenerator.ts +++ b/dist/ts/class/FontGenerator.ts @@ -19,7 +19,9 @@ // Import // ============================================================================ -import { generateFonts, FontAssetType, OtherAssetType } from 'fantasticon'; +import { generateFonts, FontAssetType, OtherAssetType, RunnerOptions, } from 'fantasticon'; +import RunnerOptionalOptions from 'fantasticon'; +import fantasticonConfig from "../config/fantasticon.config.js" // ============================================================================ @@ -28,102 +30,59 @@ import { generateFonts, FontAssetType, OtherAssetType } from 'fantasticon'; class FontGenerator { + /** + * Configuration for the TypeScript compiler. + */ + private config: any; + + /** + * Default configuration for the TypeScript compiler. + */ + private static defaultConfig: any = fantasticonConfig; + // private static defaultConfig: CompilerOptions = tsConfig; + + /** + * Constructs an instance with merged configuration of default and custom options. + * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. + */ + constructor( + customConfig: any = {}, + ) { + this.config = { + ...FontGenerator.defaultConfig, + ...customConfig + }; + } + + + + + async generateFonts( sourceDirectory: string, outputDiectory: string, ) { - const config = { + const config: RunnerOptions = { + + ...this.config, // RunnerMandatoryOptions inputDir: sourceDirectory, // (required) outputDir: outputDiectory, // (required) - // RunnerOptionalOptions - name: 'icon.gl', - fontTypes: [ - FontAssetType.TTF, // TTF = "ttf" - FontAssetType.WOFF, // WOFF = "woff" - FontAssetType.WOFF2, // WOFF2 = "woff2" - FontAssetType.EOT, // EOT = "eot" - FontAssetType.SVG, // SVG = "svg" - ], - assetTypes: [ - OtherAssetType.CSS, // CSS = "css", - OtherAssetType.SCSS, // SCSS = "scss", - OtherAssetType.SASS, // SASS = "sass", - OtherAssetType.HTML, // HTML = "html", - OtherAssetType.JSON, // JSON = "json", - OtherAssetType.TS, // TS = "ts" - ], - - formatOptions: { - // woff: { - // // Woff Extended Metadata Block - see https://www.w3.org/TR/WOFF/#Metadata - // metadata: '...' - // }, - // ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions; - // svg?: SvgOptions; // type SvgOptions = Omit; - json: { - indent: 4 - }, - ts: { - // select what kind of types you want to generate - // (default `['enum', 'constant', 'literalId', 'literalKey']`) - types: ['enum', 'constant', 'literalId', 'literalKey'], - // render the types with `'` instead of `"` (default is `"`) - singleQuotes: false, - // customise names used for the generated types and constants - enumName: 'icon_gl', - constantName: 'MY_CODEPOINTS' - // literalIdName: 'IconId', - // literalKeyName: 'IconKey' - } - }, - pathOptions: { - json: './dist/font/icon.gl.json', - css: './dist/font/icon.gl.css', - scss: './dist/font/icon.gl.scss', - woff: './dist/font/icon.gl.woff', - woff2: './dist/font/icon.gl.woff2', - }, - // codepoints: { - // 'chevron-left': 57344, // decimal representation of 0xe000 - // 'chevron-right': 57345, - // 'thumbs-up': 57358, - // 'thumbs-down': 57359, - // }, - // fontHeight: number; - // descent: number; - // normalize: boolean; - // round: number; - selector: '.igl', - // tag: string; - // Use our custom Handlebars templates - // templates: { - // css: './build/font/icon.gl.css.hbs', - // scss: './build/font/icon.gl.scss.hbs' - // }, - prefix: 'igl', - fontsUrl: './fonts', - - // Customize generated icon IDs (unavailable with `.json` config file) - // getIconId: ({ - // basename, // `string` - Example: 'foo'; - // relativeDirPath, // `string` - Example: 'sub/dir/foo.svg' - // absoluteFilePath, // `string` - Example: '/var/icons/sub/dir/foo.svg' - // relativeFilePath, // `string` - Example: 'foo.svg' - // index // `number` - Example: `0` - // }) => [index, basename].join('_') // '0_foo' }; + + try { await generateFonts(config); console.log('Fonts generated successfully.'); } catch (error) { console.error('Error generating fonts:', error); } + } } diff --git a/dist/ts/config/fantasticon.config.ts b/dist/ts/config/fantasticon.config.ts index 36dbcb7..97f3c53 100644 --- a/dist/ts/config/fantasticon.config.ts +++ b/dist/ts/config/fantasticon.config.ts @@ -19,7 +19,108 @@ // Import // ============================================================================ -import { generateFonts, FontAssetType, OtherAssetType } from 'fantasticon'; + +import { generateFonts, FontAssetType, OtherAssetType, RunnerOptions, } from 'fantasticon'; +import RunnerOptionalOptions from 'fantasticon'; + + +const fantasticonConfig: any = { + + // RunnerOptionalOptions + name: 'icon.gl', + fontTypes: [ + FontAssetType.TTF, // TTF = "ttf" + FontAssetType.WOFF, // WOFF = "woff" + FontAssetType.WOFF2, // WOFF2 = "woff2" + FontAssetType.EOT, // EOT = "eot" + FontAssetType.SVG, // SVG = "svg" + ], + assetTypes: [ + OtherAssetType.CSS, // CSS = "css", + OtherAssetType.SCSS, // SCSS = "scss", + OtherAssetType.SASS, // SASS = "sass", + OtherAssetType.HTML, // HTML = "html", + OtherAssetType.JSON, // JSON = "json", + OtherAssetType.TS, // TS = "ts" + ], + formatOptions: { + // woff: { + // // // Woff Extended Metadata Block - see https://www.w3.org/TR/WOFF/#Metadata + // // metadata: '...' + // // }, + // // ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions; + // // svg?: SvgOptions; // type SvgOptions = Omit; + + json: { indent: 4 } , + ts: { + // select what kind of types you want to generate + // (default `['enum', 'constant', 'literalId', 'literalKey']`) + // render the types with `'` instead of `"` (default is `"`) + singleQuotes: false, + enumName: 'icon_gl', + // customise names used for the generated types and constants + constantName: 'MY_CODEPOINTS' + // literalIdName: 'IconId', + + } + + }, + pathOptions: { + json: './dist/font/icon.gl.json', + css: './dist/font/icon.gl.css', + scss: './dist/font/icon.gl.scss', + woff: './dist/font/icon.gl.woff', + woff2: './dist/font/icon.gl.woff2', + }, + // codepoints: { + // 'chevron-left': 57344, // decimal representation of 0xe000 + // 'chevron-right': 57345, + // 'thumbs-up': 57358, + // 'thumbs-down': 57359, + // }, + // fontHeight: number; + // descent: number; + // normalize: boolean; + // round: number; + selector: '.igl', + // tag: string; + // Use our custom Handlebars templates + // templates: { + // css: './build/font/icon.gl.css.hbs', + // scss: './build/font/icon.gl.scss.hbs' + // }, + prefix: 'icon', + fontsUrl: './fonts', + + // Customize generated icon IDs (unavailable with `.json` config file) + // getIconId: ({ + // basename, // `string` - Example: 'foo'; + // relativeDirPath, // `string` - Example: 'sub/dir/foo.svg' + // absoluteFilePath, // `string` - Example: '/var/icons/sub/dir/foo.svg' + // relativeFilePath, // `string` - Example: 'foo.svg' + // index // `number` - Example: `0` + // }) => [index, basename].join('_') // '0_foo' + +}; + + + +export default fantasticonConfig; + + + + + + + + + + + + + + + // export const fontConfig = { diff --git a/dist/ts/index.ts b/dist/ts/index.ts index 03d1814..d91ebfb 100644 --- a/dist/ts/index.ts +++ b/dist/ts/index.ts @@ -45,7 +45,6 @@ import SvgSpriteGenerator from "./class/SvgSpriteGenerator.js"; import SvgPackager from "./class/SvgPackager.js"; - // Import | Internal Functions import gl_installer from './function/gl_installer'; import cleanDirectory from './function/clean_directory'; diff --git a/dist/ts/interface/SVG.ts b/dist/ts/interface/SVG.ts index 37e1c34..f5b948e 100644 --- a/dist/ts/interface/SVG.ts +++ b/dist/ts/interface/SVG.ts @@ -20,13 +20,12 @@ // ============================================================================ - // Assuming the structure of your SVG object, you might need to adjust these types export interface Svg { - metadata: { - name: string; - // ... other metadata properties - }; - source: string; - // ... other Svg properties + metadata: { + name: string; + // ... other metadata properties + }; + source: string; + // ... other Svg properties } \ No newline at end of file diff --git a/package.json b/package.json index e534b08..cd0ea12 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "pack.gl", "description": "Package Builder.", - "version": "0.0.35", + "version": "0.0.36", "config": { "version_short": "0.0" }, diff --git a/src/ts/class/FontGenerator.ts b/src/ts/class/FontGenerator.ts index e840e0e..d7b24f5 100644 --- a/src/ts/class/FontGenerator.ts +++ b/src/ts/class/FontGenerator.ts @@ -19,7 +19,9 @@ // Import // ============================================================================ -import { generateFonts, FontAssetType, OtherAssetType } from 'fantasticon'; +import { generateFonts, FontAssetType, OtherAssetType, RunnerOptions, } from 'fantasticon'; +import RunnerOptionalOptions from 'fantasticon'; +import fantasticonConfig from "../config/fantasticon.config.js" // ============================================================================ @@ -28,102 +30,59 @@ import { generateFonts, FontAssetType, OtherAssetType } from 'fantasticon'; class FontGenerator { + /** + * Configuration for the TypeScript compiler. + */ + private config: any; + + /** + * Default configuration for the TypeScript compiler. + */ + private static defaultConfig: any = fantasticonConfig; + // private static defaultConfig: CompilerOptions = tsConfig; + + /** + * Constructs an instance with merged configuration of default and custom options. + * @param {svgSprite.Config} customConfig - Optional custom configuration object for svg-sprite. + */ + constructor( + customConfig: any = {}, + ) { + this.config = { + ...FontGenerator.defaultConfig, + ...customConfig + }; + } + + + + + async generateFonts( sourceDirectory: string, outputDiectory: string, ) { - const config = { + const config: RunnerOptions = { + + ...this.config, // RunnerMandatoryOptions inputDir: sourceDirectory, // (required) outputDir: outputDiectory, // (required) - // RunnerOptionalOptions - name: 'icon.gl', - fontTypes: [ - FontAssetType.TTF, // TTF = "ttf" - FontAssetType.WOFF, // WOFF = "woff" - FontAssetType.WOFF2, // WOFF2 = "woff2" - FontAssetType.EOT, // EOT = "eot" - FontAssetType.SVG, // SVG = "svg" - ], - assetTypes: [ - OtherAssetType.CSS, // CSS = "css", - OtherAssetType.SCSS, // SCSS = "scss", - OtherAssetType.SASS, // SASS = "sass", - OtherAssetType.HTML, // HTML = "html", - OtherAssetType.JSON, // JSON = "json", - OtherAssetType.TS, // TS = "ts" - ], - - formatOptions: { - // woff: { - // // Woff Extended Metadata Block - see https://www.w3.org/TR/WOFF/#Metadata - // metadata: '...' - // }, - // ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions; - // svg?: SvgOptions; // type SvgOptions = Omit; - json: { - indent: 4 - }, - ts: { - // select what kind of types you want to generate - // (default `['enum', 'constant', 'literalId', 'literalKey']`) - types: ['enum', 'constant', 'literalId', 'literalKey'], - // render the types with `'` instead of `"` (default is `"`) - singleQuotes: false, - // customise names used for the generated types and constants - enumName: 'icon_gl', - constantName: 'MY_CODEPOINTS' - // literalIdName: 'IconId', - // literalKeyName: 'IconKey' - } - }, - pathOptions: { - json: './dist/font/icon.gl.json', - css: './dist/font/icon.gl.css', - scss: './dist/font/icon.gl.scss', - woff: './dist/font/icon.gl.woff', - woff2: './dist/font/icon.gl.woff2', - }, - // codepoints: { - // 'chevron-left': 57344, // decimal representation of 0xe000 - // 'chevron-right': 57345, - // 'thumbs-up': 57358, - // 'thumbs-down': 57359, - // }, - // fontHeight: number; - // descent: number; - // normalize: boolean; - // round: number; - selector: '.igl', - // tag: string; - // Use our custom Handlebars templates - // templates: { - // css: './build/font/icon.gl.css.hbs', - // scss: './build/font/icon.gl.scss.hbs' - // }, - prefix: 'igl', - fontsUrl: './fonts', - - // Customize generated icon IDs (unavailable with `.json` config file) - // getIconId: ({ - // basename, // `string` - Example: 'foo'; - // relativeDirPath, // `string` - Example: 'sub/dir/foo.svg' - // absoluteFilePath, // `string` - Example: '/var/icons/sub/dir/foo.svg' - // relativeFilePath, // `string` - Example: 'foo.svg' - // index // `number` - Example: `0` - // }) => [index, basename].join('_') // '0_foo' }; + + try { await generateFonts(config); console.log('Fonts generated successfully.'); } catch (error) { console.error('Error generating fonts:', error); } + } } diff --git a/src/ts/config/fantasticon.config.ts b/src/ts/config/fantasticon.config.ts index 36dbcb7..97f3c53 100644 --- a/src/ts/config/fantasticon.config.ts +++ b/src/ts/config/fantasticon.config.ts @@ -19,7 +19,108 @@ // Import // ============================================================================ -import { generateFonts, FontAssetType, OtherAssetType } from 'fantasticon'; + +import { generateFonts, FontAssetType, OtherAssetType, RunnerOptions, } from 'fantasticon'; +import RunnerOptionalOptions from 'fantasticon'; + + +const fantasticonConfig: any = { + + // RunnerOptionalOptions + name: 'icon.gl', + fontTypes: [ + FontAssetType.TTF, // TTF = "ttf" + FontAssetType.WOFF, // WOFF = "woff" + FontAssetType.WOFF2, // WOFF2 = "woff2" + FontAssetType.EOT, // EOT = "eot" + FontAssetType.SVG, // SVG = "svg" + ], + assetTypes: [ + OtherAssetType.CSS, // CSS = "css", + OtherAssetType.SCSS, // SCSS = "scss", + OtherAssetType.SASS, // SASS = "sass", + OtherAssetType.HTML, // HTML = "html", + OtherAssetType.JSON, // JSON = "json", + OtherAssetType.TS, // TS = "ts" + ], + formatOptions: { + // woff: { + // // // Woff Extended Metadata Block - see https://www.w3.org/TR/WOFF/#Metadata + // // metadata: '...' + // // }, + // // ttf?: TtfOptions; // type TtfOptions = svg2ttf.FontOptions; + // // svg?: SvgOptions; // type SvgOptions = Omit; + + json: { indent: 4 } , + ts: { + // select what kind of types you want to generate + // (default `['enum', 'constant', 'literalId', 'literalKey']`) + // render the types with `'` instead of `"` (default is `"`) + singleQuotes: false, + enumName: 'icon_gl', + // customise names used for the generated types and constants + constantName: 'MY_CODEPOINTS' + // literalIdName: 'IconId', + + } + + }, + pathOptions: { + json: './dist/font/icon.gl.json', + css: './dist/font/icon.gl.css', + scss: './dist/font/icon.gl.scss', + woff: './dist/font/icon.gl.woff', + woff2: './dist/font/icon.gl.woff2', + }, + // codepoints: { + // 'chevron-left': 57344, // decimal representation of 0xe000 + // 'chevron-right': 57345, + // 'thumbs-up': 57358, + // 'thumbs-down': 57359, + // }, + // fontHeight: number; + // descent: number; + // normalize: boolean; + // round: number; + selector: '.igl', + // tag: string; + // Use our custom Handlebars templates + // templates: { + // css: './build/font/icon.gl.css.hbs', + // scss: './build/font/icon.gl.scss.hbs' + // }, + prefix: 'icon', + fontsUrl: './fonts', + + // Customize generated icon IDs (unavailable with `.json` config file) + // getIconId: ({ + // basename, // `string` - Example: 'foo'; + // relativeDirPath, // `string` - Example: 'sub/dir/foo.svg' + // absoluteFilePath, // `string` - Example: '/var/icons/sub/dir/foo.svg' + // relativeFilePath, // `string` - Example: 'foo.svg' + // index // `number` - Example: `0` + // }) => [index, basename].join('_') // '0_foo' + +}; + + + +export default fantasticonConfig; + + + + + + + + + + + + + + + // export const fontConfig = { diff --git a/src/ts/index.ts b/src/ts/index.ts index 03d1814..d91ebfb 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -45,7 +45,6 @@ import SvgSpriteGenerator from "./class/SvgSpriteGenerator.js"; import SvgPackager from "./class/SvgPackager.js"; - // Import | Internal Functions import gl_installer from './function/gl_installer'; import cleanDirectory from './function/clean_directory'; diff --git a/src/ts/interface/SVG.ts b/src/ts/interface/SVG.ts index 37e1c34..f5b948e 100644 --- a/src/ts/interface/SVG.ts +++ b/src/ts/interface/SVG.ts @@ -20,13 +20,12 @@ // ============================================================================ - // Assuming the structure of your SVG object, you might need to adjust these types export interface Svg { - metadata: { - name: string; - // ... other metadata properties - }; - source: string; - // ... other Svg properties + metadata: { + name: string; + // ... other metadata properties + }; + source: string; + // ... other Svg properties } \ No newline at end of file