-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jeongheeyeun
committed
Sep 2, 2018
0 parents
commit aa94209
Showing
6 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# build artifacts | ||
sd-changer.sketchplugin | ||
|
||
# npm | ||
node_modules | ||
.npm | ||
npm-debug.log | ||
|
||
# mac | ||
.DS_Store | ||
|
||
# WebStorm | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# SD Changer | ||
|
||
SD Changer는 한국어로 언어 설정 된 iOS 화면을 더 쉽게 디자인 하도록, Apple SD Gothic Neo 폰트를 일괄로 SF Pro Display로 바꿔주는 Sketch plugin 입니다. | ||
|
||
## Keys | ||
|
||
- Menu `Plugins` › `SD Changer` | ||
- Shortcut `shift` `option` `command` `D` | ||
|
||
## Features | ||
|
||
선택된 레이어나 그룹, 아트보드 안의 Apple SD Gothic Neo 폰트가 적용된 텍스트 레이어를 찾아, SF Pro Display로 변환합니다. 아무것도 선택되지 않은 상태에서 작동하면 현재 Page의 모든 텍스트 레이어를 대상으로 합니다. | ||
|
||
## Install | ||
|
||
- [플러그인 파일](https://github.com/yeun/sd-changer/releases/latest)을 다운로드 받습니다. | ||
- 압축을 풉니다. | ||
- .sketchplugin 파일을 더블클릭해 설치합니다. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "sd-changer", | ||
"engines": { | ||
"sketch": ">=3.0" | ||
}, | ||
"skpm": { | ||
"name": "sd-changer", | ||
"manifest": "src/manifest.json", | ||
"main": "sd-changer.sketchplugin", | ||
"assets": [ | ||
"assets/**/*" | ||
] | ||
}, | ||
"scripts": { | ||
"build": "skpm-build", | ||
"watch": "skpm-build --watch", | ||
"start": "skpm-build --watch --run", | ||
"postinstall": "npm run build && skpm-link" | ||
}, | ||
"devDependencies": { | ||
"@skpm/builder": "^0.5.2" | ||
}, | ||
"author": "jeongheeyeun <heeyeun.design@gmail.com>", | ||
"repository": "https://github.com/yeun/sd-changer", | ||
"description": "Converts Apple SD Gothic Neo font to SF Pro Display" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name" : "SD Chagner", | ||
"description" : "Converts Apple SD Gothic Neo font to SF Pro Display", | ||
"author" : "Heeyeun Jeong", | ||
"authorEmail" : "heeyeun.design@gmail.com", | ||
"compatibleVersion": 3, | ||
"bundleVersion": 1, | ||
"icon": "icon.png", | ||
"commands": [ | ||
{ | ||
"name": "SD Chagner", | ||
"identifier": "sd-changer", | ||
"script": "./sd-changer.js", | ||
"shortcut" : "shift option cmd d" | ||
} | ||
], | ||
"menu": { | ||
"isRoot": true, | ||
"items": [ | ||
"sd-changer" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
export default function(context) { | ||
const doc = context.document | ||
const page = doc.currentPage() | ||
const selection = context.selection | ||
|
||
function changeFont(layer) { | ||
var fontName = layer.fontPostscriptName() | ||
var fontWeight = fontName.split("-")[1] | ||
var fontWeights = { | ||
"Thin": "Light", | ||
"UltraLight": "Light", | ||
"Light": "Light", | ||
"Regular": "Regular", | ||
"Medium": "Medium", | ||
"SemiBold": "Semibold", | ||
"Bold": "Bold", | ||
"ExtraBold": "Heavy", | ||
"Heavy": "Heavy" | ||
}; | ||
var weight = fontWeights[fontWeight] | ||
|
||
if (fontName.hasPrefix("AppleSDGothicNeo")) { | ||
layer.select_byExpandingSelection(true, true) | ||
layer.fontPostscriptName = "SFProDisplay-" + weight | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
function selectLayersByType(selectedlayer) { | ||
var count = 0 | ||
|
||
if (selectedlayer.containsLayers() && selectedlayer.class() != "MSShapeGroup") { | ||
var loopChildrens = selectedlayer.children().objectEnumerator() | ||
var layer | ||
while (layer = loopChildrens.nextObject()) { | ||
if (layer.class() == MSTextLayer) { | ||
var changed = changeFont(layer) | ||
if (changed) count ++ | ||
} | ||
} | ||
} else if (selectedlayer.containsLayers() == false && selectedlayer.class() == "MSTextLayer") { | ||
var changed = changeFont(selectedlayer) | ||
if (changed) count ++ | ||
} | ||
return count | ||
} | ||
|
||
// Fix Sketch 45 | ||
if (page.deselectAllLayers) { | ||
page.deselectAllLayers() | ||
} else { | ||
page.changeSelectionBySelectingLayers(nil) | ||
} | ||
|
||
var totalCount = 0 | ||
|
||
if (selection.count() == 0) { | ||
var count = selectLayersByType(page) | ||
totalCount = count | ||
} else { | ||
var loop = selection.objectEnumerator() | ||
var layer | ||
while (layer = loop.nextObject()) { | ||
var count = selectLayersByType(layer) | ||
totalCount += count | ||
} | ||
} | ||
|
||
if (totalCount == 0) { | ||
doc.showMessage("바꿀 레이어가 없습니다 😲") | ||
} else { | ||
doc.showMessage(totalCount + " 개의 산돌 고딕 레이어를 바꿨습니다 😎") | ||
} | ||
} |