|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 61d0326a5b1c11a8f2e8e31ec9093e81daa26588 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: David Herrmann <dh.herrmann@gmail.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Thu, 2 Oct 2014 19:47:21 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] terminal/unifont: add built-in fallback glyph
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
In case we cannot render a glyph, we want a fallback we can display
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
instead. If we rely on the font itself to provide the fallback character,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
we have nothing to display if that character is not available. Therefore,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
add a static fallback that we can use at any time.
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/unifont.c | 18 ++++++++++++++++++
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/libsystemd-terminal/unifont.h | 1 +
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
2 files changed, 19 insertions(+)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/unifont.c b/src/libsystemd-terminal/unifont.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 7520015988..2acfa9821a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/unifont.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/unifont.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -221,3 +221,21 @@ int unifont_lookup(unifont *u, unifont_glyph *out, uint32_t ucs4) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
memcpy(out, &g, sizeof(g));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+void unifont_fallback(unifont_glyph *out) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ static const uint8_t fallback_data[] = {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ /* unifont 0xfffd '�' (unicode replacement character) */
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ 0x00, 0x00, 0x00, 0x7e,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ 0x66, 0x5a, 0x5a, 0x7a,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ 0x76, 0x76, 0x7e, 0x76,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ 0x76, 0x7e, 0x00, 0x00,
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ };
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ assert(out);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ out->width = 8;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ out->height = 16;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ out->stride = 1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ out->cwidth = 1;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ out->data = fallback_data;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/libsystemd-terminal/unifont.h b/src/libsystemd-terminal/unifont.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index 0ded61472f..30527cb3fa 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/libsystemd-terminal/unifont.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/libsystemd-terminal/unifont.h
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -54,3 +54,4 @@ unsigned int unifont_get_width(unifont *u);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned int unifont_get_height(unifont *u);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
unsigned int unifont_get_stride(unifont *u);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
int unifont_lookup(unifont *u, unifont_glyph *out, uint32_t ucs4);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+void unifont_fallback(unifont_glyph *out);
|