Skip to content

Commit

Permalink
Use product icons instead of 'hardcoded' icons
Browse files Browse the repository at this point in the history
- Add a product icon font instead of icons that are unchangable by product icon themes
- Add a script using FontForge scripting API for generating product icon font for future use
- Remove redundant icons that are already part of codicons
  • Loading branch information
DeltaRazero committed Oct 9, 2024
1 parent 1fe1278 commit 5a6db88
Show file tree
Hide file tree
Showing 22 changed files with 484 additions and 172 deletions.
133 changes: 79 additions & 54 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,69 @@
],
"main": "./dist/main",
"contributes": {
"languages": [
{
"id": "cmake",
"extensions": [
".cmake"
],
"filenames": ["CMakeLists.txt"],
"aliases": [
"CMake"
]
},
{
"id": "cmake-cache",
"filenames": ["CMakeCache.txt"],
"aliases": [
"CMake Cache"
]
}
],
"icons": {
"cmake-tools-build": {
"description": "CMake build icon",
"default": {
"fontPath": "./res/product-icons.woff2",
"fontCharacter": "\\E001"
}
},
"cmake-tools-clean-configure": {
"description": "CMake clean configure icon",
"default": {
"fontPath": "./res/product-icons.woff2",
"fontCharacter": "\\E002"
}
},
"cmake-tools-clean": {
"description": "CMake clean icon",
"default": {
"fontPath": "./res/product-icons.woff2",
"fontCharacter": "\\E003"
}
},
"cmake-tools-cmake-view-1": {
"description": "CMake view icon 1",
"default": {
"fontPath": "./res/product-icons.woff2",
"fontCharacter": "\\E004"
}
},
"cmake-tools-cmake-view-2": {
"description": "CMake view icon 2",
"default": {
"fontPath": "./res/product-icons.woff2",
"fontCharacter": "\\E005"
}
},
"cmake-tools-configure": {
"description": "CMake configure icon",
"default": {
"fontPath": "./res/product-icons.woff2",
"fontCharacter": "\\E006"
}
}
},
"commands": [
{
"command": "cmake.openCMakePresets",
Expand Down Expand Up @@ -299,18 +362,12 @@
{
"command": "cmake.outline.configure",
"title": "%cmake-tools.command.cmake.configure.title%",
"icon": {
"dark": "res/dark/configure-icon.svg",
"light": "res/light/configure-icon.svg"
}
"icon": "$(cmake-tools-configure)"
},
{
"command": "cmake.projectStatus.configure",
"title": "%cmake-tools.command.cmake.configure.title%",
"icon": {
"dark": "res/dark/configure-icon.svg",
"light": "res/light/configure-icon.svg"
},
"icon": "$(cmake-tools-configure)",
"when": "cmake:enableFullFeatureSet",
"category": "CMake"
},
Expand Down Expand Up @@ -339,10 +396,7 @@
{
"command": "cmake.outline.configureAll",
"title": "%cmake-tools.command.cmake.configureAll.title%",
"icon": {
"dark": "res/dark/configure-icon.svg",
"light": "res/light/configure-icon.svg"
}
"icon": "$(cmake-tools-configure)"
},
{
"command": "cmake.outline.configureAllWithDebugger",
Expand All @@ -360,28 +414,19 @@
"command": "cmake.outline.build",
"title": "%cmake-tools.command.cmake.build.title%",
"when": "cmake:enableFullFeatureSet",
"icon": {
"dark": "res/dark/build-icon.svg",
"light": "res/light/build-icon.svg"
}
"icon": "$(cmake-tools-build)"
},
{
"command": "cmake.projectStatus.build",
"title": "%cmake-tools.command.cmake.build.title%",
"when": "cmake:enableFullFeatureSet",
"icon": {
"dark": "res/dark/build-icon.svg",
"light": "res/light/build-icon.svg"
}
"icon": "$(cmake-tools-build)"
},
{
"command": "cmake.outline.buildTarget",
"title": "%cmake-tools.command.cmake.build.title%",
"when": "cmake:enableFullFeatureSet",
"icon": {
"dark": "res/dark/build-icon.svg",
"light": "res/light/build-icon.svg"
}
"icon": "$(cmake-tools-build)"
},
{
"command": "cmake.showBuildCommand",
Expand All @@ -399,29 +444,20 @@
"command": "cmake.outline.buildAll",
"title": "%cmake-tools.command.cmake.buildAll.title%",
"when": "cmake:enableFullFeatureSet",
"icon": {
"dark": "res/dark/build-icon.svg",
"light": "res/light/build-icon.svg"
}
"icon": "$(cmake-tools-build)"
},
{
"command": "cmake.compileFile",
"title": "%cmake-tools.command.cmake.compileFile.title%",
"category": "CMake",
"when": "cmake:enableFullFeatureSet",
"icon": {
"dark": "res/dark/build-icon.svg",
"light": "res/light/build-icon.svg"
}
"icon": "$(cmake-tools-build)"
},
{
"command": "cmake.outline.compileFile",
"title": "%cmake-tools.command.cmake.outline.compileFile.title%",
"when": "cmake:enableFullFeatureSet",
"icon": {
"dark": "res/dark/build-icon.svg",
"light": "res/light/build-icon.svg"
}
"icon": "$(cmake-tools-build)"
},
{
"command": "cmake.install",
Expand Down Expand Up @@ -473,30 +509,21 @@
"title": "%cmake-tools.command.cmake.projectStatus.cleanConfigure.title%",
"when": "cmake:enableFullFeatureSet",
"category": "CMake",
"icon": {
"dark": "res/dark/clean-configure-icon.svg",
"light": "res/light/clean-configure-icon.svg"
}
"icon": "$(cmake-tools-clean-configure)"
},
{
"command": "cmake.projectStatus.openSettings",
"title": "%cmake-tools.command.cmake.openSettings.title%",
"when": "cmake:enableFullFeatureSet",
"category": "CMake",
"icon": {
"dark": "res/dark/settings-icon.svg",
"light": "res/light/settings-icon.svg"
}
"icon": "$(settings-gear)"
},
{
"command": "cmake.projectStatus.openVisibilitySettings",
"title": "%cmake-tools.command.cmake.projectStatus.openVisibilitySettings.title%",
"when": "cmake:enabelFullFeatureSet",
"category": "CMake",
"icon": {
"dark": "res/dark/json-icon.svg",
"light": "res/light/json-icon.svg"
}
"icon": "$(json)"
},
{
"command": "cmake.cleanConfigureWithDebugger",
Expand Down Expand Up @@ -539,10 +566,7 @@
"command": "cmake.outline.clean",
"when": "cmake:enableFullFeatureSet",
"title": "%cmake-tools.command.cmake.clean.title%",
"icon": {
"dark": "res/dark/clean-icon.svg",
"light": "res/light/clean-icon.svg"
}
"icon": "$(cmake-tools-clean)"
},
{
"command": "cmake.cleanAll",
Expand Down Expand Up @@ -3614,7 +3638,7 @@
{
"id": "cmake-view",
"title": "CMake",
"icon": "res/cmake-view-icon2.svg",
"icon": "$(cmake-tools-cmake-view-2)",
"when": "cmake:enableFullFeatureSet"
}
]
Expand Down Expand Up @@ -3693,7 +3717,8 @@
"extensionTestsSuccessfulBuild": "yarn run pretest && node ./out/test/extension-tests/successful-build/runTest.js",
"extensionTestsSingleRoot": "yarn run pretest && node ./out/test/extension-tests/single-root-UI/runTest.js",
"extensionTestsMultiRoot": "yarn run pretest && node ./out/test/extension-tests/multi-root-UI/runTest.js",
"backendTests": "node ./node_modules/mocha/bin/_mocha -u tdd --timeout 999999 --colors -r ts-node/register -r tsconfig-paths/register ./test/backend-unit-tests/**/*.test.ts"
"backendTests": "node ./node_modules/mocha/bin/_mocha -u tdd --timeout 999999 --colors -r ts-node/register -r tsconfig-paths/register ./test/backend-unit-tests/**/*.test.ts",
"build-product-icon-font": "yarn --cwd ./tools/product-icon-font-generator/ install && yarn --cwd ./tools/product-icon-font-generator/ build && node ./tools/product-icon-font-generator/dist/index.js --source-directory ./res/product-icons/ --output-directory ./res/ --woff2"
},
"devDependencies": {
"@octokit/rest": "^18.1.1",
Expand Down
8 changes: 0 additions & 8 deletions res/dark/build-icon.svg

This file was deleted.

27 changes: 0 additions & 27 deletions res/dark/clean-configure-icon.svg

This file was deleted.

39 changes: 0 additions & 39 deletions res/dark/clean-icon.svg

This file was deleted.

4 changes: 0 additions & 4 deletions res/dark/configure-icon.svg

This file was deleted.

4 changes: 0 additions & 4 deletions res/dark/json-icon.svg

This file was deleted.

12 changes: 0 additions & 12 deletions res/dark/settings-icon.svg

This file was deleted.

17 changes: 17 additions & 0 deletions res/generate_product_icon_font.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# FontForge script to generate a product icon font.
# SVG icons are imported recursively; filenames must start with a 4-digit hexadecimal glyph codepoint followed by an underscore
# Invoke by calling `fontforge -script <path_to_this_file>.py`

import fontforge
import os
import re

font = fontforge.font()

for dir, _, files in os.walk(os.path.dirname(__file__)):
for file in filter(lambda x: re.match('^[0-9a-f]{4}_.*svg$', x, re.IGNORECASE), files):
code = file[:4]; fp = os.path.join(dir, file)
font.createChar(int(code, 16)).importOutlines(fp)
print(f'Added U+{code} -> {fp}')

font.generate('product-icons.woff')
8 changes: 0 additions & 8 deletions res/light/build-icon.svg

This file was deleted.

4 changes: 0 additions & 4 deletions res/light/json-icon.svg

This file was deleted.

12 changes: 0 additions & 12 deletions res/light/settings-icon.svg

This file was deleted.

Binary file added res/product-icons.woff2
Binary file not shown.
1 change: 1 addition & 0 deletions res/product-icons/uE001_build-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 5a6db88

Please sign in to comment.