palm-client: glyphs for 12 common emoji, tap an emoji to see it enlarged
This commit is contained in:
1 parent
ae4d8453d8
commit
6dd623f778
19 files changed
+699
-32
No files matched your search
@@ -89,3 +89,4 @@
|
||||
- 2026-11-02: Mute Channel (Options menu; by channel key; mentions still sound; open-circle unread badge, left out of the title total) and Text size Small/Large on the new Preferences screen (5x8 misc-fixed via tools/pcf2bdf.py from XQuartz's PCF; gen_font.py builds both fonts). Verified on the Neo. Segments: 11.1 / 28.0 / 14.7 KB.
|
||||
- 2026-11-02: Flood scopes: a list of scope names (Options > Flood Scopes), the radio's default (Set Default / No Default), a per-channel choice (Options > Channel Scope: radio default, none, or a named scope), and Discover, which asks neighbouring repeaters for their regions (SEND_ANON_REQ type 0x01). The session sets the scope override before each flood send and resets it on disconnect. Keys and frames are host-tested (tests/test_scopes.c; the key for "test" matches the radio's #test channel key). Verified on the Neo. Discover only reaches 0-hop repeaters for now.
|
||||
- 2026-11-02: Map screen (Options > Map): an OpenStreetMap basemap of the Philadelphia metro in 4 greys with the contacts that advertise a position plotted on it (no position, not shown). `tools/make_map.py` downloads OSM roads, rail, water and parks (Overpass, cached in tools/map-cache), draws zooms 10-12 for the metro and 13 with residential streets for ~16 km around Center City, and writes build/VisorMeshMap.pdb (290 PackBits tiles, 1,045 KB); `make map`, `make install-map`. Zoom with -/+ or the hard buttons, drag to pan, tap a node for its info, tap again to open it. Fixed on the device: a long node name overflowed the info bar (reset), and the attribution overlapped the buttons. Verified on the Neo. Segment 3 is 24.9 KB.
|
||||
- 2026-11-02: Emoji: 12 common ones have their own glyph in both fonts (thumbs up, tears of joy, heart, crying, folded hands, waving hand, fire, party popper, thinking, eyes, antenna, 100), with close variants mapped onto them and skin tones dropped; the rest stay the generic smiley. Tap an emoji in a message for a 32x32 picture and its name (resources/emoji.bin from gen_font.py). Verified on the Neo. Segments: 12.2 / 28.8 / 25.7 KB; vmcode2 is nearly full.
|
||||
@@ -10,7 +10,7 @@ APP = visormesh
|
||||
NAME = VisorMesh
|
||||
CREATOR = VMsh
|
||||
|
||||
SRCS = src/main.c src/app.c src/home_form.c src/convo_form.c src/node_form.c src/channel_form.c src/convos.c src/protocol.c src/sha256.c src/transport_srm.c src/transport_sb.c src/sb_spi.c src/session.c src/settings.c src/presets.c src/contacts.c src/contacts_form.c src/contact_form.c src/heard.c src/remote_fmt.c src/remote.c src/remote_form.c src/messages.c src/channels.c src/preview_form.c src/ui/draw.c src/ui/text.c src/ui/rowlist.c src/ui/fontmetrics.c src/ports.c src/sounds.c src/mutes.c src/scopes.c src/scope_proto.c src/map_geo.c src/map_form.c
|
||||
SRCS = src/main.c src/app.c src/home_form.c src/convo_form.c src/node_form.c src/channel_form.c src/convos.c src/protocol.c src/sha256.c src/transport_srm.c src/transport_sb.c src/sb_spi.c src/session.c src/settings.c src/presets.c src/contacts.c src/contacts_form.c src/contact_form.c src/heard.c src/remote_fmt.c src/remote.c src/remote_form.c src/messages.c src/channels.c src/preview_form.c src/ui/draw.c src/ui/text.c src/ui/rowlist.c src/ui/fontmetrics.c src/ports.c src/sounds.c src/mutes.c src/scopes.c src/scope_proto.c src/map_geo.c src/map_form.c src/ui/emoji.c
|
||||
OBJS = $(SRCS:src/%.c=build/%.o)
|
||||
|
||||
CC = m68k-palmos-gcc
|
||||
@@ -31,7 +31,7 @@ ifeq ($(shell command -v $(CC) 2>/dev/null),)
|
||||
# so an install of an up-to-date build doesn't need the toolchain at all.
|
||||
all: build/$(APP).prc
|
||||
|
||||
build/$(APP).prc: $(SRCS) src/*.h src/ui/*.h resources/$(APP).rcp resources/smallfont.nfnt resources/largefont.nfnt $(APP).def
|
||||
build/$(APP).prc: $(SRCS) src/*.h src/ui/*.h resources/$(APP).rcp resources/smallfont.nfnt resources/largefont.nfnt resources/emoji.bin $(APP).def
|
||||
$(MAKE) image
|
||||
$(DOCKER_RUN) make all
|
||||
|
||||
@@ -60,7 +60,7 @@ build/$(APP)-sections.o: build/$(APP)-sections.s
|
||||
build/$(APP): $(OBJS) build/$(APP)-sections.o build/$(APP)-sections.ld
|
||||
$(CC) $(CFLAGS) -o $@ $(OBJS) build/$(APP)-sections.o build/$(APP)-sections.ld
|
||||
|
||||
build/res.stamp: resources/$(APP).rcp src/resources.h resources/smallfont.nfnt resources/largefont.nfnt | build
|
||||
build/res.stamp: resources/$(APP).rcp src/resources.h resources/smallfont.nfnt resources/largefont.nfnt resources/emoji.bin | build
|
||||
rm -rf build/res && mkdir -p build/res
|
||||
$(PILRC) -q -I src $< build/res
|
||||
touch $@
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1122,6 +1122,86 @@ GLYPH 144
|
||||
#---#
|
||||
-###-
|
||||
|
||||
GLYPH 145
|
||||
------
|
||||
------
|
||||
--#---
|
||||
-##---
|
||||
#####-
|
||||
#####-
|
||||
####--
|
||||
------
|
||||
|
||||
GLYPH 146
|
||||
-----
|
||||
-----
|
||||
-###-
|
||||
##-##
|
||||
#####
|
||||
##-##
|
||||
-###-
|
||||
#---#
|
||||
|
||||
GLYPH 147
|
||||
-----
|
||||
-----
|
||||
##-##
|
||||
#####
|
||||
#####
|
||||
-###-
|
||||
--#--
|
||||
-----
|
||||
|
||||
GLYPH 148
|
||||
-----
|
||||
-----
|
||||
-###-
|
||||
##-##
|
||||
#---#
|
||||
#-#-#
|
||||
-###-
|
||||
-#---
|
||||
|
||||
GLYPH 149
|
||||
-----
|
||||
-----
|
||||
--#--
|
||||
-#-#-
|
||||
-#-#-
|
||||
#-#-#
|
||||
##-##
|
||||
-----
|
||||
|
||||
GLYPH 150
|
||||
------
|
||||
------
|
||||
-#-#--
|
||||
#-#-#-
|
||||
#####-
|
||||
#####-
|
||||
-###--
|
||||
------
|
||||
|
||||
GLYPH 151
|
||||
-----
|
||||
-----
|
||||
--#--
|
||||
-##-#
|
||||
-####
|
||||
##-##
|
||||
-###-
|
||||
-----
|
||||
|
||||
GLYPH 152
|
||||
------
|
||||
------
|
||||
--#-#-
|
||||
#--#--
|
||||
-##-#-
|
||||
-###--
|
||||
####--
|
||||
------
|
||||
|
||||
GLYPH 153
|
||||
-----
|
||||
-----
|
||||
@@ -1132,6 +1212,16 @@ GLYPH 153
|
||||
-###-
|
||||
-----
|
||||
|
||||
GLYPH 154
|
||||
------
|
||||
------
|
||||
-###--
|
||||
##-##-
|
||||
#---#-
|
||||
#-###-
|
||||
-##--#
|
||||
---##-
|
||||
|
||||
GLYPH 155
|
||||
-----
|
||||
-----
|
||||
@@ -1142,6 +1232,36 @@ GLYPH 155
|
||||
-----
|
||||
-----
|
||||
|
||||
GLYPH 156
|
||||
------
|
||||
------
|
||||
------
|
||||
##-##-
|
||||
#####-
|
||||
##-##-
|
||||
------
|
||||
------
|
||||
|
||||
GLYPH 157
|
||||
-----
|
||||
-----
|
||||
-#-#-
|
||||
#-#-#
|
||||
--#--
|
||||
-###-
|
||||
#-#-#
|
||||
-----
|
||||
|
||||
GLYPH 158
|
||||
----------
|
||||
----------
|
||||
#-###-###-
|
||||
#-#-#-#-#-
|
||||
#-#-#-#-#-
|
||||
#-###-###-
|
||||
----------
|
||||
#########-
|
||||
|
||||
GLYPH 160
|
||||
-----
|
||||
-----
|
||||
|
||||
Binary file not shown.
@@ -898,6 +898,70 @@ GLYPH 144
|
||||
#---#
|
||||
-###-
|
||||
|
||||
GLYPH 145
|
||||
--#---
|
||||
-##---
|
||||
#####-
|
||||
#####-
|
||||
####--
|
||||
------
|
||||
|
||||
GLYPH 146
|
||||
-###-
|
||||
##-##
|
||||
#####
|
||||
##-##
|
||||
-###-
|
||||
#---#
|
||||
|
||||
GLYPH 147
|
||||
##-##
|
||||
#####
|
||||
#####
|
||||
-###-
|
||||
--#--
|
||||
-----
|
||||
|
||||
GLYPH 148
|
||||
-###-
|
||||
##-##
|
||||
#---#
|
||||
#-#-#
|
||||
-###-
|
||||
-#---
|
||||
|
||||
GLYPH 149
|
||||
--#--
|
||||
-#-#-
|
||||
-#-#-
|
||||
#-#-#
|
||||
##-##
|
||||
-----
|
||||
|
||||
GLYPH 150
|
||||
-#-#--
|
||||
#-#-#-
|
||||
#####-
|
||||
#####-
|
||||
-###--
|
||||
------
|
||||
|
||||
GLYPH 151
|
||||
--#--
|
||||
-##-#
|
||||
-####
|
||||
##-##
|
||||
-###-
|
||||
-----
|
||||
|
||||
GLYPH 152
|
||||
--#-#-
|
||||
#--#--
|
||||
-##-#-
|
||||
-###--
|
||||
####--
|
||||
------
|
||||
|
||||
GLYPH 153
|
||||
-###-
|
||||
#-#-#
|
||||
@@ -906,6 +970,14 @@ GLYPH 153
|
||||
-###-
|
||||
-----
|
||||
|
||||
GLYPH 154
|
||||
-###--
|
||||
##-##-
|
||||
#---#-
|
||||
#-###-
|
||||
-##--#
|
||||
---##-
|
||||
|
||||
GLYPH 155
|
||||
----
|
||||
-#--
|
||||
@@ -914,6 +986,30 @@ GLYPH 155
|
||||
----
|
||||
----
|
||||
|
||||
GLYPH 156
|
||||
------
|
||||
##-##-
|
||||
#####-
|
||||
##-##-
|
||||
------
|
||||
------
|
||||
|
||||
GLYPH 157
|
||||
-#-#-
|
||||
#-#-#
|
||||
--#--
|
||||
-###-
|
||||
#-#-#
|
||||
-----
|
||||
|
||||
GLYPH 158
|
||||
#-###-###-
|
||||
#-#-#-#-#-
|
||||
#-#-#-#-#-
|
||||
#-###-###-
|
||||
----------
|
||||
#########-
|
||||
|
||||
GLYPH 160
|
||||
----
|
||||
----
|
||||
|
||||
@@ -9,6 +9,7 @@ APPLICATIONICONNAME ID 1000 "VisorMesh"
|
||||
*/
|
||||
DATA "NFNT" ID SmallFontRes "resources/smallfont.nfnt"
|
||||
DATA "NFNT" ID LargeFontRes "resources/largefont.nfnt"
|
||||
DATA "EMJI" ID EmojiArtRes "resources/emoji.bin"
|
||||
|
||||
MENU ID MainMenuBar
|
||||
BEGIN
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "ui/draw.h"
|
||||
#include "ui/text.h"
|
||||
#include "ui/rowlist.h"
|
||||
#include "ui/emoji.h"
|
||||
#include "convo_form.h"
|
||||
|
||||
/* In the second code segment: see sections.h for the rules. */
|
||||
@@ -23,7 +24,7 @@ static void SuffixOf(const VmMsgHeader *h, Char *out) VM_SECT2;
|
||||
static UInt32 LocalDay(UInt32 utc) VM_SECT2;
|
||||
static void AddLine(UInt8 kind, UInt16 msg, UInt16 off, UInt16 len, Boolean first, Boolean last, UInt32 day) VM_SECT2;
|
||||
static void Build(void) VM_SECT2;
|
||||
static void DrawTextWithMentions(const Char *text, UInt16 len, Coord x, Coord y) VM_SECT2;
|
||||
static Int16 TextWithMentions(const Char *text, UInt16 len, Coord x, Coord y, Coord hitX) VM_SECT2;
|
||||
static void DrawLine(UInt16 row, const RectangleType *b, void *ctx) VM_SECT2;
|
||||
static void DrawCounter(void) VM_SECT2;
|
||||
static UInt16 FirstUnread(void) VM_SECT2;
|
||||
@@ -31,7 +32,8 @@ static void ScrollToNew(void) VM_SECT2;
|
||||
static void Refresh(Boolean toEnd) VM_SECT2;
|
||||
static void Send(FormType *form) VM_SECT2;
|
||||
static void InsertMention(const Char *sender) VM_SECT2;
|
||||
static void Tapped(UInt16 row) VM_SECT2;
|
||||
static void Tapped(UInt16 row, Coord penX) VM_SECT2;
|
||||
static Boolean TappedEmoji(UInt16 row, Coord penX) VM_SECT2;
|
||||
|
||||
#define MAX_MSGS 40 /* newest messages shown */
|
||||
#define MAX_LINES 200
|
||||
@@ -196,31 +198,52 @@ static void Build(void)
|
||||
* "@[Name]" it replaces (2 px pads vs three 4 px characters), so the line still
|
||||
* fits the width it was wrapped to.
|
||||
*/
|
||||
static void DrawTextWithMentions(const Char *text, UInt16 len, Coord x, Coord y)
|
||||
/*
|
||||
* A line's text with "@[name]" mentions drawn as chips. With hitX < 0 it
|
||||
* draws; otherwise it only lays the line out and returns the index of the
|
||||
* plain character under hitX (-1 if none, or a chip), so taps line up with
|
||||
* what's drawn.
|
||||
*/
|
||||
static Int16 TextWithMentions(const Char *text, UInt16 len, Coord x, Coord y, Coord hitX)
|
||||
{
|
||||
Char name[VM_NAME_SIZE];
|
||||
UInt16 i = 0, start = 0, end, n;
|
||||
UInt16 i = 0, start = 0, end = 0, n = 0, k;
|
||||
Coord w;
|
||||
|
||||
while (i + 2 < len) {
|
||||
if (text[i] != '@' || text[i + 1] != '[') {
|
||||
i++;
|
||||
continue;
|
||||
for (;;) {
|
||||
/* find the next mention (or the end) */
|
||||
for (; i + 2 < len; i++) {
|
||||
if (text[i] != '@' || text[i + 1] != '[')
|
||||
continue;
|
||||
for (end = i + 2; end < len && text[end] != ']'; end++)
|
||||
;
|
||||
n = end - (i + 2);
|
||||
if (end < len && n > 0 && n < sizeof(name))
|
||||
break;
|
||||
}
|
||||
for (end = i + 2; end < len && text[end] != ']'; end++)
|
||||
;
|
||||
n = end - (i + 2);
|
||||
if (end >= len || n == 0 || n >= sizeof(name)) {
|
||||
i++;
|
||||
continue;
|
||||
if (i + 2 >= len)
|
||||
i = len;
|
||||
/* the plain text before it */
|
||||
if (hitX < 0) {
|
||||
WinDrawChars(text + start, i - start, x, y);
|
||||
x += FntCharsWidth(text + start, i - start);
|
||||
} else {
|
||||
for (k = start; k < i; k++, x += w) {
|
||||
w = FntCharWidth(text[k]);
|
||||
if (hitX < x + w)
|
||||
return hitX >= x ? (Int16)k : -1;
|
||||
}
|
||||
}
|
||||
WinDrawChars(text + start, i - start, x, y);
|
||||
x += FntCharsWidth(text + start, i - start);
|
||||
if (i >= len)
|
||||
return -1;
|
||||
MemMove(name, text + i + 2, n);
|
||||
name[n] = 0;
|
||||
x += DrawChip(name, x, y - 1);
|
||||
w = hitX < 0 ? DrawChip(name, x, y - 1) : ChipWidth(name);
|
||||
if (hitX >= 0 && hitX < x + w)
|
||||
return -1;
|
||||
x += w;
|
||||
i = start = end + 1;
|
||||
}
|
||||
WinDrawChars(text + start, len - start, x, y);
|
||||
}
|
||||
|
||||
static void DrawLine(UInt16 row, const RectangleType *b, void *ctx)
|
||||
@@ -253,7 +276,7 @@ static void DrawLine(UInt16 row, const RectangleType *b, void *ctx)
|
||||
StrPrintF(buf, "%02u:%02u", dt.hour, dt.minute);
|
||||
WinDrawChars(buf, StrLen(buf), x + TIME_X, y);
|
||||
}
|
||||
DrawTextWithMentions(text, l->len, x + TEXT_X, y);
|
||||
TextWithMentions(text, l->len, x + TEXT_X, y, -1);
|
||||
if (l->last) {
|
||||
SuffixOf(h, buf);
|
||||
if (buf[0])
|
||||
@@ -371,13 +394,56 @@ static void InsertMention(const Char *sender)
|
||||
DrawCounter();
|
||||
}
|
||||
|
||||
/* Tap a failed message of ours to retry it, or someone's channel message to reply to them. */
|
||||
static void Tapped(UInt16 row)
|
||||
/* An emoji (or its neighbour, they're narrow) under the pen: show it enlarged. */
|
||||
static Boolean TappedEmoji(UInt16 row, Coord penX)
|
||||
{
|
||||
const VmMsgHeader *h = MessagesLock(gLines[row].msg);
|
||||
FormType *form = FrmGetActiveForm();
|
||||
const Line *l = &gLines[row];
|
||||
const VmMsgHeader *h;
|
||||
const Char *text;
|
||||
RectangleType b;
|
||||
FontID old;
|
||||
Int16 k;
|
||||
Char c[3];
|
||||
UInt16 n = 0, i;
|
||||
|
||||
if (l->kind != L_TEXT)
|
||||
return false;
|
||||
h = MessagesLock(l->msg);
|
||||
if (!h)
|
||||
return false;
|
||||
FrmGetObjectBounds(form, FrmGetObjectIndex(form, ConvoGadget), &b);
|
||||
text = (const Char *)(h + 1) + l->off;
|
||||
old = FntSetFont(vmSmallFont);
|
||||
k = TextWithMentions(text, l->len, b.topLeft.x + TEXT_X, 0, penX);
|
||||
FntSetFont(old);
|
||||
if (k >= 0) {
|
||||
c[n++] = text[k];
|
||||
if (k > 0)
|
||||
c[n++] = text[k - 1];
|
||||
if (k + 1 < (Int16)l->len)
|
||||
c[n++] = text[k + 1];
|
||||
}
|
||||
MessagesRelease(l->msg);
|
||||
for (i = 0; i < n; i++)
|
||||
if (EmojiShow(c[i]))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tap an emoji to see it enlarged, a failed message of ours to retry it, or
|
||||
* someone's channel message to reply to them.
|
||||
*/
|
||||
static void Tapped(UInt16 row, Coord penX)
|
||||
{
|
||||
const VmMsgHeader *h;
|
||||
Boolean failed, reply;
|
||||
Char sender[VM_NAME_SIZE];
|
||||
|
||||
if (TappedEmoji(row, penX))
|
||||
return;
|
||||
h = MessagesLock(gLines[row].msg);
|
||||
if (!h)
|
||||
return;
|
||||
failed = h->dir == VM_DIR_OUT && h->status == VM_ST_FAILED;
|
||||
@@ -466,7 +532,7 @@ Boolean ConvoFormHandleEvent(EventType *event)
|
||||
|
||||
if (gLines && RowListHandleEvent(&gList, event, &tapped)) {
|
||||
if (tapped >= 0)
|
||||
Tapped((UInt16)tapped);
|
||||
Tapped((UInt16)tapped, event->screenX);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -157,6 +157,7 @@
|
||||
|
||||
#define SmallFontRes 1000
|
||||
#define LargeFontRes 1001
|
||||
#define EmojiArtRes 1002
|
||||
#define FontPreviewForm 1400
|
||||
#define FontPreviewDoneButton 1401
|
||||
|
||||
|
||||
@@ -71,6 +71,11 @@ void DrawSection(const Char *label, Coord x0, Coord y, Coord width)
|
||||
#define CHIP_PAD_X 2
|
||||
#define CHIP_PAD_Y 1
|
||||
|
||||
Coord ChipWidth(const Char *text)
|
||||
{
|
||||
return FntCharsWidth(text, StrLen(text)) + 2 * CHIP_PAD_X;
|
||||
}
|
||||
|
||||
Coord DrawChip(const Char *text, Coord x, Coord y)
|
||||
{
|
||||
UInt16 len = StrLen(text);
|
||||
|
||||
@@ -27,6 +27,8 @@ void DrawSection(const Char *label, Coord x, Coord y, Coord width) VM_SECT2;
|
||||
/* A name chip: text inverted (white on black), VM_CHIP_H tall. Returns its width. */
|
||||
#define VM_CHIP_H (gUiFontHeight + 2)
|
||||
Coord DrawChip(const Char *text, Coord x, Coord y) VM_SECT2;
|
||||
/* The width DrawChip would take, without drawing. */
|
||||
Coord ChipWidth(const Char *text) VM_SECT2;
|
||||
|
||||
/* Draws text in the current font, cut with an ellipsis to fit maxW. Returns the width drawn. */
|
||||
Coord DrawCut(const Char *text, Coord x, Coord y, Coord maxW) VM_SECT2;
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
#include <PalmOS.h>
|
||||
#include "../resources.h"
|
||||
#include "draw.h"
|
||||
#include "emoji.h"
|
||||
|
||||
static void WaitForTap(void) VM_SECT3;
|
||||
|
||||
#define ENTRY 56 /* code, name[23], 16 rows of 2 bytes */
|
||||
#define NAME_SIZE 23
|
||||
#define SCALE 2
|
||||
#define BOX_W 104
|
||||
#define BOX_H 70
|
||||
|
||||
/* Until a tap (down and up) or a key; the tap that opened the box is still queued. */
|
||||
static void WaitForTap(void)
|
||||
{
|
||||
EventType e;
|
||||
Boolean down = false;
|
||||
|
||||
for (;;) {
|
||||
EvtGetEvent(&e, evtWaitForever);
|
||||
if (e.eType == appStopEvent) {
|
||||
EvtAddEventToQueue(&e);
|
||||
return;
|
||||
}
|
||||
if (e.eType == keyDownEvent)
|
||||
return;
|
||||
if (e.eType == penDownEvent)
|
||||
down = true;
|
||||
else if (e.eType == penUpEvent && down)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Boolean EmojiShow(Char c)
|
||||
{
|
||||
MemHandle h = DmGetResource('EMJI', EmojiArtRes);
|
||||
const UInt8 *p, *e = NULL;
|
||||
UInt8 bits[32];
|
||||
Char name[NAME_SIZE + 1];
|
||||
RectangleType box, save, px;
|
||||
WinHandle under;
|
||||
UInt16 i, err, row, col, rowBits;
|
||||
Coord x0, y0;
|
||||
FontID old;
|
||||
|
||||
if (!h)
|
||||
return false;
|
||||
p = (const UInt8 *)MemHandleLock(h);
|
||||
for (i = 0; i < p[0]; i++)
|
||||
if (p[1 + i * ENTRY] == (UInt8)c)
|
||||
e = p + 1 + i * ENTRY;
|
||||
if (e) {
|
||||
MemMove(name, e + 1, NAME_SIZE);
|
||||
name[NAME_SIZE] = 0;
|
||||
MemMove(bits, e + 1 + NAME_SIZE, sizeof(bits));
|
||||
}
|
||||
MemHandleUnlock(h);
|
||||
DmReleaseResource(h);
|
||||
if (!e)
|
||||
return false;
|
||||
|
||||
RctSetRectangle(&box, (160 - BOX_W) / 2, 40, BOX_W, BOX_H);
|
||||
RctSetRectangle(&save, box.topLeft.x - 3, box.topLeft.y - 3, BOX_W + 6, BOX_H + 6);
|
||||
under = WinSaveBits(&save, &err);
|
||||
WinEraseRectangle(&box, 0);
|
||||
WinDrawRectangleFrame(dialogFrame, &box);
|
||||
|
||||
x0 = box.topLeft.x + (BOX_W - 16 * SCALE) / 2;
|
||||
y0 = box.topLeft.y + 4;
|
||||
for (row = 0; row < 16; row++) {
|
||||
rowBits = (UInt16)((bits[2 * row] << 8) | bits[2 * row + 1]);
|
||||
for (col = 0; col < 16; col++) {
|
||||
if (!(rowBits & (0x8000 >> col)))
|
||||
continue;
|
||||
RctSetRectangle(&px, x0 + col * SCALE, y0 + row * SCALE, SCALE, SCALE);
|
||||
WinDrawRectangle(&px, 0);
|
||||
}
|
||||
}
|
||||
old = FntSetFont(stdFont);
|
||||
WinDrawChars(name, StrLen(name), box.topLeft.x + (BOX_W - FntCharsWidth(name, StrLen(name))) / 2,
|
||||
y0 + 16 * SCALE + 3);
|
||||
FntSetFont(vmSmallFont);
|
||||
WinDrawChars("tap to close", 12, box.topLeft.x + (BOX_W - FntCharsWidth("tap to close", 12)) / 2,
|
||||
box.topLeft.y + BOX_H - gUiFontHeight - 3);
|
||||
FntSetFont(old);
|
||||
|
||||
WaitForTap();
|
||||
if (under)
|
||||
WinRestoreBits(under, save.topLeft.x, save.topLeft.y);
|
||||
else
|
||||
FrmUpdateForm(FrmGetActiveFormID(), frmRedrawUpdateCode);
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* The enlarged view of an emoji: its 16x16 picture at double size and its
|
||||
* name, in a box over the screen until the next tap. The pictures come from
|
||||
* resources/emoji.bin (tools/gen_font.py), a resource rather than a table in
|
||||
* the code (see sections.h).
|
||||
*/
|
||||
#ifndef VM_EMOJI_H
|
||||
#define VM_EMOJI_H
|
||||
|
||||
#include <PalmOS.h>
|
||||
#include "../sections.h"
|
||||
|
||||
/* Shows c if it's one of the font's emoji (or GLYPH_EMOJI); false if it isn't one. */
|
||||
Boolean EmojiShow(Char c) VM_SECT3;
|
||||
|
||||
#endif
|
||||
@@ -13,7 +13,7 @@ UInt8 gSmallFontWidths[256] = {
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
5, 5, 5, 4, 5, 4, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4,
|
||||
5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 4, 4, 4,
|
||||
5, 6, 5, 5, 5, 5, 6, 5, 6, 5, 6, 4, 6, 5, 10, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
@@ -31,7 +31,7 @@ UInt8 gLargeFontWidths[256] = {
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 6, 5, 5, 5, 5, 6, 5, 6, 5, 6, 5, 6, 5, 10, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
||||
|
||||
@@ -21,6 +21,18 @@
|
||||
#define GLYPH_PENDING ((Char)0x90)
|
||||
#define GLYPH_EMOJI ((Char)0x99)
|
||||
#define GLYPH_FORWARD ((Char)0x9B)
|
||||
#define GLYPH_THUMBS ((Char)0x91)
|
||||
#define GLYPH_LAUGH ((Char)0x92)
|
||||
#define GLYPH_HEART ((Char)0x93)
|
||||
#define GLYPH_CRY ((Char)0x94)
|
||||
#define GLYPH_PRAY ((Char)0x95)
|
||||
#define GLYPH_WAVE ((Char)0x96)
|
||||
#define GLYPH_FIRE ((Char)0x97)
|
||||
#define GLYPH_PARTY ((Char)0x98)
|
||||
#define GLYPH_THINK ((Char)0x9A)
|
||||
#define GLYPH_EYES ((Char)0x9C)
|
||||
#define GLYPH_DISH ((Char)0x9D)
|
||||
#define GLYPH_HUNDRED ((Char)0x9E)
|
||||
|
||||
#define VM_SMALL_FONT_HEIGHT 6
|
||||
#define VM_LARGE_FONT_HEIGHT 8
|
||||
|
||||
@@ -137,8 +137,25 @@ UInt16 TxtSplitSender(const Char *text, UInt16 len)
|
||||
*/
|
||||
static Char MapUnicode(UInt32 cp)
|
||||
{
|
||||
if (cp == 0xFE0F || cp == 0xFE0E || (cp >= 0x200B && cp <= 0x200F) || cp == 0x2060)
|
||||
return 0; /* invisible */
|
||||
if (cp == 0xFE0F || cp == 0xFE0E || (cp >= 0x200B && cp <= 0x200F) || cp == 0x2060 ||
|
||||
(cp >= 0x1F3FB && cp <= 0x1F3FF))
|
||||
return 0; /* invisible; skin tones: the plain emoji */
|
||||
/* the emoji with their own glyph (tools/gen_font.py EMOJI); the rest get GLYPH_EMOJI */
|
||||
switch (cp) {
|
||||
case 0x1F44D: return GLYPH_THUMBS;
|
||||
case 0x1F602: case 0x1F923: return GLYPH_LAUGH;
|
||||
case 0x2764: case 0x2665: case 0x1F499: case 0x1F49A: case 0x1F49B: case 0x1F49C:
|
||||
case 0x1F5A4: case 0x1F90D: case 0x1F90E: case 0x1F9E1: return GLYPH_HEART;
|
||||
case 0x1F622: case 0x1F62D: return GLYPH_CRY;
|
||||
case 0x1F64F: return GLYPH_PRAY;
|
||||
case 0x1F44B: return GLYPH_WAVE;
|
||||
case 0x1F525: return GLYPH_FIRE;
|
||||
case 0x1F389: case 0x1F973: return GLYPH_PARTY;
|
||||
case 0x1F914: return GLYPH_THINK;
|
||||
case 0x1F440: return GLYPH_EYES;
|
||||
case 0x1F4E1: return GLYPH_DISH;
|
||||
case 0x1F4AF: return GLYPH_HUNDRED;
|
||||
}
|
||||
if ((cp >= 0x1F000 && cp <= 0x1FAFF) || (cp >= 0x2600 && cp <= 0x27BF && cp != 0x2605 &&
|
||||
cp != 0x2713 && cp != 0x2714 && cp != 0x2717 && cp != 0x2718 && cp != 0x2705 && cp != 0x274C))
|
||||
return GLYPH_EMOJI;
|
||||
|
||||
@@ -80,6 +80,20 @@ static void test_age_and_snr(void)
|
||||
{
|
||||
char buf[16];
|
||||
|
||||
{
|
||||
/* thumbs up with a skin tone, tears of joy, rolling (same glyph), a heart with VS16, 100, a rocket */
|
||||
static const UInt8 em[] = {
|
||||
0xF0, 0x9F, 0x91, 0x8D, 0xF0, 0x9F, 0x8F, 0xBD,
|
||||
0xF0, 0x9F, 0x98, 0x82, 0xF0, 0x9F, 0xA4, 0xA3,
|
||||
0xE2, 0x9D, 0xA4, 0xEF, 0xB8, 0x8F,
|
||||
0xF0, 0x9F, 0x92, 0xAF, 0xF0, 0x9F, 0x9A, 0x80
|
||||
};
|
||||
Char o[16];
|
||||
|
||||
CHECK(TxtUtf8ToPalm(em, sizeof(em), o, sizeof(o)) == 6);
|
||||
CHECK(o[0] == GLYPH_THUMBS && o[1] == GLYPH_LAUGH && o[2] == GLYPH_LAUGH);
|
||||
CHECK(o[3] == GLYPH_HEART && o[4] == GLYPH_HUNDRED && o[5] == GLYPH_EMOJI);
|
||||
}
|
||||
{
|
||||
static const UInt8 key[] = { 0x00, 0x9c, 0xd8, 0xff, 0x0a };
|
||||
Char hex[11];
|
||||
@@ -120,7 +134,7 @@ static void test_utf8(void)
|
||||
|
||||
CHECK(TxtUtf8ToPalm(cafe, sizeof(cafe), out, sizeof(out)) == 4 && (unsigned char)out[3] == 0xE9);
|
||||
CHECK(TxtUtf8ToPalm(dots, sizeof(dots), out, sizeof(out)) == 2 && out[1] == GLYPH_ELLIPSIS);
|
||||
CHECK(TxtUtf8ToPalm(emoji, sizeof(emoji), out, sizeof(out)) == 4 && out[3] == GLYPH_EMOJI);
|
||||
CHECK(TxtUtf8ToPalm(emoji, sizeof(emoji), out, sizeof(out)) == 4 && out[3] == GLYPH_WAVE);
|
||||
{
|
||||
/* "a→b" (arrow), "“hi”" (curly quotes), "x—y" (em dash), "❤️" (heart + VS16) */
|
||||
static const UInt8 arrow[] = { 'a', 0xE2, 0x86, 0x92, 'b' };
|
||||
@@ -132,7 +146,7 @@ static void test_utf8(void)
|
||||
CHECK(TxtUtf8ToPalm(arrow, sizeof(arrow), out, sizeof(out)) == 3 && out[1] == GLYPH_RIGHT);
|
||||
CHECK(TxtUtf8ToPalm(quotes, sizeof(quotes), out, sizeof(out)) == 4 && strcmp(out, "\"hi\"") == 0);
|
||||
CHECK(TxtUtf8ToPalm(dash, sizeof(dash), out, sizeof(out)) == 3 && strcmp(out, "x-y") == 0);
|
||||
CHECK(TxtUtf8ToPalm(heart, sizeof(heart), out, sizeof(out)) == 1 && out[0] == GLYPH_EMOJI);
|
||||
CHECK(TxtUtf8ToPalm(heart, sizeof(heart), out, sizeof(out)) == 1 && out[0] == GLYPH_HEART);
|
||||
CHECK(TxtUtf8ToPalm(check, sizeof(check), out, sizeof(out)) == 1 && out[0] == GLYPH_ACKED);
|
||||
}
|
||||
CHECK(TxtUtf8ToPalm(broken, sizeof(broken), out, sizeof(out)) == 2 && strcmp(out, "x?") == 0);
|
||||
|
||||
@@ -11,6 +11,8 @@ Outputs:
|
||||
resources/smallfont.txt the same glyphs as text, for reading and diffs
|
||||
src/ui/glyphs.h code points for the UI symbols
|
||||
src/ui/fontmetrics.c per-character widths of both, for text layout
|
||||
resources/emoji.bin 16x16 pictures and names of the emoji in the font,
|
||||
for the tap-to-enlarge view (ui/emoji.c)
|
||||
|
||||
Palm fonts are 8-bit: 0x20-0x7E and 0xA0-0xFF come from the BDF (ASCII and
|
||||
Latin-1); the UI symbols go in 0x80-0x9F, reusing Windows-1252's slots where it
|
||||
@@ -23,6 +25,7 @@ HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
RES = os.path.join(HERE, '..', 'resources')
|
||||
OUT_GLYPHS = os.path.join(HERE, '..', 'src', 'ui', 'glyphs.h')
|
||||
OUT_METRICS = os.path.join(HERE, '..', 'src', 'ui', 'fontmetrics.c')
|
||||
OUT_EMOJI = os.path.join(HERE, '..', 'resources', 'emoji.bin')
|
||||
|
||||
# (name, BDF, ascent, descent): the hand-drawn symbols below are drawn for the
|
||||
# small font's 5 + 1 and are padded to the larger cell, sitting on the baseline.
|
||||
@@ -56,6 +59,214 @@ SYMBOLS = [
|
||||
(0x9B, 'GLYPH_FORWARD', 0x203A),
|
||||
]
|
||||
|
||||
# The emoji with their own glyph (src/ui/text.c MapUnicode says which code points
|
||||
# land on each): (code point in the font, C name, 6-row glyph, 16x16 picture for
|
||||
# the enlarged view, name shown there). GLYPH_EMOJI, the stand-in for the rest,
|
||||
# comes first in emoji.bin.
|
||||
FACE = [
|
||||
'.....######.....',
|
||||
'...##......##...',
|
||||
'..#..........#..',
|
||||
'.#............#.',
|
||||
'.#............#.',
|
||||
'#..............#',
|
||||
'#..............#',
|
||||
'#..............#',
|
||||
'#..............#',
|
||||
'#..............#',
|
||||
'.#............#.',
|
||||
'.#............#.',
|
||||
'..#..........#..',
|
||||
'...##......##...',
|
||||
'.....######.....',
|
||||
'................',
|
||||
]
|
||||
|
||||
|
||||
def face(features):
|
||||
"""FACE with (row, col) pixels added."""
|
||||
rows = [list(r) for r in FACE]
|
||||
for r, c in features:
|
||||
rows[r][c] = '#'
|
||||
return [''.join(r) for r in rows]
|
||||
|
||||
|
||||
def pts(row, cols):
|
||||
return [(row, c) for c in cols]
|
||||
|
||||
|
||||
EMOJI = [
|
||||
(0x99, 'GLYPH_EMOJI', None,
|
||||
face(pts(5, [5, 10]) + pts(6, [5, 10]) + pts(9, [4, 11]) + pts(10, [5, 10]) + pts(11, [6, 7, 8, 9])),
|
||||
"Not in the Visor's set"),
|
||||
(0x91, 'GLYPH_THUMBS', ['--#---', '-##---', '#####-', '#####-', '####--', '------'], [
|
||||
'................',
|
||||
'.......##.......',
|
||||
'......#..#......',
|
||||
'......#..#......',
|
||||
'.....#...#......',
|
||||
'.....#...#......',
|
||||
'....#....######.',
|
||||
'###.#.........#.',
|
||||
'#.#.#........##.',
|
||||
'#.#.#.........#.',
|
||||
'#.#.#........##.',
|
||||
'#.#.#.........#.',
|
||||
'#.#.#........##.',
|
||||
'###..########...',
|
||||
'................',
|
||||
'................'], 'Thumbs up'),
|
||||
(0x92, 'GLYPH_LAUGH', ['-###-', '##-##', '#####', '##-##', '-###-', '#---#'],
|
||||
face(pts(4, [5, 10]) + pts(5, [4, 6, 9, 11]) + pts(6, [3, 12]) + pts(7, [3, 12]) +
|
||||
pts(8, range(3, 13)) + pts(9, [3, 12]) + pts(10, [4, 11]) + pts(11, range(5, 11))), 'Tears of joy'),
|
||||
(0x93, 'GLYPH_HEART', ['##-##', '#####', '#####', '-###-', '--#--', '-----'], [
|
||||
'................',
|
||||
'..####....####..',
|
||||
'.######..######.',
|
||||
'################',
|
||||
'################',
|
||||
'################',
|
||||
'################',
|
||||
'.##############.',
|
||||
'..############..',
|
||||
'...##########...',
|
||||
'....########....',
|
||||
'.....######.....',
|
||||
'......####......',
|
||||
'.......##.......',
|
||||
'................',
|
||||
'................'], 'Red heart'),
|
||||
(0x94, 'GLYPH_CRY', ['-###-', '##-##', '#---#', '#-#-#', '-###-', '-#---'],
|
||||
face(pts(5, [4, 5, 10, 11]) + pts(6, [4, 5, 10, 11]) + pts(8, [4]) + pts(9, [4]) +
|
||||
pts(10, range(5, 11)) + pts(11, [4, 11])), 'Crying face'),
|
||||
(0x95, 'GLYPH_PRAY', ['--#--', '-#-#-', '-#-#-', '#-#-#', '##-##', '-----'], [
|
||||
'......####......',
|
||||
'.....#.##.#.....',
|
||||
'.....#.##.#.....',
|
||||
'.....#.##.#.....',
|
||||
'....#..##..#....',
|
||||
'....#..##..#....',
|
||||
'...#...##...#...',
|
||||
'...#...##...#...',
|
||||
'..#....##....#..',
|
||||
'..#....##....#..',
|
||||
'..#....##....#..',
|
||||
'..#...#..#...#..',
|
||||
'..#..#....#..#..',
|
||||
'.####......####.',
|
||||
'.####......####.',
|
||||
'................'], 'Folded hands'),
|
||||
(0x96, 'GLYPH_WAVE', ['-#-#--', '#-#-#-', '#####-', '#####-', '-###--', '------'], [
|
||||
'...#.#.#........',
|
||||
'...#.#.#.#......',
|
||||
'...#.#.#.#...#..',
|
||||
'...#.#.#.#..#...',
|
||||
'...#.#.#.#.#..#.',
|
||||
'...#######.#.#..',
|
||||
'...#.......#.#..',
|
||||
'...#......#.....',
|
||||
'...#.....#..#...',
|
||||
'...#....#..#....',
|
||||
'....#..#........',
|
||||
'.....##.........',
|
||||
'................',
|
||||
'................',
|
||||
'................',
|
||||
'................'], 'Waving hand'),
|
||||
(0x97, 'GLYPH_FIRE', ['--#--', '-##-#', '-####', '##-##', '-###-', '-----'], [
|
||||
'.......#........',
|
||||
'.......##.......',
|
||||
'......###.......',
|
||||
'......####......',
|
||||
'.....#####...#..',
|
||||
'....#######.##..',
|
||||
'....##########..',
|
||||
'...###########..',
|
||||
'..#####.######..',
|
||||
'..####...#####..',
|
||||
'..###.....####..',
|
||||
'..###..#..###...',
|
||||
'..###.###.###...',
|
||||
'...##.###.##....',
|
||||
'....#######.....',
|
||||
'................'], 'Fire'),
|
||||
(0x98, 'GLYPH_PARTY', ['--#-#-', '#--#--', '-##-#-', '-###--', '####--', '------'], [
|
||||
'.......#....#...',
|
||||
'...#.........#..',
|
||||
'.....#..##......',
|
||||
'#......#..#..#..',
|
||||
'......#...#.....',
|
||||
'.....#....#..#..',
|
||||
'....#.....#.....',
|
||||
'...#.....#...#..',
|
||||
'..#.....#.......',
|
||||
'..#....#....#...',
|
||||
'.#....#.........',
|
||||
'.#...#....#.....',
|
||||
'#...#...........',
|
||||
'#.##............',
|
||||
'##..............',
|
||||
'................'], 'Party popper'),
|
||||
(0x9A, 'GLYPH_THINK', ['-###--', '##-##-', '#---#-', '#-###-', '-##--#', '---##-'],
|
||||
face(pts(3, [9, 10, 11]) + pts(5, [5, 10]) + pts(6, [5, 10]) + pts(10, range(6, 10))) [:12] + [
|
||||
'..####.##.......',
|
||||
'.#....#.........',
|
||||
'.#....#.........',
|
||||
'..####..........'], 'Thinking face'),
|
||||
(0x9C, 'GLYPH_EYES', ['------', '##-##-', '#####-', '##-##-', '------', '------'], [
|
||||
'................',
|
||||
'................',
|
||||
'................',
|
||||
'..####....####..',
|
||||
'.#....#..#....#.',
|
||||
'#......##......#',
|
||||
'#...##.##...##.#',
|
||||
'#...##.##...##.#',
|
||||
'#......##......#',
|
||||
'.#....#..#....#.',
|
||||
'..####....####..',
|
||||
'................',
|
||||
'................',
|
||||
'................',
|
||||
'................',
|
||||
'................'], 'Eyes'),
|
||||
(0x9D, 'GLYPH_DISH', ['-#-#-', '#-#-#', '--#--', '-###-', '#-#-#', '-----'], [
|
||||
'................',
|
||||
'..#....#....#...',
|
||||
'.#..#..#..#..#..',
|
||||
'.#.#...#...#.#..',
|
||||
'.#.#..###..#.#..',
|
||||
'.#..#.###.#..#..',
|
||||
'..#...#.#...#...',
|
||||
'......#.#.......',
|
||||
'.....#...#......',
|
||||
'.....#...#......',
|
||||
'....#.###.#.....',
|
||||
'....#.....#.....',
|
||||
'...#.......#....',
|
||||
'...#.......#....',
|
||||
'..###.....###...',
|
||||
'................'], 'Antenna'),
|
||||
(0x9E, 'GLYPH_HUNDRED', ['#-###-###-', '#-#-#-#-#-', '#-#-#-#-#-', '#-###-###-', '----------', '#########-'], [
|
||||
'................',
|
||||
'................',
|
||||
'.##..###...###..',
|
||||
'###.#...#.#...#.',
|
||||
'.##.#...#.#...#.',
|
||||
'.##.#...#.#...#.',
|
||||
'.##.#...#.#...#.',
|
||||
'.##.#...#.#...#.',
|
||||
'.##.#...#.#...#.',
|
||||
'####.###...###..',
|
||||
'................',
|
||||
'###############.',
|
||||
'................',
|
||||
'###############.',
|
||||
'................',
|
||||
'................'], 'Hundred points'),
|
||||
]
|
||||
SYMBOLS += [(code, name, small) for code, name, small, _big, _title in EMOJI if small]
|
||||
|
||||
|
||||
def parse_bdf(path, ascent, descent):
|
||||
"""Returns {codepoint: (width, rows)} with rows as ascent + descent strings of '#'/'-'."""
|
||||
@@ -226,6 +437,17 @@ def main():
|
||||
f.write('\n#define VM_SMALL_FONT_HEIGHT %d\n#define VM_LARGE_FONT_HEIGHT %d\n\n#endif\n'
|
||||
% (heights['small'], heights['large']))
|
||||
|
||||
# emoji.bin: count, then per emoji: code, name[23], 16 rows of 2 bytes (MSB = left)
|
||||
out = bytearray([len(EMOJI)])
|
||||
for code, _cname, _small, big, title in EMOJI:
|
||||
assert len(big) == 16 and all(len(r) == 16 for r in big), (hex(code), [len(r) for r in big])
|
||||
out.append(code)
|
||||
out += title.encode('latin-1')[:22].ljust(23, b'\0')
|
||||
for r in big:
|
||||
out += int(r.replace('.', '0').replace('#', '1'), 2).to_bytes(2, 'big')
|
||||
with open(OUT_EMOJI, 'wb') as f:
|
||||
f.write(out)
|
||||
|
||||
with open(OUT_METRICS, 'w') as f:
|
||||
f.write('/* GENERATED by tools/gen_font.py: UI font character widths in pixels. */\n')
|
||||
f.write('#include "fontmetrics.h"\n\n')
|
||||
|
||||
Reference in new issue
Block a user