abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorJules Aguillon2022-03-17 20:08:26 +0100
committerJules Aguillon2022-03-17 20:23:28 +0100
commite63ff8f837947d574cc2da0c764b564302580343 (patch)
tree75eeb508c5835084ae4cac23662242d3d1bffd53
parentfe35d5fd5a96d995e0ff434718b7b2b8bcac5ba5 (diff)
downloadunexpected-keyboard-e63ff8f837947d574cc2da0c764b564302580343.tar.gz
unexpected-keyboard-e63ff8f837947d574cc2da0c764b564302580343.zip
Stateless build of the special font file
Keep the glyphs in SVG format and build the font using a FontForge script. A part of the previous font is kept because the sources is lost. This adds a new dependency to the build system, fontforge.
-rw-r--r--Makefile19
-rw-r--r--assets/fonts/README.md15
-rw-r--r--shell.nix2
-rw-r--r--srcs/juloo.keyboard2/KeyValue.java8
-rw-r--r--srcs/juloo.keyboard2/Theme.java2
-rw-r--r--srcs/special_font/01.svg7
-rw-r--r--srcs/special_font/02.svg16
-rw-r--r--srcs/special_font/03.svg16
-rw-r--r--srcs/special_font/04.svg1
-rw-r--r--srcs/special_font/README.md8
-rw-r--r--srcs/special_font/base_font.ttf (renamed from assets/fonts/keys.ttf)bin7076 -> 5780 bytes
-rw-r--r--srcs/special_font/build.pe15
12 files changed, 83 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index 72edb5b..a213088 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,6 @@ ANDROID_PLATFORM_VERSION = android-30
JAVA_VERSION = 1.8
SRC_DIR = srcs
-ASSETS_DIR = assets
RES_DIR = res
EXTRA_JARS =
@@ -46,7 +45,6 @@ JAVAC_FLAGS = -source $(JAVA_VERSION) -target $(JAVA_VERSION) -encoding utf8
MANIFEST_FILE = AndroidManifest.xml
JAVA_FILES = $(shell find $(SRC_DIR) -name '*.java')
RES_FILES = $(shell find $(RES_DIR) -type f)
-ASSETS_FILES = $(shell find $(ASSETS_DIR) -type f 2>/dev/null)
# Debug signing
@@ -80,11 +78,12 @@ _build/%.apk: _build/%.unsigned-apk %-keystore.conf
_build/%.unsigned-apk: _build/%.unaligned-apk
$(ANDROID_BUILD_TOOLS)/zipalign -fp 4 "$<" "$@"
-_build/%.unaligned-apk: _build/classes.dex $(MANIFEST_FILE) $(ASSETS_FILES)
+APK_EXTRA_FILES = classes.dex assets/special_font.ttf
+
+_build/%.unaligned-apk: $(addprefix _build/,$(APK_EXTRA_FILES)) $(MANIFEST_FILE)
$(ANDROID_BUILD_TOOLS)/aapt package -f -M $(MANIFEST_FILE) -S $(RES_DIR) \
-I $(ANDROID_PLATFORM)/android.jar -F "$@" $(AAPT_PACKAGE_FLAGS)
- [ -z "$(ASSETS_FILES)" ] || $(ANDROID_BUILD_TOOLS)/aapt add "$@" $(ASSETS_FILES)
- cd $(@D) && $(ANDROID_BUILD_TOOLS)/aapt add $(@F) classes.dex
+ cd $(@D) && $(ANDROID_BUILD_TOOLS)/aapt add $(@F) $(APK_EXTRA_FILES)
# R.java
@@ -96,6 +95,16 @@ $(R_FILE): $(RES_FILES) $(MANIFEST_FILE)
$(ANDROID_BUILD_TOOLS)/aapt package -f -m -S $(RES_DIR) -J $(GEN_DIR) \
-M $(MANIFEST_FILE) -I $(ANDROID_PLATFORM)/android.jar
+# Special font
+
+SPECIAL_FONT_BASE_FONT = srcs/special_font/base_font.ttf
+SPECIAL_FONT_GLYPHS = $(wildcard srcs/special_font/*.svg)
+SPECIAL_FONT_SCRIPT = srcs/special_font/build.pe
+
+_build/assets/special_font.ttf: $(SPECIAL_FONT_SCRIPT) $(SPECIAL_FONT_BASE_FONT) $(SPECIAL_FONT_GLYPHS)
+ mkdir -p $(@D)
+ fontforge -lang=ff -script $(SPECIAL_FONT_SCRIPT) $@ $(SPECIAL_FONT_BASE_FONT) $(SPECIAL_FONT_GLYPHS)
+
# Compile java classes and build classes.dex
OBJ_DIR = _build/class
diff --git a/assets/fonts/README.md b/assets/fonts/README.md
deleted file mode 100644
index ba0ff7c..0000000
--- a/assets/fonts/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# Fonts
-
-The glyphs from this font are made by:
-
-- Home and End
- Author: @sdrapha
-
-- Cog
- Copyright (C) 2016 by Dave Gandy
- Author: Dave Gandy
- License: SIL ()
-
-- Emoticon, PageUp and PageDown
- IcoMoon-Free is a free vector icon pack by Keyamoon.
- License: Attribution 4.0 International (CC BY 4.0)
diff --git a/shell.nix b/shell.nix
index 76ee98e..8036a5e 100644
--- a/shell.nix
+++ b/shell.nix
@@ -14,6 +14,6 @@ let
in
pkgs.mkShell {
- buildInputs = [ pkgs.findutils jdk android.androidsdk ];
+ buildInputs = [ pkgs.findutils jdk android.androidsdk pkgs.fontforge ];
ANDROID_HOME = "${android.androidsdk}/libexec/android-sdk";
}
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java
index 9cee797..9c0c080 100644
--- a/srcs/juloo.keyboard2/KeyValue.java
+++ b/srcs/juloo.keyboard2/KeyValue.java
@@ -228,10 +228,10 @@ class KeyValue
addCharKey('€', EVENT_NONE, FLAG_LOCALIZED);
addCharKey('£', EVENT_NONE, FLAG_LOCALIZED);
- addSpecialKey("config", "\uE806", EVENT_CONFIG, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
+ addSpecialKey("config", "\u0004", EVENT_CONFIG, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
addSpecialKey("switch_text", "ABC", EVENT_SWITCH_TEXT);
addSpecialKey("switch_numeric", "123+", EVENT_SWITCH_NUMERIC);
- addSpecialKey("switch_emoji", "\uE812" , EVENT_SWITCH_EMOJI, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
+ addSpecialKey("switch_emoji", "\u0001" , EVENT_SWITCH_EMOJI, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
addSpecialKey("switch_back_emoji", "ABC", EVENT_SWITCH_BACK_EMOJI);
addSpecialKey("change_method", "\ue807", EVENT_CHANGE_METHOD, FLAG_KEY_FONT | FLAG_SMALLER_FONT);
addSpecialKey("action", "Action", EVENT_ACTION, FLAG_SMALLER_FONT); // Will always be replaced
@@ -242,8 +242,8 @@ class KeyValue
addEventKey("right", "\uE80C", KeyEvent.KEYCODE_DPAD_RIGHT, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT);
addEventKey("down", "\uE809", KeyEvent.KEYCODE_DPAD_DOWN, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT);
addEventKey("left", "\uE80A", KeyEvent.KEYCODE_DPAD_LEFT, FLAG_KEY_FONT | FLAG_PRECISE_REPEAT);
- addEventKey("page_up", "\uE810", KeyEvent.KEYCODE_PAGE_UP, FLAG_KEY_FONT);
- addEventKey("page_down", "\uE811", KeyEvent.KEYCODE_PAGE_DOWN, FLAG_KEY_FONT);
+ addEventKey("page_up", "\u0002", KeyEvent.KEYCODE_PAGE_UP, FLAG_KEY_FONT);
+ addEventKey("page_down", "\u0003", KeyEvent.KEYCODE_PAGE_DOWN, FLAG_KEY_FONT);
addEventKey("home", "\uE80E", KeyEvent.KEYCODE_MOVE_HOME, FLAG_KEY_FONT);
addEventKey("end", "\uE80F", KeyEvent.KEYCODE_MOVE_END, FLAG_KEY_FONT);
addEventKey("backspace", "⌫", KeyEvent.KEYCODE_DEL, FLAG_SMALLER_FONT);
diff --git a/srcs/juloo.keyboard2/Theme.java b/srcs/juloo.keyboard2/Theme.java
index 3d57fe7..548e291 100644
--- a/srcs/juloo.keyboard2/Theme.java
+++ b/srcs/juloo.keyboard2/Theme.java
@@ -70,7 +70,7 @@ public class Theme
{
if (_specialKeyFont == null)
{
- _specialKeyFont = Typeface.createFromAsset(context.getAssets(), "fonts/keys.ttf");
+ _specialKeyFont = Typeface.createFromAsset(context.getAssets(), "special_font.ttf");
}
return _specialKeyFont;
}
diff --git a/srcs/special_font/01.svg b/srcs/special_font/01.svg
new file mode 100644
index 0000000..86169a4
--- /dev/null
+++ b/srcs/special_font/01.svg
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- IcoMoon-Free 227-smile2 CC BY 4.0 -->
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#000000" d="M8 0c-4.418 0-8 3.582-8 8s3.582 8 8 8 8-3.582 8-8-3.582-8-8-8zM11 4c0.552 0 1 0.448 1 1s-0.448 1-1 1-1-0.448-1-1 0.448-1 1-1zM5 4c0.552 0 1 0.448 1 1s-0.448 1-1 1-1-0.448-1-1 0.448-1 1-1zM8 13c-1.82 0-3.413-0.973-4.288-2.427l1.286-0.772c0.612 1.018 1.727 1.699 3.002 1.699s2.389-0.681 3.002-1.699l1.286 0.772c-0.874 1.454-2.467 2.427-4.288 2.427z"></path>
+</svg>
diff --git a/srcs/special_font/02.svg b/srcs/special_font/02.svg
new file mode 100644
index 0000000..3eab9dc
--- /dev/null
+++ b/srcs/special_font/02.svg
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- IcoMoon-Free 327-move-up CC BY 4.0 -->
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#000000" d="M11 8v6h1v-6h2.5l-3-3-3 3z"></path>
+<path fill="#000000" d="M1 3h1.5v1h-1.5v-1z"></path>
+<path fill="#000000" d="M3 3h1.5v1h-1.5v-1z"></path>
+<path fill="#000000" d="M5 3h1v1.5h-1v-1.5z"></path>
+<path fill="#000000" d="M1 6.5h1v1.5h-1v-1.5z"></path>
+<path fill="#000000" d="M2.5 7h1.5v1h-1.5v-1z"></path>
+<path fill="#000000" d="M4.5 7h1.5v1h-1.5v-1z"></path>
+<path fill="#000000" d="M1 4.5h1v1.5h-1v-1.5z"></path>
+<path fill="#000000" d="M5 5h1v1.5h-1v-1.5z"></path>
+<path fill="#000000" d="M5 11v3h-3v-3h3zM6 10h-5v5h5v-5z"></path>
+</svg>
diff --git a/srcs/special_font/03.svg b/srcs/special_font/03.svg
new file mode 100644
index 0000000..a4140eb
--- /dev/null
+++ b/srcs/special_font/03.svg
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- IcoMoon-Free 328-move-down CC BY 4.0 -->
+<!-- Generated by IcoMoon.io -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
+<path fill="#000000" d="M12 11v-6h-1v6h-2.5l3 3 3-3z"></path>
+<path fill="#000000" d="M5 4v3h-3v-3h3zM6 3h-5v5h5v-5z"></path>
+<path fill="#000000" d="M1 10h1.5v1h-1.5v-1z"></path>
+<path fill="#000000" d="M3 10h1.5v1h-1.5v-1z"></path>
+<path fill="#000000" d="M5 10h1v1.5h-1v-1.5z"></path>
+<path fill="#000000" d="M1 13.5h1v1.5h-1v-1.5z"></path>
+<path fill="#000000" d="M2.5 14h1.5v1h-1.5v-1z"></path>
+<path fill="#000000" d="M4.5 14h1.5v1h-1.5v-1z"></path>
+<path fill="#000000" d="M1 11.5h1v1.5h-1v-1.5z"></path>
+<path fill="#000000" d="M5 12h1v1.5h-1v-1.5z"></path>
+</svg>
diff --git a/srcs/special_font/04.svg b/srcs/special_font/04.svg
new file mode 100644
index 0000000..2a52ef7
--- /dev/null
+++ b/srcs/special_font/04.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.1.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --><path d="M495.9 166.6C499.2 175.2 496.4 184.9 489.6 191.2L446.3 230.6C447.4 238.9 448 247.4 448 256C448 264.6 447.4 273.1 446.3 281.4L489.6 320.8C496.4 327.1 499.2 336.8 495.9 345.4C491.5 357.3 486.2 368.8 480.2 379.7L475.5 387.8C468.9 398.8 461.5 409.2 453.4 419.1C447.4 426.2 437.7 428.7 428.9 425.9L373.2 408.1C359.8 418.4 344.1 427 329.2 433.6L316.7 490.7C314.7 499.7 307.7 506.1 298.5 508.5C284.7 510.8 270.5 512 255.1 512C241.5 512 227.3 510.8 213.5 508.5C204.3 506.1 197.3 499.7 195.3 490.7L182.8 433.6C167 427 152.2 418.4 138.8 408.1L83.14 425.9C74.3 428.7 64.55 426.2 58.63 419.1C50.52 409.2 43.12 398.8 36.52 387.8L31.84 379.7C25.77 368.8 20.49 357.3 16.06 345.4C12.82 336.8 15.55 327.1 22.41 320.8L65.67 281.4C64.57 273.1 64 264.6 64 256C64 247.4 64.57 238.9 65.67 230.6L22.41 191.2C15.55 184.9 12.82 175.3 16.06 166.6C20.49 154.7 25.78 143.2 31.84 132.3L36.51 124.2C43.12 113.2 50.52 102.8 58.63 92.95C64.55 85.8 74.3 83.32 83.14 86.14L138.8 103.9C152.2 93.56 167 84.96 182.8 78.43L195.3 21.33C197.3 12.25 204.3 5.04 213.5 3.51C227.3 1.201 241.5 0 256 0C270.5 0 284.7 1.201 298.5 3.51C307.7 5.04 314.7 12.25 316.7 21.33L329.2 78.43C344.1 84.96 359.8 93.56 373.2 103.9L428.9 86.14C437.7 83.32 447.4 85.8 453.4 92.95C461.5 102.8 468.9 113.2 475.5 124.2L480.2 132.3C486.2 143.2 491.5 154.7 495.9 166.6V166.6zM256 336C300.2 336 336 300.2 336 255.1C336 211.8 300.2 175.1 256 175.1C211.8 175.1 176 211.8 176 255.1C176 300.2 211.8 336 256 336z"/></svg> \ No newline at end of file
diff --git a/srcs/special_font/README.md b/srcs/special_font/README.md
new file mode 100644
index 0000000..baa8bb6
--- /dev/null
+++ b/srcs/special_font/README.md
@@ -0,0 +1,8 @@
+# Fonts
+
+See copyright notice in each SVG files.
+
+The glyphs in `base_font.ttf` are made by:
+
+- Home and End
+ Author: @sdrapha
diff --git a/assets/fonts/keys.ttf b/srcs/special_font/base_font.ttf
index aa5cf8c..2bfd130 100644
--- a/assets/fonts/keys.ttf
+++ b/srcs/special_font/base_font.ttf
Binary files differ
diff --git a/srcs/special_font/build.pe b/srcs/special_font/build.pe
new file mode 100644
index 0000000..fab828b
--- /dev/null
+++ b/srcs/special_font/build.pe
@@ -0,0 +1,15 @@
+# The special font is used for the symbols of some keys. It is built from SVG
+# files, one for each glyph.
+
+# Starts from an existing font file for glyphs that don't have SVG sources yet.
+Open($2)
+
+# Imports glyphs, file name is position in the font.
+i = 3
+while (i < $argc)
+ Select(Strtol($argv[i]:t:r))
+ Import($argv[i])
+ i++
+endloop
+
+Generate($1)