Feat/embedded fonts (#2174)
* #239 Embedded fonts * Add boilerplate for font table * Fix linting * Fix linting * Fix odttf naming * Correct writing of fonts to relationships and font table new uuid function * Add font to run * Add demo Fix tests * Add character set support * Add tests * Write tests
This commit is contained in:
@ -1,6 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { convertInchesToTwip, convertMillimetersToTwip, uniqueId, uniqueNumericIdCreator } from "./convenience-functions";
|
||||
import {
|
||||
abstractNumUniqueNumericIdGen,
|
||||
bookmarkUniqueNumericIdGen,
|
||||
concreteNumUniqueNumericIdGen,
|
||||
convertInchesToTwip,
|
||||
convertMillimetersToTwip,
|
||||
docPropertiesUniqueNumericIdGen,
|
||||
uniqueId,
|
||||
uniqueNumericIdCreator,
|
||||
uniqueUuid,
|
||||
} from "./convenience-functions";
|
||||
|
||||
describe("Utility", () => {
|
||||
describe("#convertMillimetersToTwip", () => {
|
||||
@ -24,9 +34,47 @@ describe("Utility", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("#abstractNumUniqueNumericIdGen", () => {
|
||||
it("should generate a unique incrementing ID", () => {
|
||||
const uniqueNumericId = abstractNumUniqueNumericIdGen();
|
||||
expect(uniqueNumericId()).to.equal(1);
|
||||
expect(uniqueNumericId()).to.equal(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#concreteNumUniqueNumericIdGen", () => {
|
||||
it("should generate a unique incrementing ID", () => {
|
||||
const uniqueNumericId = concreteNumUniqueNumericIdGen();
|
||||
expect(uniqueNumericId()).to.equal(2);
|
||||
expect(uniqueNumericId()).to.equal(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#docPropertiesUniqueNumericIdGen", () => {
|
||||
it("should generate a unique incrementing ID", () => {
|
||||
const uniqueNumericId = docPropertiesUniqueNumericIdGen();
|
||||
expect(uniqueNumericId()).to.equal(1);
|
||||
expect(uniqueNumericId()).to.equal(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#bookmarkUniqueNumericIdGen", () => {
|
||||
it("should generate a unique incrementing ID", () => {
|
||||
const uniqueNumericId = bookmarkUniqueNumericIdGen();
|
||||
expect(uniqueNumericId()).to.equal(1);
|
||||
expect(uniqueNumericId()).to.equal(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#uniqueId", () => {
|
||||
it("should generate a unique pseudorandom ID", () => {
|
||||
expect(uniqueId()).to.not.be.empty;
|
||||
});
|
||||
});
|
||||
|
||||
describe("#uniqueUuid", () => {
|
||||
it("should generate a unique pseudorandom ID", () => {
|
||||
expect(uniqueUuid()).to.not.be.empty;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { nanoid } from "nanoid/non-secure";
|
||||
import { nanoid, customAlphabet } from "nanoid/non-secure";
|
||||
|
||||
// Twip - twentieths of a point
|
||||
export const convertMillimetersToTwip = (millimeters: number): number => Math.floor((millimeters / 25.4) * 72 * 20);
|
||||
@ -23,3 +23,7 @@ export const docPropertiesUniqueNumericIdGen = (): UniqueNumericIdCreator => uni
|
||||
export const bookmarkUniqueNumericIdGen = (): UniqueNumericIdCreator => uniqueNumericIdCreator();
|
||||
|
||||
export const uniqueId = (): string => nanoid().toLowerCase();
|
||||
|
||||
const generateUuidPart = (count: number): string => customAlphabet("1234567890abcdef", count)();
|
||||
export const uniqueUuid = (): string =>
|
||||
`${generateUuidPart(8)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(12)}`;
|
||||
|
Reference in New Issue
Block a user