-
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
Showing
23 changed files
with
264 additions
and
73 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
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
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
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
iconfont-assets/src/test/java/open/source/iconfont/assets/test/Main.java
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,31 @@ | ||
package open.source.iconfont.assets.test; | ||
|
||
import com.google.gson.Gson; | ||
|
||
import java.io.IOException; | ||
|
||
import okhttp3.OkHttpClient; | ||
import okhttp3.Request; | ||
import open.source.iconfont.assets.IconFontAssetService; | ||
import retrofit2.Retrofit; | ||
import retrofit2.converter.gson.GsonConverterFactory; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
OkHttpClient client = new OkHttpClient(); | ||
IconFontAssetService service = new Retrofit.Builder() | ||
.client(client) | ||
.baseUrl("https://icon-font-assets.oss-cn-beijing.aliyuncs.com") | ||
.addConverterFactory(GsonConverterFactory.create(new Gson())) | ||
.build() | ||
.create(IconFontAssetService.class); | ||
try { | ||
System.out.println(service.index("0.0.1").execute().body().icons); | ||
client.newCall(new Request.Builder() | ||
.url("https://icon-font-assets.oss-cn-beijing.aliyuncs.com/icon-font-assets/iconfont.ttf") | ||
.build()).execute(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/build | ||
/.idea | ||
/node_modules | ||
yarn.lock | ||
/.idea | ||
/build |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,73 @@ | ||
const iconfont = require('gulp-iconfont'); | ||
const gulp = require('gulp'); | ||
const fs = require('fs'); | ||
const del = require('del'); | ||
const path = require('path'); | ||
const argv = require('minimist')(process.argv.slice(2)); | ||
const input = argv['input'] || "assets/icons"; | ||
const output = argv['output'] || 'build/'; | ||
const fontName = argv['font-name'] || 'iconfont'; | ||
const version = argv['version'] || '0.0.1'; | ||
const outputWithVersion = path.join(output, version); | ||
|
||
/* Creates a unicode literal based on the string */ | ||
function unicodeLiteral(str) { | ||
function fixedHex(number, length) { | ||
let str = number.toString(16).toUpperCase(); | ||
while (str.length < length) | ||
str = "0" + str; | ||
return str; | ||
} | ||
|
||
let i; | ||
let result = ""; | ||
for (i = 0; i < str.length; ++i) { | ||
/* You should probably replace this by an isASCII test */ | ||
if (str.charCodeAt(i) > 126 || str.charCodeAt(i) < 32) | ||
result += fixedHex(str.charCodeAt(i), 4); | ||
else | ||
result += str[i]; | ||
} | ||
|
||
return result.toLocaleLowerCase(); | ||
} | ||
|
||
function saveJson(list) { | ||
const icons = {}; | ||
for (let e of list) { | ||
icons[e.name] = e.unicode | ||
} | ||
const json = {icons, version, fonts: ["./" + fontName + ".ttf"]}; | ||
const exportJson = path.join(outputWithVersion, "export.json"); | ||
if (fs.existsSync(exportJson)) { | ||
fs.unlinkSync(exportJson); | ||
} | ||
fs.writeFileSync(exportJson, JSON.stringify(json)); | ||
} | ||
|
||
gulp.task('clean', async () => { | ||
await del([ | ||
path.join(output, '/**/*'), | ||
]); | ||
}); | ||
|
||
gulp.task('iconfont', () => { | ||
return gulp.src([path.join(input, '*.svg')]) | ||
.pipe(iconfont({ | ||
fontName: fontName, | ||
formats: ['ttf'], | ||
})) | ||
.on('glyphs', function (glyphs, options) { | ||
// CSS templating, e.g. | ||
saveJson(glyphs.map((e) => { | ||
return { | ||
name: e.name, | ||
unicode: unicodeLiteral(e.unicode[0]) | ||
} | ||
})); | ||
//console.log(glyphs, options); | ||
}) | ||
.pipe(gulp.dest(outputWithVersion)); | ||
}); | ||
|
||
gulp.task("default", gulp.series("clean", "iconfont")); |
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
{ | ||
"name": "iconfont-export", | ||
"name": "svg2iconfont", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"iconfont": "gulp default" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"del": "^6.0.0", | ||
"gulp": "^4.0.2", | ||
"gulp-filter": "^6.0.0", | ||
"gulp-iconfont": "^11.0.0", | ||
"hasha": "^5.2.2", | ||
"minimist": "^1.2.5", | ||
"xmldom": "^0.4.0" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
"minimist": "^1.2.5" | ||
} | ||
} |
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
Oops, something went wrong.