From 357b66170ace6b0d46a772905fc80f74bc9228f1 Mon Sep 17 00:00:00 2001 From: Brandon Liu Date: Sun, 4 Dec 2022 20:58:32 +0800 Subject: [PATCH] UI clear button + fix multiple fonts sharing same codepoint (#11) * add UI button to clear file input * don't include duplicate glyphs for same codepoint in one fontstack. Allow FreeType style_name to be empty. * rename build.sh to build_wasm.sh --- .github/workflows/actions.yml | 2 +- CONTRIBUTING.md | 10 ++++++++-- app/src/App.tsx | 15 +++++++++++---- build.sh => build_wasm.sh | 2 +- main.cpp | 7 ++++++- 5 files changed, 27 insertions(+), 9 deletions(-) rename build.sh => build_wasm.sh (90%) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 00a0abb..bbd8110 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -35,7 +35,7 @@ jobs: with: version: ${{env.EM_VERSION}} actions-cache-folder: ${{env.EM_CACHE_FOLDER}} - - run: ./build.sh boost/boost/include + - run: ./build_wasm.sh boost/boost/include - run: BOOST_INCLUDEDIR=boost/boost/include cmake . && make - run: cd app && npm install && npx tsc && npx vite build --base=/font-maker/ - name: build_app diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0c027a0..7533574 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ The WASM outputs `sdfglyph.js` and `sdfglyph.wasm` are not committed to git. To * [sdfglyph.js](https://maplibre.org/font-maker/sdfglyph.js) * [sdfglyph.wasm](https://maplibre.org/font-maker/sdfglyph.wasm) -## Building +## Building WASM If you want to compile the WebAssembly components from scratch, you'll need the following: @@ -16,5 +16,11 @@ If you want to compile the WebAssembly components from scratch, you'll need the Clone this repository and all submodules with `git clone --recursive` -Use `./build.sh PATH_TO_INCLUDE_DIR` to build the WASM output, where `PATH_TO_INCLUDE_DIR` is the directory of your local Boost install. +Use `./build_wasm.sh PATH_TO_INCLUDE_DIR` to build the WASM output, where `PATH_TO_INCLUDE_DIR` is the directory of your local Boost install. example: `./build_wasm.sh /opt/local/include` +## Building command line + +``` +cmake . +make +``` \ No newline at end of file diff --git a/app/src/App.tsx b/app/src/App.tsx index 0311034..6e663d8 100644 --- a/app/src/App.tsx +++ b/app/src/App.tsx @@ -3,10 +3,7 @@ import "tachyons/css/tachyons.min.css"; import Pbf from "pbf"; import JSZip from "jszip"; import { saveAs } from "file-saver"; -import { - Map, - NavigationControl -} from "react-map-gl"; +import { Map, NavigationControl } from "react-map-gl"; import maplibregl from "maplibre-gl"; import "maplibre-gl/dist/maplibre-gl.css"; import { styleFunc } from "./style"; @@ -139,6 +136,10 @@ function App() { setFileUploads([...fileUploads, ...event.target.files!]); } + function clearFileInput() { + setFileUploads([]); + } + async function runFilesConvert() { if (fileUploads.length === 0) return; let bufs: ArrayBuffer[] = []; @@ -209,6 +210,12 @@ function App() { ); })} + {fileUploads.length > 0 ? ( + + ) : null} +
&faces, FT glyph_message.add_bytes(2,glyph.bitmap); } parent.add_message(3,glyph_data); + return; } } } @@ -125,7 +126,11 @@ extern "C" { FT_Set_Char_Size(face, 0, static_cast(size * (1 << 6)), 0, 0); f->faces->push_back(face); - std::string combined_name = std::string(face->family_name) + " " + std::string(face->style_name); + std::string combined_name = std::string(face->family_name); + if (face->style_name != NULL) { + combined_name += " " + std::string(face->style_name); + } + if (f->seen_face_names->count(combined_name) == 0) { if (f->seen_face_names->size() > 0) { *f->name += ",";