Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 7f459d8

Browse files
committed
Consider fontStyle, fontStretch and fontVariant for copying fonts.
1 parent d2b70d9 commit 7f459d8

12 files changed

+174
-17
lines changed

gxdesignops.sketchplugin/Contents/Sketch/__see-result.js

+36-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gxdesignops.sketchplugin/Contents/Sketch/__see-result.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gxdesignops.sketchplugin/Contents/Sketch/__send-to-queue-file.js

+33-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gxdesignops.sketchplugin/Contents/Sketch/__send-to-queue-file.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gxdesignops.sketchplugin/Contents/Sketch/__send-to-queue-gx-sketch.js

+33-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gxdesignops.sketchplugin/Contents/Sketch/__send-to-queue-gx-sketch.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gxdesignops.sketchplugin/Contents/Sketch/__send-to-queue.js

+33-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gxdesignops.sketchplugin/Contents/Sketch/__send-to-queue.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gxdesignops.sketchplugin/Contents/Sketch/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"gxdesignops.set-queue-path"
3939
]
4040
},
41-
"version": "2.2.8",
41+
"version": "2.2.9",
4242
"description": "Sketch Plugin For GeneXus Design Ops Cycles",
4343
"name": "GxDesignOps",
4444
"identifier": "GxDesignOps",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gxdesignops",
33
"description": "Sketch Plugin For GeneXus Design Ops Cycles",
44
"repository": "https://github.com/genexuslabs/sketchdesignops.git",
5-
"version": "2.2.8",
5+
"version": "2.2.9",
66
"engines": {
77
"sketch": ">=49.0"
88
},

src/see-result.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import sketch from 'sketch';
22

33

44
import { spawnSync , execSync} from '@skpm/child_process';
5-
import { getFileAndQueueName, getQueuePath } from './utils';
6-
5+
import { copyFonts } from './utils';
76

87
var UI = require("sketch/ui");
98
var zip = require("jszip");
@@ -21,7 +20,7 @@ function getFonts() {
2120
}
2221

2322

24-
export default function () {
23+
export default function (context) {
2524
var queuePath = getQueuePath(queuePath);
2625
var fileName;
2726
({ fileName, queuePath } = getFileAndQueueName(doc, queuePath));

src/utils.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,36 @@ var exportLayer = function (layer, path) {
178178
}
179179
}
180180

181+
function getTraitsForFont(style) {
182+
var traits = 0;
183+
if (style.fontStyle == 'italic')
184+
traits |= NSItalicFontMask;
185+
if (style.fontVariant == 'small-caps')
186+
traits |= NSSmallCapsFontMask;
187+
188+
switch (style.fontStretch) {
189+
case 'compressed':
190+
traits |= NSCompressedFontMask;
191+
break;
192+
case 'condensed':
193+
traits |= NSCondensedFontMask;
194+
break;
195+
case 'narrow':
196+
traits |= NSNarrowFontMask;
197+
break;
198+
case 'expanded':
199+
traits |= NSExpandedFontMask;
200+
break;
201+
case 'poster':
202+
traits |= NSPosterFontMask;
203+
break;
204+
default:
205+
}
206+
return traits;
207+
}
208+
209+
210+
181211
var traverseFonts = function (layer, fonts) {
182212
if (layer.type == "Text" && layer.style.fontFamily != "Helvetica") {
183213
log(layer.style.fontFamily + "-" + layer.style.fontWeight);
@@ -187,7 +217,7 @@ var traverseFonts = function (layer, fonts) {
187217
return;
188218
}
189219
if (layer.style.fontFamily && layer.style.fontWeight && layer.style.fontSize) {
190-
var nFont = fontManager.fontWithFamily_traits_weight_size(layer.style.fontFamily, 0, layer.style.fontWeight, layer.style.fontSize);
220+
var nFont = fontManager.fontWithFamily_traits_weight_size(layer.style.fontFamily, getTraitsForFont(layer.style), layer.style.fontWeight, layer.style.fontSize);
191221
if (nFont) {
192222
var fontName = nFont.fontName();
193223
log("FONT NAME:" + fontName);

0 commit comments

Comments
 (0)