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

Can't use icon contributed using TTF file #194506

Merged
merged 1 commit into from
Sep 29, 2023
Merged
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
13 changes: 10 additions & 3 deletions src/vs/workbench/services/themes/common/iconExtensionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ export class IconExtensionPoint {
if (typeof defaultIcon === 'string') {
iconRegistry.registerIcon(id, { id: defaultIcon }, iconContribution.description);
} else if (typeof defaultIcon === 'object' && typeof defaultIcon.fontPath === 'string' && typeof defaultIcon.fontCharacter === 'string') {
const format = extname(defaultIcon.fontPath).substring(1);
if (['woff', 'woff2', 'ttf'].indexOf(format) === -1) {
collector.warn(nls.localize('invalid.icons.default.fontPath.extension', "Expected `contributes.icons.default.fontPath` to have file extension 'woff', woff2' or 'ttf', is '{0}'.", format));
const fileExt = extname(defaultIcon.fontPath).substring(1);
const format = formatMap[fileExt];
if (!format) {
collector.warn(nls.localize('invalid.icons.default.fontPath.extension', "Expected `contributes.icons.default.fontPath` to have file extension 'woff', woff2' or 'ttf', is '{0}'.", fileExt));
return;
}
const extensionLocation = extension.description.extensionLocation;
Expand Down Expand Up @@ -132,6 +133,12 @@ export class IconExtensionPoint {
}
}

const formatMap: Record<string, string> = {
'ttf': 'truetype',
'woff': 'woff',
'woff2': 'woff2'
};

function getFontId(description: IExtensionDescription, fontPath: string) {
return posix.join(description.identifier.value, fontPath);
}