Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support XML fonts in Webworker #8904

Merged
merged 1 commit into from Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions bundles/pixi.js-node/package.json
Expand Up @@ -67,11 +67,10 @@
"@pixi/text": "7.1.0-alpha",
"@pixi/text-bitmap": "7.1.0-alpha",
"@types/gl": "^6.0.2",
"@types/xml2js": "^0.4.11",
"@xmldom/xmldom": "^0.8.6",
"canvas": "^2.9.1",
"cross-fetch": "^3.1.5",
"gl": "^6.0.1",
"xml2js": "^0.4.23"
"gl": "^6.0.1"
},
"nodeDependencies": [
"fs",
Expand Down
7 changes: 7 additions & 0 deletions bundles/pixi.js-node/src/adapter/adapter.ts
Expand Up @@ -3,6 +3,7 @@ import fs from 'fs';
import { WebGLRenderingContext } from 'gl';
import { settings, utils } from '@pixi/core';
import { NodeCanvasElement } from './NodeCanvasElement';
import { DOMParser } from '@xmldom/xmldom';

import type { IAdapter } from '@pixi/core';

Expand Down Expand Up @@ -53,6 +54,12 @@ export const NodeAdapter = {
});
});
},
parseXML: (xml: string) =>
{
const parser = new DOMParser();

return parser.parseFromString(xml, 'text/xml');
},
} as IAdapter;

settings.ADAPTER = NodeAdapter;
Expand Down
1 change: 0 additions & 1 deletion bundles/pixi.js-node/src/adapter/index.ts
Expand Up @@ -2,7 +2,6 @@ import './polyfills';

export * from './NodeCanvasElement';
export * from './NodeCanvasResource';
export * from './loadNodeBitmapFont';
export * from './loadNodeFont';
export * from './loadNodeTexture';
export * from './loadNodeBase64';
Expand Down
197 changes: 0 additions & 197 deletions bundles/pixi.js-node/src/adapter/loadNodeBitmapFont.ts

This file was deleted.

2 changes: 0 additions & 2 deletions bundles/pixi.js-node/src/index.ts
Expand Up @@ -14,13 +14,11 @@ import '@pixi/mixin-get-global-position';
import { NodeCanvasResource } from './adapter';
import { loadTextures, loadWebFont } from '@pixi/assets';
import { ResizePlugin } from '@pixi/app';
import { loadBitmapFont } from '@pixi/text-bitmap';

// Remove the default loader plugins
extensions.remove(
loadTextures,
loadWebFont,
loadBitmapFont,
ResizePlugin
);

Expand Down
3 changes: 2 additions & 1 deletion bundles/pixi.js-webworker/package.json
Expand Up @@ -62,7 +62,8 @@
"@pixi/sprite-tiling": "7.1.0-alpha",
"@pixi/spritesheet": "7.1.0-alpha",
"@pixi/text": "7.1.0-alpha",
"@pixi/text-bitmap": "7.1.0-alpha"
"@pixi/text-bitmap": "7.1.0-alpha",
"@xmldom/xmldom": "^0.8.6"
},
"publishConfig": {
"access": "public"
Expand Down
8 changes: 8 additions & 0 deletions bundles/pixi.js-webworker/src/adapter.ts
@@ -1,4 +1,5 @@
import { settings } from '@pixi/core';
import { DOMParser } from '@xmldom/xmldom';

import type { IAdapter } from '@pixi/core';

Expand All @@ -15,6 +16,13 @@ export const WebWorkerAdapter = {
getBaseUrl: () => globalThis.location.href,
getFontFaceSet: () => (globalThis as unknown as WorkerGlobalScope).fonts,
fetch: (url: RequestInfo, options?: RequestInit) => fetch(url, options),
parseXML: (xml: string) =>
{
const parser = new DOMParser();

return parser.parseFromString(xml, 'text/xml');
},

} as IAdapter;

settings.ADAPTER = WebWorkerAdapter;
Expand Down