diff --git a/README.md b/README.md index 3c3aaaf..b39f56e 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ You can take the code snapshot in two steps: - [x] Syntax highlighting - [x] Adjustable image dimensions - [ ] Customizable theme -- [ ] Customizable fonts +- [x] Customizable fonts ## Contributing @@ -47,4 +47,4 @@ Join our community on [Discord](http://discord.devsdope.com/) Give a ⭐️ if this project helped you! ### License -This project is [MIT](https://github.com/khattakdev/capture/blob/main/LICENSE.md) licensed. \ No newline at end of file +This project is [MIT](https://github.com/khattakdev/capture/blob/main/LICENSE.md) licensed. diff --git a/package.json b/package.json index 871cc57..ba7d43d 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,28 @@ "default": "one-dark-pro", "description": "Select a theme for the screenshot. This theme will be used to style the code in the screenshot, making it look like it does in the VS Code editor with that theme applied.", "enum": ["dark-plus","dracula-soft","dracula","github-dark-dimmed","github-dark","github-light","hc_light","light-plus","material-theme-darker","material-theme-lighter","material-theme-ocean","material-theme","material-theme-palenight","min-dark","min-light","monokai","nord","one-dark-pro","poimandres","rose-pine-dane","rose-pine","slack-dark","slack-ochin","solarized-dark","solarized-light","vitesse-dark","vitesse-light","rose-pine-dawn","rose-pine-moon","css-variables"] + }, + "capture.fontFamily": { + "type": "string", + "default": "Cascadia Code PL", + "description": "Select a font for the code in the screenshot.", + "enum": [ + "Cascadia Code PL", + "Fira Code", + "JetBrains Mono", + "Source Code Pro", + "Consolas", + "Roboto Mono", + "Ubuntu Mono", + "Inconsolata", + "Anonymous Pro", + "Hack", + "IBM Plex Mono", + "Droid Sans Mono", + "Courier Prime", + "PT Mono", + "Space Mono" + ] } } }] diff --git a/src/extension.ts b/src/extension.ts index 15e32d2..8c42b4e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -33,8 +33,9 @@ export function activate(context: vscode.ExtensionContext) { const configuration = vscode.workspace.getConfiguration('capture'); const themeName = configuration.get('themeName', 'one-dark-pro'); + const fontFamily = configuration.get('fontFamily', 'Cascadia Code PL'); - const content = await generateTemplate(text,themeName); + const content = await generateTemplate(text, themeName, fontFamily); await page.setContent(content); const contentHeight = content.split("\n").length; const totalHeight = contentHeight * 3; diff --git a/src/template.ts b/src/template.ts index 41a4f51..eae4f7f 100644 --- a/src/template.ts +++ b/src/template.ts @@ -8,7 +8,7 @@ const highlightCode = async (themeName: string) => { return highlighter; }; -const generateTemplate = async (content: string, themeName: string) => { +const generateTemplate = async (content: string, themeName: string, fontFamily: string = 'Cascadia Code PL') => { // get hightlighter const highlighter = await highlightCode(themeName); // set content @@ -20,13 +20,20 @@ const generateTemplate = async (content: string, themeName: string) => { +