fix(linux): improve color emoji fallback and reaction painting (#12)
Bundle a prepared CBDT Noto Color Emoji face, exclude conflicting system COLRv1 fonts via a temporary fontconfig, add a desktop file, and paint hover-bar reactions with the emoji family.
@@ -22,6 +22,8 @@ pub mod fuzzy;
22
22
pub mod image_clipboard;
23
23
pub mod image_view_math;
24
24
pub mod inline_image;
25
#[cfg(target_os = "linux")]
26
pub mod linux_fonts;
25
27
pub mod native_dumps;
26
28
pub mod notify;
27
29
pub mod presence_link;
@@ -36,9 +38,12 @@ pub mod stickers;
36
38
pub mod task_dialog;
37
39
pub mod theme;
38
40
pub mod translation;
41
pub mod ui_locale;
39
42
pub mod updater;
40
43
pub mod user_activity;
41
44
pub mod version;
42
45
pub mod zoom;
43
46
44
47
pub const APP_NAME: &str = "Rusty Teams";
48
49
rust_i18n::i18n!("locales", fallback = "en");
@@ -22,6 +22,8 @@ pub mod fuzzy;22
pub mod image_clipboard;22
pub mod image_clipboard;23
pub mod image_view_math;23
pub mod image_view_math;24
pub mod inline_image;24
pub mod inline_image;25
#[cfg(target_os = "linux")]26
pub mod linux_fonts;25
pub mod native_dumps;27
pub mod native_dumps;26
pub mod notify;28
pub mod notify;27
pub mod presence_link;29
pub mod presence_link;@@ -36,9 +38,12 @@ pub mod stickers;36
pub mod task_dialog;38
pub mod task_dialog;37
pub mod theme;39
pub mod theme;38
pub mod translation;40
pub mod translation;41
pub mod ui_locale;39
pub mod updater;42
pub mod updater;40
pub mod user_activity;43
pub mod user_activity;41
pub mod version;44
pub mod version;42
pub mod zoom;45
pub mod zoom;43
46
44
pub const APP_NAME: &str = "Rusty Teams";47
pub const APP_NAME: &str = "Rusty Teams";48
49
rust_i18n::i18n!("locales", fallback = "en");@@ -0,0 +1,228 @@
1
//! Hide a system Noto Color Emoji face before GPUI loads fonts.
2
//!
3
//! Cosmic Text on Linux falls back to the family "Noto Color Emoji", and
4
//! fontdb returns the first face of that name. A COLRv1-only face draws
5
//! blank. The app bundles a CBDT build of the same name and loads it with
6
//! `add_fonts`. fontdb only honors `<dir>` entries from `FONTCONFIG_FILE`,
7
//! so this module rewrites those directories and leaves the system color
8
//! emoji file out. An existing `FONTCONFIG_FILE` is left alone.
9
10
use std::collections::HashSet;
11
use std::fs;
12
use std::path::{Path, PathBuf};
13
14
const FONT_EXTENSIONS: &[&str] = &["ttf", "ttc", "otf", "otc"];
15
16
/// A system color-emoji file that would win the "Noto Color Emoji" lookup.
17
pub fn is_system_color_emoji_file(name: &str) -> bool {
18
let lower = name.to_ascii_lowercase();
19
let stem = lower
20
.rsplit_once('.')
21
.map(|(stem, _)| stem)
22
.unwrap_or(lower.as_str());
23
stem == "notocoloremoji"
24
|| stem.starts_with("notocoloremoji-")
25
|| (stem.contains("noto") && stem.contains("colrv1"))
26
}
27
28
/// Point `FONTCONFIG_FILE` at a font list that omits the system color emoji face.
29
pub fn hide_system_color_emoji() {
30
if std::env::var_os("FONTCONFIG_FILE").is_some() {
31
log::info!("FONTCONFIG_FILE is already set, leaving the system emoji font alone");
32
return;
33
}
34
let Some(cache) = directories::ProjectDirs::from("", "", store::DATA_DIR_NAME) else {
35
return;
36
};
37
let staging = cache.cache_dir().join("fontconfig-emoji");
38
let _ = fs::remove_dir_all(&staging);
39
if fs::create_dir_all(&staging).is_err() {
40
return;
41
}
42
let dirs: Vec<PathBuf> = font_roots()
43
.into_iter()
44
.enumerate()
45
.filter_map(|(index, root)| publish_root(&root, &staging, index))
46
.collect();
47
if dirs.is_empty() {
48
return;
49
}
50
let config = staging.join("fonts.conf");
51
if write_config(&config, &dirs).is_err() {
52
return;
53
}
54
unsafe { std::env::set_var("FONTCONFIG_FILE", &config) };
55
log::info!("emoji fontconfig {}", config.display());
56
}
57
58
fn font_roots() -> Vec<PathBuf> {
59
let mut roots = Vec::new();
60
let data_dirs =
61
std::env::var("XDG_DATA_DIRS").unwrap_or_else(|_| "/usr/local/share:/usr/share".to_owned());
62
for dir in data_dirs.split(':').filter(|dir| !dir.is_empty()) {
63
roots.push(PathBuf::from(dir).join("fonts"));
64
}
65
if let Ok(xdg) = std::env::var("XDG_DATA_HOME") {
66
roots.push(PathBuf::from(xdg).join("fonts"));
67
} else if let Ok(home) = std::env::var("HOME") {
68
roots.push(PathBuf::from(home).join(".local/share/fonts"));
69
}
70
if let Ok(home) = std::env::var("HOME") {
71
roots.push(PathBuf::from(home).join(".fonts"));
72
}
73
roots.retain(|path| path.is_dir());
74
roots.sort();
75
roots.dedup();
76
roots
77
}
78
79
/// Use `root` as-is when it has no color emoji file. Otherwise mirror it and skip that file.
80
pub(crate) fn publish_root(root: &Path, staging: &Path, index: usize) -> Option<PathBuf> {
81
if !contains_emoji(root) {
82
return Some(root.to_path_buf());
83
}
84
let dest = staging.join(format!("root-{index}"));
85
let mut seen = HashSet::new();
86
mirror(root, &dest, &mut seen).then_some(dest)
87
}
88
89
fn contains_emoji(dir: &Path) -> bool {
90
fn walk(dir: &Path, seen: &mut HashSet<PathBuf>) -> bool {
91
let canon = fs::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf());
92
if !seen.insert(canon) {
93
return false;
94
}
95
let Ok(entries) = fs::read_dir(dir) else {
96
return false;
97
};
98
for entry in entries.flatten() {
99
let path = entry.path();
100
let Ok(meta) = fs::metadata(&path) else {
101
continue;
102
};
103
if meta.is_dir() {
104
if walk(&path, seen) {
105
return true;
106
}
107
} else if is_system_color_emoji_file(&entry.file_name().to_string_lossy()) {
108
return true;
109
}
110
}
111
false
112
}
113
walk(dir, &mut HashSet::new())
114
}
115
116
fn mirror(src: &Path, dest: &Path, seen: &mut HashSet<PathBuf>) -> bool {
117
let canon = fs::canonicalize(src).unwrap_or_else(|_| src.to_path_buf());
118
if !seen.insert(canon) {
119
return false;
120
}
121
let Ok(entries) = fs::read_dir(src) else {
122
return false;
123
};
124
let mut wrote = false;
125
for entry in entries.flatten() {
126
let path = entry.path();
127
let name = entry.file_name();
128
let Ok(meta) = fs::metadata(&path) else {
129
continue;
130
};
131
if meta.is_dir() {
132
if contains_emoji(&path) {
133
let child = dest.join(&name);
134
let _ = fs::create_dir_all(&child);
135
wrote |= mirror(&path, &child, seen);
136
} else {
137
let _ = fs::create_dir_all(dest);
138
wrote |= symlink_to(&path, &dest.join(&name)).is_ok();
139
}
140
} else if is_font_file(&name.to_string_lossy())
141
&& !is_system_color_emoji_file(&name.to_string_lossy())
142
{
143
let _ = fs::create_dir_all(dest);
144
wrote |= symlink_to(&path, &dest.join(&name)).is_ok();
145
}
146
}
147
wrote
148
}
149
150
fn is_font_file(name: &str) -> bool {
151
name.rsplit_once('.').is_some_and(|(_, extension)| {
152
FONT_EXTENSIONS
153
.iter()
154
.any(|known| extension.eq_ignore_ascii_case(known))
155
})
156
}
157
158
fn symlink_to(target: &Path, link: &Path) -> std::io::Result<()> {
159
let target = fs::canonicalize(target).unwrap_or_else(|_| target.to_path_buf());
160
std::os::unix::fs::symlink(target, link)
161
}
162
163
fn write_config(path: &Path, dirs: &[PathBuf]) -> std::io::Result<()> {
164
let mut body = String::from("<?xml version=\"1.0\"?>\n<fontconfig>\n");
165
for dir in dirs {
166
body.push_str(" <dir>");
167
body.push_str(&xml_escape(&dir.to_string_lossy()));
168
body.push_str("</dir>\n");
169
}
170
body.push_str("</fontconfig>\n");
171
fs::write(path, body)
172
}
173
174
fn xml_escape(text: &str) -> String {
175
text.replace('&', "&")
176
.replace('<', "<")
177
.replace('>', ">")
178
}
179
180
#[cfg(test)]
181
mod tests {
182
use super::*;
183
184
#[test]
185
fn color_emoji_file_names() {
186
assert!(is_system_color_emoji_file("NotoColorEmoji.ttf"));
187
assert!(is_system_color_emoji_file("Noto-COLRv1.ttf"));
188
assert!(is_system_color_emoji_file("NotoColorEmoji-emojicompat.ttf"));
189
assert!(!is_system_color_emoji_file("NotoSans-Regular.ttf"));
190
assert!(!is_system_color_emoji_file("NotoEmoji-Regular.ttf"));
191
}
192
193
#[test]
194
fn publish_root_drops_the_color_emoji_file_and_keeps_the_rest() {
195
let temp = tempfile::tempdir().unwrap();
196
let root = temp.path().join("fonts");
197
let noto = root.join("noto");
198
let other = root.join("liberation");
199
fs::create_dir_all(¬o).unwrap();
200
fs::create_dir_all(&other).unwrap();
201
fs::write(noto.join("NotoColorEmoji.ttf"), b"emoji").unwrap();
202
fs::write(noto.join("NotoSans-Regular.ttf"), b"sans").unwrap();
203
fs::write(other.join("LiberationSans.ttf"), b"serif").unwrap();
204
let staging = temp.path().join("staging");
205
fs::create_dir_all(&staging).unwrap();
206
let published = publish_root(&root, &staging, 0).unwrap();
207
assert!(published.starts_with(&staging));
208
assert!(!published.join("noto/NotoColorEmoji.ttf").exists());
209
assert_eq!(
210
fs::read(published.join("noto/NotoSans-Regular.ttf")).unwrap(),
211
b"sans"
212
);
213
assert_eq!(
214
fs::read(published.join("liberation/LiberationSans.ttf")).unwrap(),
215
b"serif"
216
);
217
}
218
219
#[test]
220
fn publish_root_keeps_a_tree_without_a_color_emoji_file() {
221
let temp = tempfile::tempdir().unwrap();
222
let root = temp.path().join("fonts");
223
fs::create_dir_all(&root).unwrap();
224
fs::write(root.join("DejaVuSans.ttf"), b"dejavu").unwrap();
225
let published = publish_root(&root, &temp.path().join("staging"), 0).unwrap();
226
assert_eq!(published, root);
227
}
228
}
@@ -0,0 +1,228 @@1
//! Hide a system Noto Color Emoji face before GPUI loads fonts.2
//!3
//! Cosmic Text on Linux falls back to the family "Noto Color Emoji", and4
//! fontdb returns the first face of that name. A COLRv1-only face draws5
//! blank. The app bundles a CBDT build of the same name and loads it with6
//! `add_fonts`. fontdb only honors `<dir>` entries from `FONTCONFIG_FILE`,7
//! so this module rewrites those directories and leaves the system color8
//! emoji file out. An existing `FONTCONFIG_FILE` is left alone.9
10
use std::collections::HashSet;11
use std::fs;12
use std::path::{Path, PathBuf};13
14
const FONT_EXTENSIONS: &[&str] = &["ttf", "ttc", "otf", "otc"];15
16
/// A system color-emoji file that would win the "Noto Color Emoji" lookup.17
pub fn is_system_color_emoji_file(name: &str) -> bool {18
let lower = name.to_ascii_lowercase();19
let stem = lower20
.rsplit_once('.')21
.map(|(stem, _)| stem)22
.unwrap_or(lower.as_str());23
stem == "notocoloremoji"24
|| stem.starts_with("notocoloremoji-")25
|| (stem.contains("noto") && stem.contains("colrv1"))26
}27
28
/// Point `FONTCONFIG_FILE` at a font list that omits the system color emoji face.29
pub fn hide_system_color_emoji() {30
if std::env::var_os("FONTCONFIG_FILE").is_some() {31
log::info!("FONTCONFIG_FILE is already set, leaving the system emoji font alone");32
return;33
}34
let Some(cache) = directories::ProjectDirs::from("", "", store::DATA_DIR_NAME) else {35
return;36
};37
let staging = cache.cache_dir().join("fontconfig-emoji");38
let _ = fs::remove_dir_all(&staging);39
if fs::create_dir_all(&staging).is_err() {40
return;41
}42
let dirs: Vec<PathBuf> = font_roots()43
.into_iter()44
.enumerate()45
.filter_map(|(index, root)| publish_root(&root, &staging, index))46
.collect();47
if dirs.is_empty() {48
return;49
}50
let config = staging.join("fonts.conf");51
if write_config(&config, &dirs).is_err() {52
return;53
}54
unsafe { std::env::set_var("FONTCONFIG_FILE", &config) };55
log::info!("emoji fontconfig {}", config.display());56
}57
58
fn font_roots() -> Vec<PathBuf> {59
let mut roots = Vec::new();60
let data_dirs =61
std::env::var("XDG_DATA_DIRS").unwrap_or_else(|_| "/usr/local/share:/usr/share".to_owned());62
for dir in data_dirs.split(':').filter(|dir| !dir.is_empty()) {63
roots.push(PathBuf::from(dir).join("fonts"));64
}65
if let Ok(xdg) = std::env::var("XDG_DATA_HOME") {66
roots.push(PathBuf::from(xdg).join("fonts"));67
} else if let Ok(home) = std::env::var("HOME") {68
roots.push(PathBuf::from(home).join(".local/share/fonts"));69
}70
if let Ok(home) = std::env::var("HOME") {71
roots.push(PathBuf::from(home).join(".fonts"));72
}73
roots.retain(|path| path.is_dir());74
roots.sort();75
roots.dedup();76
roots77
}78
79
/// Use `root` as-is when it has no color emoji file. Otherwise mirror it and skip that file.80
pub(crate) fn publish_root(root: &Path, staging: &Path, index: usize) -> Option<PathBuf> {81
if !contains_emoji(root) {82
return Some(root.to_path_buf());83
}84
let dest = staging.join(format!("root-{index}"));85
let mut seen = HashSet::new();86
mirror(root, &dest, &mut seen).then_some(dest)87
}88
89
fn contains_emoji(dir: &Path) -> bool {90
fn walk(dir: &Path, seen: &mut HashSet<PathBuf>) -> bool {91
let canon = fs::canonicalize(dir).unwrap_or_else(|_| dir.to_path_buf());92
if !seen.insert(canon) {93
return false;94
}95
let Ok(entries) = fs::read_dir(dir) else {96
return false;97
};98
for entry in entries.flatten() {99
let path = entry.path();100
let Ok(meta) = fs::metadata(&path) else {101
continue;102
};103
if meta.is_dir() {104
if walk(&path, seen) {105
return true;106
}107
} else if is_system_color_emoji_file(&entry.file_name().to_string_lossy()) {108
return true;109
}110
}111
false112
}113
walk(dir, &mut HashSet::new())114
}115
116
fn mirror(src: &Path, dest: &Path, seen: &mut HashSet<PathBuf>) -> bool {117
let canon = fs::canonicalize(src).unwrap_or_else(|_| src.to_path_buf());118
if !seen.insert(canon) {119
return false;120
}121
let Ok(entries) = fs::read_dir(src) else {122
return false;123
};124
let mut wrote = false;125
for entry in entries.flatten() {126
let path = entry.path();127
let name = entry.file_name();128
let Ok(meta) = fs::metadata(&path) else {129
continue;130
};131
if meta.is_dir() {132
if contains_emoji(&path) {133
let child = dest.join(&name);134
let _ = fs::create_dir_all(&child);135
wrote |= mirror(&path, &child, seen);136
} else {137
let _ = fs::create_dir_all(dest);138
wrote |= symlink_to(&path, &dest.join(&name)).is_ok();139
}140
} else if is_font_file(&name.to_string_lossy())141
&& !is_system_color_emoji_file(&name.to_string_lossy())142
{143
let _ = fs::create_dir_all(dest);144
wrote |= symlink_to(&path, &dest.join(&name)).is_ok();145
}146
}147
wrote148
}149
150
fn is_font_file(name: &str) -> bool {151
name.rsplit_once('.').is_some_and(|(_, extension)| {152
FONT_EXTENSIONS153
.iter()154
.any(|known| extension.eq_ignore_ascii_case(known))155
})156
}157
158
fn symlink_to(target: &Path, link: &Path) -> std::io::Result<()> {159
let target = fs::canonicalize(target).unwrap_or_else(|_| target.to_path_buf());160
std::os::unix::fs::symlink(target, link)161
}162
163
fn write_config(path: &Path, dirs: &[PathBuf]) -> std::io::Result<()> {164
let mut body = String::from("<?xml version=\"1.0\"?>\n<fontconfig>\n");165
for dir in dirs {166
body.push_str(" <dir>");167
body.push_str(&xml_escape(&dir.to_string_lossy()));168
body.push_str("</dir>\n");169
}170
body.push_str("</fontconfig>\n");171
fs::write(path, body)172
}173
174
fn xml_escape(text: &str) -> String {175
text.replace('&', "&")176
.replace('<', "<")177
.replace('>', ">")178
}179
180
#[cfg(test)]181
mod tests {182
use super::*;183
184
#[test]185
fn color_emoji_file_names() {186
assert!(is_system_color_emoji_file("NotoColorEmoji.ttf"));187
assert!(is_system_color_emoji_file("Noto-COLRv1.ttf"));188
assert!(is_system_color_emoji_file("NotoColorEmoji-emojicompat.ttf"));189
assert!(!is_system_color_emoji_file("NotoSans-Regular.ttf"));190
assert!(!is_system_color_emoji_file("NotoEmoji-Regular.ttf"));191
}192
193
#[test]194
fn publish_root_drops_the_color_emoji_file_and_keeps_the_rest() {195
let temp = tempfile::tempdir().unwrap();196
let root = temp.path().join("fonts");197
let noto = root.join("noto");198
let other = root.join("liberation");199
fs::create_dir_all(¬o).unwrap();200
fs::create_dir_all(&other).unwrap();201
fs::write(noto.join("NotoColorEmoji.ttf"), b"emoji").unwrap();202
fs::write(noto.join("NotoSans-Regular.ttf"), b"sans").unwrap();203
fs::write(other.join("LiberationSans.ttf"), b"serif").unwrap();204
let staging = temp.path().join("staging");205
fs::create_dir_all(&staging).unwrap();206
let published = publish_root(&root, &staging, 0).unwrap();207
assert!(published.starts_with(&staging));208
assert!(!published.join("noto/NotoColorEmoji.ttf").exists());209
assert_eq!(210
fs::read(published.join("noto/NotoSans-Regular.ttf")).unwrap(),211
b"sans"212
);213
assert_eq!(214
fs::read(published.join("liberation/LiberationSans.ttf")).unwrap(),215
b"serif"216
);217
}218
219
#[test]220
fn publish_root_keeps_a_tree_without_a_color_emoji_file() {221
let temp = tempfile::tempdir().unwrap();222
let root = temp.path().join("fonts");223
fs::create_dir_all(&root).unwrap();224
fs::write(root.join("DejaVuSans.ttf"), b"dejavu").unwrap();225
let published = publish_root(&root, &temp.path().join("staging"), 0).unwrap();226
assert_eq!(published, root);227
}228
}@@ -21,6 +21,16 @@ const FONT_FILES: [&[u8]; 4] = [
21
21
include_bytes!("../../app/assets/fonts/GoogleSansFlex-Bold.ttf"),
22
22
include_bytes!("../../app/assets/fonts/GoogleSansFlex-Italic.ttf"),
23
23
];
24
#[cfg(target_os = "linux")]
25
const EMOJI_FONT: &[u8] = include_bytes!("../../app/assets/fonts/NotoColorEmoji.ttf");
26
27
/// Family used for emoji glyphs. On Linux this is the bundled CBDT face.
28
#[cfg(target_os = "windows")]
29
pub const EMOJI_FONT_FAMILY: &str = "Segoe UI Emoji";
30
#[cfg(target_os = "macos")]
31
pub const EMOJI_FONT_FAMILY: &str = "Apple Color Emoji";
32
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
33
pub const EMOJI_FONT_FAMILY: &str = "Noto Color Emoji";
24
34
25
35
#[cfg(target_os = "linux")]
26
36
const PLATFORM_FONT_FILES: [&[u8]; 1] = [include_bytes!("../../app/assets/fonts/NotoColorEmoji.ttf")];
@@ -427,6 +437,24 @@ mod tests {
427
437
set_thread_shade(None);
428
438
}
429
439
440
#[cfg(target_os = "linux")]
441
#[test]
442
fn bundled_emoji_font_is_cbdt_noto() {
443
let bytes = include_bytes!("../../app/assets/fonts/NotoColorEmoji.ttf");
444
assert!(bytes.windows(4).any(|window| window == b"CBDT"));
445
assert!(bytes.windows(4).any(|window| window == b"CBLC"));
446
assert!(!bytes.windows(4).any(|window| window == b"COLR"));
447
let postscript: Vec<u8> = "NotoColorEmoji"
448
.encode_utf16()
449
.flat_map(|unit| unit.to_be_bytes())
450
.collect();
451
assert!(
452
bytes
453
.windows(postscript.len())
454
.any(|window| window == postscript)
455
);
456
}
457
430
458
#[test]
431
459
fn fluent_shadow_blur_is_halved_for_gpui() {
432
460
let shadow = super::flyout_shadow();
@@ -21,6 +21,16 @@ const FONT_FILES: [&[u8]; 4] = [21
include_bytes!("../../app/assets/fonts/GoogleSansFlex-Bold.ttf"),21
include_bytes!("../../app/assets/fonts/GoogleSansFlex-Bold.ttf"),22
include_bytes!("../../app/assets/fonts/GoogleSansFlex-Italic.ttf"),22
include_bytes!("../../app/assets/fonts/GoogleSansFlex-Italic.ttf"),23
];23
];24
#[cfg(target_os = "linux")]25
const EMOJI_FONT: &[u8] = include_bytes!("../../app/assets/fonts/NotoColorEmoji.ttf");26
27
/// Family used for emoji glyphs. On Linux this is the bundled CBDT face.28
#[cfg(target_os = "windows")]29
pub const EMOJI_FONT_FAMILY: &str = "Segoe UI Emoji";30
#[cfg(target_os = "macos")]31
pub const EMOJI_FONT_FAMILY: &str = "Apple Color Emoji";32
#[cfg(not(any(target_os = "windows", target_os = "macos")))]33
pub const EMOJI_FONT_FAMILY: &str = "Noto Color Emoji";24
34
25
#[cfg(target_os = "linux")]35
#[cfg(target_os = "linux")]26
const PLATFORM_FONT_FILES: [&[u8]; 1] = [include_bytes!("../../app/assets/fonts/NotoColorEmoji.ttf")];36
const PLATFORM_FONT_FILES: [&[u8]; 1] = [include_bytes!("../../app/assets/fonts/NotoColorEmoji.ttf")];@@ -427,6 +437,24 @@ mod tests {427
set_thread_shade(None);437
set_thread_shade(None);428
}438
}429
439
440
#[cfg(target_os = "linux")]441
#[test]442
fn bundled_emoji_font_is_cbdt_noto() {443
let bytes = include_bytes!("../../app/assets/fonts/NotoColorEmoji.ttf");444
assert!(bytes.windows(4).any(|window| window == b"CBDT"));445
assert!(bytes.windows(4).any(|window| window == b"CBLC"));446
assert!(!bytes.windows(4).any(|window| window == b"COLR"));447
let postscript: Vec<u8> = "NotoColorEmoji"448
.encode_utf16()449
.flat_map(|unit| unit.to_be_bytes())450
.collect();451
assert!(452
bytes453
.windows(postscript.len())454
.any(|window| window == postscript)455
);456
}457
430
#[test]458
#[test]431
fn fluent_shadow_blur_is_halved_for_gpui() {459
fn fluent_shadow_blur_is_halved_for_gpui() {432
let shadow = super::flyout_shadow();460
let shadow = super::flyout_shadow();@@ -373,12 +373,6 @@ fn code_font(cx: &App) -> SharedString {
373
373
cx.theme().mono_font_family.clone()
374
374
}
375
375
376
#[cfg(target_os = "windows")]
377
const EMOJI_FONT_FAMILY: &str = "Segoe UI Emoji";
378
#[cfg(target_os = "macos")]
379
const EMOJI_FONT_FAMILY: &str = "Apple Color Emoji";
380
#[cfg(not(any(target_os = "windows", target_os = "macos")))]
381
const EMOJI_FONT_FAMILY: &str = "Noto Color Emoji";
382
376
const KEYCAP: char = '\u{20e3}';
383
377
const VARIATION_SELECTOR: char = '\u{fe0f}';
384
378
@@ -406,7 +400,8 @@ fn render_inline(inline: &Inline, id: String, own: bool, cx: &App) -> AnyElement
406
400
.map(|segment| (segment.range.clone(), highlight_for(segment.style, own)))
407
401
.collect::<Vec<_>>();
408
402
let mono = code_font(cx);
409
let font_overrides = inline
403
let emoji_family = SharedString::from(theme::EMOJI_FONT_FAMILY);
404
let mut font_overrides: Vec<_> = inline
410
405
.segments
411
406
.iter()
412
407
.filter(|segment| segment.style.code)
@@ -414,9 +409,17 @@ fn render_inline(inline: &Inline, id: String, own: bool, cx: &App) -> AnyElement
414
409
.chain(
415
410
keycap_ranges(&inline.text)
416
411
.into_iter()
417
.map(|range| (range, SharedString::from(EMOJI_FONT_FAMILY))),
412
.map(|range| (range, emoji_family.clone())),
413
)
414
.chain(
415
inline
416
.segments
417
.iter()
418
.filter(|segment| segment.emoji.is_some())
419
.map(|segment| (segment.range.clone(), emoji_family.clone())),
418
420
)
419
421
.collect();
422
font_overrides.sort_by_key(|(range, _)| range.start);
420
423
let emoji = inline.emoji();
421
424
let highlights = highlights
422
425
.into_iter()
@@ -456,7 +459,11 @@ fn render_inline(inline: &Inline, id: String, own: bool, cx: &App) -> AnyElement
456
459
},
457
460
None => highlight_for(segment.style, own),
458
461
},
459
family: segment.style.code.then(|| mono.clone()),
462
family: if segment.emoji.is_some() {
463
Some(SharedString::from(theme::EMOJI_FONT_FAMILY))
464
} else {
465
segment.style.code.then(|| mono.clone())
466
},
460
467
scale: segment.style.font_scale(),
461
468
raise: segment.style.baseline_raise(),
462
469
})
@@ -373,12 +373,6 @@ fn code_font(cx: &App) -> SharedString {373
cx.theme().mono_font_family.clone()373
cx.theme().mono_font_family.clone()374
}374
}375
375
376
#[cfg(target_os = "windows")]377
const EMOJI_FONT_FAMILY: &str = "Segoe UI Emoji";378
#[cfg(target_os = "macos")]379
const EMOJI_FONT_FAMILY: &str = "Apple Color Emoji";380
#[cfg(not(any(target_os = "windows", target_os = "macos")))]381
const EMOJI_FONT_FAMILY: &str = "Noto Color Emoji";382
const KEYCAP: char = '\u{20e3}';376
const KEYCAP: char = '\u{20e3}';383
const VARIATION_SELECTOR: char = '\u{fe0f}';377
const VARIATION_SELECTOR: char = '\u{fe0f}';384
378
@@ -406,7 +400,8 @@ fn render_inline(inline: &Inline, id: String, own: bool, cx: &App) -> AnyElement406
.map(|segment| (segment.range.clone(), highlight_for(segment.style, own)))400
.map(|segment| (segment.range.clone(), highlight_for(segment.style, own)))407
.collect::<Vec<_>>();401
.collect::<Vec<_>>();408
let mono = code_font(cx);402
let mono = code_font(cx);409
let font_overrides = inline403
let emoji_family = SharedString::from(theme::EMOJI_FONT_FAMILY);404
let mut font_overrides: Vec<_> = inline410
.segments405
.segments411
.iter()406
.iter()412
.filter(|segment| segment.style.code)407
.filter(|segment| segment.style.code)@@ -414,9 +409,17 @@ fn render_inline(inline: &Inline, id: String, own: bool, cx: &App) -> AnyElement414
.chain(409
.chain(415
keycap_ranges(&inline.text)410
keycap_ranges(&inline.text)416
.into_iter()411
.into_iter()417
.map(|range| (range, SharedString::from(EMOJI_FONT_FAMILY))),412
.map(|range| (range, emoji_family.clone())),413
)414
.chain(415
inline416
.segments417
.iter()418
.filter(|segment| segment.emoji.is_some())419
.map(|segment| (segment.range.clone(), emoji_family.clone())),418
)420
)419
.collect();421
.collect();422
font_overrides.sort_by_key(|(range, _)| range.start);420
let emoji = inline.emoji();423
let emoji = inline.emoji();421
let highlights = highlights424
let highlights = highlights422
.into_iter()425
.into_iter()@@ -456,7 +459,11 @@ fn render_inline(inline: &Inline, id: String, own: bool, cx: &App) -> AnyElement456
},459
},457
None => highlight_for(segment.style, own),460
None => highlight_for(segment.style, own),458
},461
},459
family: segment.style.code.then(|| mono.clone()),462
family: if segment.emoji.is_some() {463
Some(SharedString::from(theme::EMOJI_FONT_FAMILY))464
} else {465
segment.style.code.then(|| mono.clone())466
},460
scale: segment.style.font_scale(),467
scale: segment.style.font_scale(),461
raise: segment.style.baseline_raise(),468
raise: segment.style.baseline_raise(),462
})469
})The contents of this binary file are not shown.
@@ -0,0 +1,12 @@
1
Copyright 2022 Google Inc.
2
3
Noto Color Emoji (CBDT/CBLC) from
4
https://github.com/googlefonts/noto-emoji/tree/main/2D/fonts
5
6
Rusty Teams adds a cmap entry for U+006D, mapped onto an existing glyph, so
7
GPUI keeps the face when a text run asks for this family. The family name
8
"Noto Color Emoji" and the PostScript name "NotoColorEmoji" are unchanged.
9
The upstream copyright declares no Reserved Font Name.
10
11
This Font Software is licensed under the SIL Open Font License, Version 1.1.
12
The license text is in OFL.txt in this directory.
@@ -0,0 +1,12 @@1
Copyright 2022 Google Inc.2
3
Noto Color Emoji (CBDT/CBLC) from4
https://github.com/googlefonts/noto-emoji/tree/main/2D/fonts5
6
Rusty Teams adds a cmap entry for U+006D, mapped onto an existing glyph, so7
GPUI keeps the face when a text run asks for this family. The family name8
"Noto Color Emoji" and the PostScript name "NotoColorEmoji" are unchanged.9
The upstream copyright declares no Reserved Font Name.10
11
This Font Software is licensed under the SIL Open Font License, Version 1.1.12
The license text is in OFL.txt in this directory.@@ -0,0 +1,9 @@
1
[Desktop Entry]
2
Type=Application
3
Name=Rusty Teams
4
Comment=A fast, native Microsoft Teams chat client
5
Exec=teams
6
Icon=rusty-teams
7
StartupWMClass=rusty-teams
8
Terminal=false
9
Categories=Network;InstantMessaging;
@@ -0,0 +1,9 @@1
[Desktop Entry]2
Type=Application3
Name=Rusty Teams4
Comment=A fast, native Microsoft Teams chat client5
Exec=teams6
Icon=rusty-teams7
StartupWMClass=rusty-teams8
Terminal=false9
Categories=Network;InstantMessaging;@@ -176,6 +176,8 @@ fn main() {
176
176
data_path(crash_log::CRASH_LOG_FILE),
177
177
);
178
178
diagnostics::install(data_path(diagnostics::DIAGNOSTICS_FILE));
179
#[cfg(target_os = "linux")]
180
app_base::linux_fonts::hide_system_color_emoji();
179
181
let arguments = parse_arguments();
180
182
if !arguments.demo && arguments.database.is_none() {
181
183
let relaunch_value = std::env::var(updater::RELAUNCH_ENV).ok();
@@ -176,6 +176,8 @@ fn main() {176
data_path(crash_log::CRASH_LOG_FILE),176
data_path(crash_log::CRASH_LOG_FILE),177
);177
);178
diagnostics::install(data_path(diagnostics::DIAGNOSTICS_FILE));178
diagnostics::install(data_path(diagnostics::DIAGNOSTICS_FILE));179
#[cfg(target_os = "linux")]180
app_base::linux_fonts::hide_system_color_emoji();179
let arguments = parse_arguments();181
let arguments = parse_arguments();180
if !arguments.demo && arguments.database.is_none() {182
if !arguments.demo && arguments.database.is_none() {181
let relaunch_value = std::env::var(updater::RELAUNCH_ENV).ok();183
let relaunch_value = std::env::var(updater::RELAUNCH_ENV).ok();@@ -12,6 +12,7 @@ use gpui_kit::*;
12
12
13
13
use super::reaction_picker::ReactionPicker;
14
14
use super::widgets::{Corner, corner_badge, icon};
15
use crate::i18n::tr;
15
16
use crate::app_state::AppState;
16
17
use crate::default_reactions::{
17
18
filled, place_in_slot, quick_reaction_glyphs, reaction_id_for_glyph, slots_for,
@@ -124,9 +125,12 @@ impl CustomizeForm {
124
125
.rounded(px(10.))
125
126
.tooltip(label)
126
127
.map(|button| match &glyph {
127
Some(glyph) => {
128
button.child(div().text_size(px(SLOT_GLYPH_SIZE)).child(glyph.clone()))
129
}
128
Some(glyph) => button.child(
129
div()
130
.text_size(px(SLOT_GLYPH_SIZE))
131
.font_family(theme::EMOJI_FONT_FAMILY)
132
.child(glyph.clone()),
133
),
130
134
None => button.child(icon(IconName::Plus, 18., theme::text_muted())),
131
135
});
132
136
let (picker, view) = (self.picker.clone(), cx.entity().downgrade());
@@ -196,6 +200,7 @@ impl CustomizeForm {
196
200
.rounded_full()
197
201
.cursor_pointer()
198
202
.text_size(px(TONE_GLYPH_SIZE))
203
.font_family(theme::EMOJI_FONT_FAMILY)
199
204
.when(selected, |choice| choice.bg(theme::reaction_on_own()))
200
205
.when(!selected, |choice| {
201
206
choice.hover(|choice| choice.bg(theme::popup_hover()))
@@ -248,13 +253,13 @@ pub fn open_customize_reactions(state: Entity<AppState>, window: &mut Window, cx
248
253
let footer = DialogFooter::new()
249
254
.child(
250
255
Button::new("customize-reactions-cancel")
251
.label("Cancel")
256
.label(tr("common.cancel"))
252
257
.on_click(|_, window, cx| window.close_dialog(cx)),
253
258
)
254
259
.child(
255
260
Button::new("customize-reactions-save")
256
261
.primary()
257
.label("Save")
262
.label(tr("common.save"))
258
263
.disabled(unchanged)
259
264
.on_click(move |_, window, cx| {
260
265
submit_form.update(cx, |form, cx| form.save(window, cx));
@@ -12,6 +12,7 @@ use gpui_kit::*;12
12
13
use super::reaction_picker::ReactionPicker;13
use super::reaction_picker::ReactionPicker;14
use super::widgets::{Corner, corner_badge, icon};14
use super::widgets::{Corner, corner_badge, icon};15
use crate::i18n::tr;15
use crate::app_state::AppState;16
use crate::app_state::AppState;16
use crate::default_reactions::{17
use crate::default_reactions::{17
filled, place_in_slot, quick_reaction_glyphs, reaction_id_for_glyph, slots_for,18
filled, place_in_slot, quick_reaction_glyphs, reaction_id_for_glyph, slots_for,@@ -124,9 +125,12 @@ impl CustomizeForm {124
.rounded(px(10.))125
.rounded(px(10.))125
.tooltip(label)126
.tooltip(label)126
.map(|button| match &glyph {127
.map(|button| match &glyph {127
Some(glyph) => {128
Some(glyph) => button.child(128
button.child(div().text_size(px(SLOT_GLYPH_SIZE)).child(glyph.clone()))129
div()129
}130
.text_size(px(SLOT_GLYPH_SIZE))131
.font_family(theme::EMOJI_FONT_FAMILY)132
.child(glyph.clone()),133
),130
None => button.child(icon(IconName::Plus, 18., theme::text_muted())),134
None => button.child(icon(IconName::Plus, 18., theme::text_muted())),131
});135
});132
let (picker, view) = (self.picker.clone(), cx.entity().downgrade());136
let (picker, view) = (self.picker.clone(), cx.entity().downgrade());@@ -196,6 +200,7 @@ impl CustomizeForm {196
.rounded_full()200
.rounded_full()197
.cursor_pointer()201
.cursor_pointer()198
.text_size(px(TONE_GLYPH_SIZE))202
.text_size(px(TONE_GLYPH_SIZE))203
.font_family(theme::EMOJI_FONT_FAMILY)199
.when(selected, |choice| choice.bg(theme::reaction_on_own()))204
.when(selected, |choice| choice.bg(theme::reaction_on_own()))200
.when(!selected, |choice| {205
.when(!selected, |choice| {201
choice.hover(|choice| choice.bg(theme::popup_hover()))206
choice.hover(|choice| choice.bg(theme::popup_hover()))@@ -248,13 +253,13 @@ pub fn open_customize_reactions(state: Entity<AppState>, window: &mut Window, cx248
let footer = DialogFooter::new()253
let footer = DialogFooter::new()249
.child(254
.child(250
Button::new("customize-reactions-cancel")255
Button::new("customize-reactions-cancel")251
.label("Cancel")256
.label(tr("common.cancel"))252
.on_click(|_, window, cx| window.close_dialog(cx)),257
.on_click(|_, window, cx| window.close_dialog(cx)),253
)258
)254
.child(259
.child(255
Button::new("customize-reactions-save")260
Button::new("customize-reactions-save")256
.primary()261
.primary()257
.label("Save")262
.label(tr("common.save"))258
.disabled(unchanged)263
.disabled(unchanged)259
.on_click(move |_, window, cx| {264
.on_click(move |_, window, cx| {260
submit_form.update(cx, |form, cx| form.save(window, cx));265
submit_form.update(cx, |form, cx| form.save(window, cx));@@ -116,6 +116,7 @@ fn row(index: usize, found: &Match, selected: bool, skin_tone: u8) -> Stateful<D
116
116
.text_center()
117
117
.text_size(px(20.))
118
118
.line_height(px(ROW_HEIGHT))
119
.font_family(theme::EMOJI_FONT_FAMILY)
119
120
.child(emoticons::with_tone(found.glyph, skin_tone)),
120
121
)
121
122
.child(highlighted_text(code, code_highlight, 13., theme::text()))
@@ -116,6 +116,7 @@ fn row(index: usize, found: &Match, selected: bool, skin_tone: u8) -> Stateful<D116
.text_center()116
.text_center()117
.text_size(px(20.))117
.text_size(px(20.))118
.line_height(px(ROW_HEIGHT))118
.line_height(px(ROW_HEIGHT))119
.font_family(theme::EMOJI_FONT_FAMILY)119
.child(emoticons::with_tone(found.glyph, skin_tone)),120
.child(emoticons::with_tone(found.glyph, skin_tone)),120
)121
)121
.child(highlighted_text(code, code_highlight, 13., theme::text()))122
.child(highlighted_text(code, code_highlight, 13., theme::text()))@@ -2,8 +2,8 @@ use crate::views::image_memory::bounded;
2
2
use std::rc::Rc;
3
3
use std::time::Duration;
4
4
5
use gpui_kit::component::scroll::ScrollableElement as _;
6
5
use gpui_kit::base::PopoverState;
6
use gpui_kit::component::scroll::ScrollableElement as _;
7
7
use gpui_kit::component::{
8
8
h_flex,
9
9
input::{Input, InputEvent, InputState},
@@ -28,7 +28,8 @@ const HEIGHT: f32 = 380.;
28
28
const PADDING: f32 = 8.;
29
29
const CONTENT_WIDTH: f32 = WIDTH - 2. * PADDING;
30
30
const EMOJI_COLUMNS: usize = 10;
31
const EMOJI_CELL: f32 = (CONTENT_WIDTH - EMOJI_GAP * (EMOJI_COLUMNS - 1) as f32) / EMOJI_COLUMNS as f32;
31
const EMOJI_CELL: f32 =
32
(CONTENT_WIDTH - EMOJI_GAP * (EMOJI_COLUMNS - 1) as f32) / EMOJI_COLUMNS as f32;
32
33
const EMOJI_GAP: f32 = 2.;
33
34
const EMOJI_SEARCH_LIMIT: usize = 240;
34
35
const GIF_COLUMNS: usize = 3;
@@ -342,7 +343,8 @@ impl FunPicker {
342
343
343
344
fn pick_tone(&mut self, glyph: &str, tone: u8, cx: &mut Context<Self>) {
344
345
self.skin_tone = tone;
345
self.app.update(cx, |state, cx| state.set_skin_tone(tone, cx));
346
self.app
347
.update(cx, |state, cx| state.set_skin_tone(tone, cx));
346
348
self.pick_emoji(&emoticons::with_tone(glyph, tone), cx);
347
349
}
348
350
@@ -466,6 +468,7 @@ impl FunPicker {
466
468
.justify_center()
467
469
.rounded(px(6.))
468
470
.text_size(px(20.))
471
.font_family(theme::EMOJI_FONT_FAMILY)
469
472
.cursor_pointer()
470
473
.hover(|cell| cell.bg(theme::popup_hover()))
471
474
.child(shown)
@@ -2,8 +2,8 @@ use crate::views::image_memory::bounded;2
use std::rc::Rc;2
use std::rc::Rc;3
use std::time::Duration;3
use std::time::Duration;4
4
5
use gpui_kit::component::scroll::ScrollableElement as _;6
use gpui_kit::base::PopoverState;5
use gpui_kit::base::PopoverState;6
use gpui_kit::component::scroll::ScrollableElement as _;7
use gpui_kit::component::{7
use gpui_kit::component::{8
h_flex,8
h_flex,9
input::{Input, InputEvent, InputState},9
input::{Input, InputEvent, InputState},@@ -28,7 +28,8 @@ const HEIGHT: f32 = 380.;28
const PADDING: f32 = 8.;28
const PADDING: f32 = 8.;29
const CONTENT_WIDTH: f32 = WIDTH - 2. * PADDING;29
const CONTENT_WIDTH: f32 = WIDTH - 2. * PADDING;30
const EMOJI_COLUMNS: usize = 10;30
const EMOJI_COLUMNS: usize = 10;31
const EMOJI_CELL: f32 = (CONTENT_WIDTH - EMOJI_GAP * (EMOJI_COLUMNS - 1) as f32) / EMOJI_COLUMNS as f32;31
const EMOJI_CELL: f32 =32
(CONTENT_WIDTH - EMOJI_GAP * (EMOJI_COLUMNS - 1) as f32) / EMOJI_COLUMNS as f32;32
const EMOJI_GAP: f32 = 2.;33
const EMOJI_GAP: f32 = 2.;33
const EMOJI_SEARCH_LIMIT: usize = 240;34
const EMOJI_SEARCH_LIMIT: usize = 240;34
const GIF_COLUMNS: usize = 3;35
const GIF_COLUMNS: usize = 3;@@ -342,7 +343,8 @@ impl FunPicker {342
343
343
fn pick_tone(&mut self, glyph: &str, tone: u8, cx: &mut Context<Self>) {344
fn pick_tone(&mut self, glyph: &str, tone: u8, cx: &mut Context<Self>) {344
self.skin_tone = tone;345
self.skin_tone = tone;345
self.app.update(cx, |state, cx| state.set_skin_tone(tone, cx));346
self.app347
.update(cx, |state, cx| state.set_skin_tone(tone, cx));346
self.pick_emoji(&emoticons::with_tone(glyph, tone), cx);348
self.pick_emoji(&emoticons::with_tone(glyph, tone), cx);347
}349
}348
350
@@ -466,6 +468,7 @@ impl FunPicker {466
.justify_center()468
.justify_center()467
.rounded(px(6.))469
.rounded(px(6.))468
.text_size(px(20.))470
.text_size(px(20.))471
.font_family(theme::EMOJI_FONT_FAMILY)469
.cursor_pointer()472
.cursor_pointer()470
.hover(|cell| cell.bg(theme::popup_hover()))473
.hover(|cell| cell.bg(theme::popup_hover()))471
.child(shown)474
.child(shown)@@ -31,6 +31,7 @@ fn glyph(emoji: &JumboEmoji) -> AnyElement {
31
31
.flex()
32
32
.items_center()
33
33
.text_size(px(GLYPH_SIZE))
34
.font_family(theme::EMOJI_FONT_FAMILY)
34
35
.text_color(theme::text())
35
36
.child(emoji.glyph.clone())
36
37
.into_any_element()
@@ -31,6 +31,7 @@ fn glyph(emoji: &JumboEmoji) -> AnyElement {31
.flex()31
.flex()32
.items_center()32
.items_center()33
.text_size(px(GLYPH_SIZE))33
.text_size(px(GLYPH_SIZE))34
.font_family(theme::EMOJI_FONT_FAMILY)34
.text_color(theme::text())35
.text_color(theme::text())35
.child(emoji.glyph.clone())36
.child(emoji.glyph.clone())36
.into_any_element()37
.into_any_element()@@ -15,8 +15,8 @@ use gpui_kit::*;
15
15
use super::reaction_picker::{DoneHandler, PickHandler, ReactionPicker};
16
16
use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};
17
17
use super::widgets::{icon, symbol};
18
use crate::post_follow::follow_label;
19
18
use crate::forward_selection::{FORWARD_LABEL, MULTIPLE_MESSAGES_LABEL, THIS_MESSAGE_LABEL};
19
use crate::post_follow::follow_label;
20
20
use crate::rows::reaction_glyph;
21
21
use crate::share_outlook::SHARE_TO_OUTLOOK_LABEL;
22
22
use crate::theme::{self, ElevatedSurface as _};
@@ -100,6 +100,7 @@ pub(super) fn reaction_button(menu: &MessageMenu, glyph: &str, index: usize) ->
100
100
let selected = menu.mine.contains(&reaction_glyph(glyph));
101
101
bar_button(element_id(&format!("quick-reaction-{index}"), &menu.key))
102
102
.text_size(px(17.))
103
.font_family(theme::EMOJI_FONT_FAMILY)
103
104
.when(selected, |button| button.bg(theme::reaction_on_own()))
104
105
.child(glyph.to_owned())
105
106
.on_click(move |_, window, cx| {
@@ -133,7 +134,12 @@ impl MessageMenu {
133
134
}
134
135
}
135
136
136
fn picker_popover(adder: ReactionAdder, prefix: &str, trigger: Button, anchor: Anchor) -> AnyElement {
137
fn picker_popover(
138
adder: ReactionAdder,
139
prefix: &str,
140
trigger: Button,
141
anchor: Anchor,
142
) -> AnyElement {
137
143
let ReactionAdder {
138
144
key,
139
145
picker,
@@ -15,8 +15,8 @@ use gpui_kit::*;15
use super::reaction_picker::{DoneHandler, PickHandler, ReactionPicker};15
use super::reaction_picker::{DoneHandler, PickHandler, ReactionPicker};16
use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};16
use super::toolbar_placement::{HoverChange, TOOLBAR_HEIGHT, toolbar_slot};17
use super::widgets::{icon, symbol};17
use super::widgets::{icon, symbol};18
use crate::post_follow::follow_label;19
use crate::forward_selection::{FORWARD_LABEL, MULTIPLE_MESSAGES_LABEL, THIS_MESSAGE_LABEL};18
use crate::forward_selection::{FORWARD_LABEL, MULTIPLE_MESSAGES_LABEL, THIS_MESSAGE_LABEL};19
use crate::post_follow::follow_label;20
use crate::rows::reaction_glyph;20
use crate::rows::reaction_glyph;21
use crate::share_outlook::SHARE_TO_OUTLOOK_LABEL;21
use crate::share_outlook::SHARE_TO_OUTLOOK_LABEL;22
use crate::theme::{self, ElevatedSurface as _};22
use crate::theme::{self, ElevatedSurface as _};@@ -100,6 +100,7 @@ pub(super) fn reaction_button(menu: &MessageMenu, glyph: &str, index: usize) ->100
let selected = menu.mine.contains(&reaction_glyph(glyph));100
let selected = menu.mine.contains(&reaction_glyph(glyph));101
bar_button(element_id(&format!("quick-reaction-{index}"), &menu.key))101
bar_button(element_id(&format!("quick-reaction-{index}"), &menu.key))102
.text_size(px(17.))102
.text_size(px(17.))103
.font_family(theme::EMOJI_FONT_FAMILY)103
.when(selected, |button| button.bg(theme::reaction_on_own()))104
.when(selected, |button| button.bg(theme::reaction_on_own()))104
.child(glyph.to_owned())105
.child(glyph.to_owned())105
.on_click(move |_, window, cx| {106
.on_click(move |_, window, cx| {@@ -133,7 +134,12 @@ impl MessageMenu {133
}134
}134
}135
}135
136
136
fn picker_popover(adder: ReactionAdder, prefix: &str, trigger: Button, anchor: Anchor) -> AnyElement {137
fn picker_popover(138
adder: ReactionAdder,139
prefix: &str,140
trigger: Button,141
anchor: Anchor,142
) -> AnyElement {137
let ReactionAdder {143
let ReactionAdder {138
key,144
key,139
picker,145
picker,@@ -295,6 +295,7 @@ impl ReactionPicker {
295
295
.justify_center()
296
296
.rounded(px(6.))
297
297
.text_size(px(20.))
298
.font_family(theme::EMOJI_FONT_FAMILY)
298
299
.cursor_pointer()
299
300
.when(selected, |cell| cell.bg(theme::reaction_on_own()))
300
301
.hover(|cell| cell.bg(theme::popup_hover()))
@@ -295,6 +295,7 @@ impl ReactionPicker {295
.justify_center()295
.justify_center()296
.rounded(px(6.))296
.rounded(px(6.))297
.text_size(px(20.))297
.text_size(px(20.))298
.font_family(theme::EMOJI_FONT_FAMILY)298
.cursor_pointer()299
.cursor_pointer()299
.when(selected, |cell| cell.bg(theme::reaction_on_own()))300
.when(selected, |cell| cell.bg(theme::reaction_on_own()))300
.hover(|cell| cell.bg(theme::popup_hover()))301
.hover(|cell| cell.bg(theme::popup_hover()))@@ -2,8 +2,8 @@ use crate::views::image_memory::bounded;
2
2
use std::rc::Rc;
3
3
4
4
use chrono::Local;
5
use gpui_kit::component::scroll::ScrollableElement as _;
6
5
use gpui_kit::base::GlobalState;
6
use gpui_kit::component::scroll::ScrollableElement as _;
7
7
use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};
8
8
use gpui_kit::prelude::FluentBuilder as _;
9
9
use gpui_kit::*;
@@ -80,6 +80,7 @@ fn reaction_emoji(glyph: &str, label: &str, size: f32, directory: &Directory) ->
80
80
.flex_none()
81
81
.h(px(size))
82
82
.text_size(px(size))
83
.font_family(theme::EMOJI_FONT_FAMILY)
83
84
.line_height(px(size))
84
85
.child(label.to_owned())
85
86
.into_any_element();
@@ -120,9 +121,7 @@ fn pill_content(chip: &ReactionChip, background: Hsla, directory: &Directory) ->
120
121
),
121
122
)
122
123
} else {
123
content
124
.gap(px(PILL_GAP))
125
.child(chip.count.to_string())
124
content.gap(px(PILL_GAP)).child(chip.count.to_string())
126
125
}
127
126
}
128
127
@@ -162,7 +161,11 @@ fn pill(
162
161
.h(px(PILL_HEIGHT))
163
162
.flex_none()
164
163
.pl(px(5.))
165
.pr(px(if shows_faces(chip.reactors.len()) { 2. } else { 8. }))
164
.pr(px(if shows_faces(chip.reactors.len()) {
165
2.
166
} else {
167
8.
168
}))
166
169
.items_center()
167
170
.rounded(px(PILL_HEIGHT / 2.))
168
171
.bg(background)
@@ -2,8 +2,8 @@ use crate::views::image_memory::bounded;2
use std::rc::Rc;2
use std::rc::Rc;3
3
4
use chrono::Local;4
use chrono::Local;5
use gpui_kit::component::scroll::ScrollableElement as _;6
use gpui_kit::base::GlobalState;5
use gpui_kit::base::GlobalState;6
use gpui_kit::component::scroll::ScrollableElement as _;7
use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};7
use gpui_kit::component::{h_flex, tooltip::Tooltip, v_flex};8
use gpui_kit::prelude::FluentBuilder as _;8
use gpui_kit::prelude::FluentBuilder as _;9
use gpui_kit::*;9
use gpui_kit::*;@@ -80,6 +80,7 @@ fn reaction_emoji(glyph: &str, label: &str, size: f32, directory: &Directory) ->80
.flex_none()80
.flex_none()81
.h(px(size))81
.h(px(size))82
.text_size(px(size))82
.text_size(px(size))83
.font_family(theme::EMOJI_FONT_FAMILY)83
.line_height(px(size))84
.line_height(px(size))84
.child(label.to_owned())85
.child(label.to_owned())85
.into_any_element();86
.into_any_element();@@ -120,9 +121,7 @@ fn pill_content(chip: &ReactionChip, background: Hsla, directory: &Directory) ->120
),121
),121
)122
)122
} else {123
} else {123
content124
content.gap(px(PILL_GAP)).child(chip.count.to_string())124
.gap(px(PILL_GAP))125
.child(chip.count.to_string())126
}125
}127
}126
}128
127
@@ -162,7 +161,11 @@ fn pill(162
.h(px(PILL_HEIGHT))161
.h(px(PILL_HEIGHT))163
.flex_none()162
.flex_none()164
.pl(px(5.))163
.pl(px(5.))165
.pr(px(if shows_faces(chip.reactors.len()) { 2. } else { 8. }))164
.pr(px(if shows_faces(chip.reactors.len()) {165
2.166
} else {167
8.168
}))166
.items_center()169
.items_center()167
.rounded(px(PILL_HEIGHT / 2.))170
.rounded(px(PILL_HEIGHT / 2.))168
.bg(background)171
.bg(background)@@ -0,0 +1,47 @@
1
"""Keep a CBDT Noto Color Emoji face loadable by GPUI.
2
3
GPUI drops a requested family when the face has no glyph for "m", and it
4
only paints color bitmaps for the PostScript name NotoColorEmoji. Cosmic Text
5
on Linux falls back to the family name Noto Color Emoji. This script leaves
6
both names alone and maps U+006D onto an existing glyph so the face survives
7
that check. The system COLRv1 face of the same name is hidden at runtime.
8
"""
9
10
import sys
11
from fontTools.ttLib import TTFont
12
13
SOURCE = sys.argv[1]
14
DEST = sys.argv[2]
15
16
17
def add_latin_m(font: TTFont) -> None:
18
cmap = font.getBestCmap()
19
if not cmap:
20
raise SystemExit("emoji font has no unicode cmap")
21
glyph = next(iter(cmap.values()))
22
for table in font["cmap"].tables:
23
if table.isUnicode():
24
table.cmap[ord("m")] = glyph
25
if font.getGlyphID(glyph) == 0:
26
raise SystemExit("mapped m onto .notdef")
27
28
29
def main() -> None:
30
font = TTFont(SOURCE)
31
if "CBDT" not in font or "CBLC" not in font:
32
raise SystemExit("source is not a CBDT/CBLC color font")
33
if "COLR" in font:
34
raise SystemExit("source also has a COLR table")
35
add_latin_m(font)
36
font.save(DEST)
37
saved = TTFont(DEST)
38
names = {record.nameID: record.toUnicode() for record in saved["name"].names if record.nameID in (1, 6)}
39
if names.get(1) != "Noto Color Emoji" or names.get(6) != "NotoColorEmoji":
40
raise SystemExit(f"unexpected names: {names}")
41
if ord("m") not in (saved.getBestCmap() or {}):
42
raise SystemExit("cmap is missing m")
43
print("wrote", DEST)
44
45
46
if __name__ == "__main__":
47
main()
@@ -0,0 +1,47 @@1
"""Keep a CBDT Noto Color Emoji face loadable by GPUI.2
3
GPUI drops a requested family when the face has no glyph for "m", and it4
only paints color bitmaps for the PostScript name NotoColorEmoji. Cosmic Text5
on Linux falls back to the family name Noto Color Emoji. This script leaves6
both names alone and maps U+006D onto an existing glyph so the face survives7
that check. The system COLRv1 face of the same name is hidden at runtime.8
"""9
10
import sys11
from fontTools.ttLib import TTFont12
13
SOURCE = sys.argv[1]14
DEST = sys.argv[2]15
16
17
def add_latin_m(font: TTFont) -> None:18
cmap = font.getBestCmap()19
if not cmap:20
raise SystemExit("emoji font has no unicode cmap")21
glyph = next(iter(cmap.values()))22
for table in font["cmap"].tables:23
if table.isUnicode():24
table.cmap[ord("m")] = glyph25
if font.getGlyphID(glyph) == 0:26
raise SystemExit("mapped m onto .notdef")27
28
29
def main() -> None:30
font = TTFont(SOURCE)31
if "CBDT" not in font or "CBLC" not in font:32
raise SystemExit("source is not a CBDT/CBLC color font")33
if "COLR" in font:34
raise SystemExit("source also has a COLR table")35
add_latin_m(font)36
font.save(DEST)37
saved = TTFont(DEST)38
names = {record.nameID: record.toUnicode() for record in saved["name"].names if record.nameID in (1, 6)}39
if names.get(1) != "Noto Color Emoji" or names.get(6) != "NotoColorEmoji":40
raise SystemExit(f"unexpected names: {names}")41
if ord("m") not in (saved.getBestCmap() or {}):42
raise SystemExit("cmap is missing m")43
print("wrote", DEST)44
45
46
if __name__ == "__main__":47
main()