Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better emoji support when mixed with text #203

Merged
merged 12 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ https://github.com/Zoxcore/trifa_material/releases/download/nightly/bom_compilec
Full list of run time dependencies:<br>
https://github.com/Zoxcore/trifa_material/releases/download/nightly/bom_runtimeclasspath.txt

## Custom fonts
```NotoColorEmoji.ttf```<br>
downloaded from this repo https://github.com/googlefonts/noto-emoji<br>
https://github.com/googlefonts/noto-emoji/raw/main/fonts/NotoColorEmoji.ttf


```NotoSans-Regular.ttf```<br>
```NotoSans-SemiBold.ttf```<br>
both downloaded from this repo https://github.com/openmaptiles/fonts/tree/master/noto-sans<br>

```Noto-COLRv1_normal_chars_removed.ttf```<br>

this is made by removing all normal characters like SPACE and NUMBERS from ```Noto-COLRv1.ttf```
(from this repo https://github.com/googlefonts/noto-emoji/tree/main/fonts)



<br>
Any use of this project's code by GitHub Copilot, past or present, is done
Expand Down
87 changes: 62 additions & 25 deletions src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontLoadingStrategy
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.KeyboardCapitalization
Expand All @@ -112,22 +111,32 @@ import androidx.compose.ui.window.rememberWindowState
import ca.gosyer.appdirs.AppDirs
import com.google.gson.Gson
import com.vanniktech.emoji.Emoji
import com.vanniktech.emoji.EmojiManager
import com.vanniktech.emoji.ios.IosEmojiProvider
import com.vanniktech.emoji.search.SearchEmojiManager
import com.zoffcc.applications.ffmpegav.AVActivity
import com.zoffcc.applications.ffmpegav.AVActivity.JAVA_AUDIO_IN_DEVICE_NAME
import com.zoffcc.applications.sorm.BootstrapNodeEntryDB
import com.zoffcc.applications.trifa.AVState
import com.zoffcc.applications.trifa.AudioBar
import com.zoffcc.applications.trifa.AudioBar.audio_in_bar
import com.zoffcc.applications.trifa.AudioBar.audio_out_bar
import com.zoffcc.applications.trifa.CustomSemaphore
import com.zoffcc.applications.trifa.EmojiStrAndName
import com.zoffcc.applications.trifa.FriendSettingDetails
import com.zoffcc.applications.trifa.GroupSettingDetails
import com.zoffcc.applications.trifa.HelperGeneric.PubkeyShort
import com.zoffcc.applications.trifa.HelperGeneric.ngc_video_frame_last_incoming_ts
import com.zoffcc.applications.trifa.HelperGroup
import com.zoffcc.applications.trifa.HelperNotification.init_system_tray
import com.zoffcc.applications.trifa.HelperNotification.set_resouces_dir
import com.zoffcc.applications.trifa.JPictureBox
import com.zoffcc.applications.trifa.JPictureBoxOut
import com.zoffcc.applications.trifa.Log
import com.zoffcc.applications.trifa.MainActivity
import com.zoffcc.applications.trifa.MainActivity.Companion.DEBUG_COMPOSE_UI_UPDATES
import com.zoffcc.applications.trifa.MainActivity.Companion.PREF__audio_input_filter
import com.zoffcc.applications.trifa.MainActivity.Companion.PREF__do_not_sync_av
import com.zoffcc.applications.trifa.MainActivity.Companion.PREF__v4l2_capture_force_mjpeg
import com.zoffcc.applications.trifa.MainActivity.Companion.PREF__video_bitrate_mode
import com.zoffcc.applications.trifa.MainActivity.Companion.accept_incoming_av_call
Expand All @@ -136,7 +145,10 @@ import com.zoffcc.applications.trifa.MainActivity.Companion.main_init
import com.zoffcc.applications.trifa.MainActivity.Companion.set_toxav_video_sending_quality
import com.zoffcc.applications.trifa.MainActivity.Companion.tox_friend_by_public_key
import com.zoffcc.applications.trifa.MainActivity.Companion.tox_friend_get_name
import com.zoffcc.applications.trifa.MainActivity.Companion.tox_group_peer_get_name
import com.zoffcc.applications.trifa.MainActivity.Companion.toxav_option_set
import com.zoffcc.applications.trifa.NodeListJS
import com.zoffcc.applications.trifa.OperatingSystem
import com.zoffcc.applications.trifa.PrefsSettings
import com.zoffcc.applications.trifa.RandomNameGenerator
import com.zoffcc.applications.trifa.SingleComponentAspectRatioKeeperLayout
Expand Down Expand Up @@ -171,12 +183,15 @@ import org.briarproject.briar.desktop.ui.AddFriend
import org.briarproject.briar.desktop.ui.AddGroup
import org.briarproject.briar.desktop.ui.ExplainerChat
import org.briarproject.briar.desktop.ui.ExplainerGroup
import org.briarproject.briar.desktop.ui.ExplainerInfoIsRelay
import org.briarproject.briar.desktop.ui.ExplainerToxNotRunning
import org.briarproject.briar.desktop.ui.HorizontalDivider
import org.briarproject.briar.desktop.ui.Tooltip
import org.briarproject.briar.desktop.ui.UiMode
import org.briarproject.briar.desktop.ui.UiPlaceholder
import org.briarproject.briar.desktop.ui.VerticalDivider
import org.briarproject.briar.desktop.utils.InternationalizationUtils.i18n
import java.awt.GraphicsEnvironment
import java.awt.Toolkit
import java.io.File
import java.net.URI
Expand All @@ -187,21 +202,6 @@ import java.util.*
import java.util.concurrent.Executors
import java.util.prefs.Preferences
import javax.swing.JPanel
import com.vanniktech.emoji.EmojiManager
import com.vanniktech.emoji.ios.IosEmojiProvider
import com.vanniktech.emoji.search.SearchEmojiManager
import com.zoffcc.applications.ffmpegav.AVActivity.JAVA_AUDIO_IN_DEVICE_NAME
import com.zoffcc.applications.trifa.EmojiStrAndName
import com.zoffcc.applications.trifa.FriendSettingDetails
import com.zoffcc.applications.trifa.HelperGeneric.ngc_video_frame_last_incoming_ts
import com.zoffcc.applications.trifa.HelperGroup
import com.zoffcc.applications.trifa.MainActivity.Companion.DEBUG_COMPOSE_UI_UPDATES
import com.zoffcc.applications.trifa.MainActivity.Companion.PREF__do_not_sync_av
import com.zoffcc.applications.trifa.MainActivity.Companion.tox_group_peer_get_name
import com.zoffcc.applications.trifa.MainActivity.Companion.toxav_option_set
import com.zoffcc.applications.trifa.OperatingSystem
import org.briarproject.briar.desktop.ui.ExplainerInfoIsRelay
import org.briarproject.briar.desktop.ui.Tooltip

private const val TAG = "trifa.Main.kt"
var tox_running_state_wrapper = "start"
Expand Down Expand Up @@ -892,7 +892,7 @@ fun App()
}
audio_in_sources_get = tmp2.toTypedArray()
}
//if (avstatestore.state.audio_in_device_get() == "dshow")
// if (avstatestore.state.audio_in_device_get() == "dshow")
//{
// audio_in_sources_get += listOf("audio=" + MainActivity.DB_PREF__windows_audio_in_source + "")
//}
Expand Down Expand Up @@ -1890,6 +1890,18 @@ object AboutIcon : Painter() {
@Composable
private fun MainAppStart()
{
var use_custom_font_with_color_emoji = true
try
{
val tmp = global_prefs.getBoolean("main.use_custom_font_with_color_emoji", true)
if (tmp == false)
{
use_custom_font_with_color_emoji = false
}
} catch (_: Exception)
{
}

try
{
// HINT: for some reason the fonts do not load on macOS
Expand All @@ -1909,17 +1921,42 @@ private fun MainAppStart()
// HINT: for some reason the fonts do not load on macOS
if ((OperatingSystem.getCurrent() != OperatingSystem.MACOS) && (OperatingSystem.getCurrent() != OperatingSystem.MACARM))
{
DefaultFont = FontFamily(
// Font(resource = "fonts/Ubuntu-R.ttf", FontWeight.Normal, FontStyle.Normal),
// Font(resource = "fonts/Ubuntu-B.ttf", FontWeight.Bold, FontStyle.Normal),
Font(resource = "fonts/NotoSans-Regular.ttf", FontWeight.Normal, FontStyle.Normal),
Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.SemiBold, FontStyle.Normal),
Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.Bold, FontStyle.Normal),
)
if (use_custom_font_with_color_emoji)
{
// HINT: use a patched font that noto color emoji with regular chars like numbers and spaces removed
// this will show emojis in texts but use the default font as fallback for anything that is not an emoji
DefaultFont = FontFamily(
Font(resource = "fonts/Noto-COLRv1_normal_chars_removed.ttf", FontWeight.Normal, FontStyle.Normal),
Font(resource = "fonts/Noto-COLRv1_normal_chars_removed.ttf", FontWeight.SemiBold, FontStyle.Normal),
Font(resource = "fonts/Noto-COLRv1_normal_chars_removed.ttf", FontWeight.Bold, FontStyle.Normal),
// Font(resource = "fonts/NotoSans-Regular.ttf", FontWeight.Normal, FontStyle.Normal),
// Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.SemiBold, FontStyle.Normal),
// Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.Bold, FontStyle.Normal),
)
/*
val default_font_file_with_path = RESOURCESDIR.toString() + "/" + "NotoSans-Regular.ttf"
Log.i(TAG, "font=" + default_font_file_with_path)
val f: java.awt.Font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT,
File(default_font_file_with_path))
val ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
ge.registerFont(f)
*/
}
else
{
DefaultFont = FontFamily(
// Font(resource = "fonts/Ubuntu-R.ttf", FontWeight.Normal, FontStyle.Normal),
// Font(resource = "fonts/Ubuntu-B.ttf", FontWeight.Bold, FontStyle.Normal),
Font(resource = "fonts/NotoSans-Regular.ttf", FontWeight.Normal, FontStyle.Normal),
Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.SemiBold, FontStyle.Normal),
Font(resource = "fonts/NotoSans-SemiBold.ttf", FontWeight.Bold, FontStyle.Normal),
)
}
}
}
catch(_: Exception)
catch(e: Exception)
{
e.printStackTrace()
}

var showIntroScreen by remember { mutableStateOf(true) }
Expand Down
29 changes: 29 additions & 0 deletions src/main/kotlin/org/briarproject/briar/desktop/SettingDetails.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ fun SettingDetails()
own_relay_settings()
Spacer(modifier = Modifier.height(60.dp))
}
general_settings()
Spacer(modifier = Modifier.height(60.dp))
tox_settings()
Spacer(modifier = Modifier.height(60.dp))
if (global_store.ormaRunning)
Expand Down Expand Up @@ -325,6 +327,33 @@ private fun database_settings()
}
}

@Composable
private fun general_settings()
{
// ---- use custom font that has color emoji AND normal text ----
var use_custom_font_with_color_emoji by remember { mutableStateOf(true) }
try
{
if (!global_prefs.getBoolean("main.use_custom_font_with_color_emoji", true))
{
use_custom_font_with_color_emoji = false
}
} catch (_: Exception)
{
}
DetailItem(label = i18n("use custom font with color emojis for text.\n!! this is experimental and also needs an app restart !!"),
description = (if (use_custom_font_with_color_emoji) i18n("enabled") else i18n("disabled"))) {
Switch(
checked = use_custom_font_with_color_emoji,
onCheckedChange = {
global_prefs.putBoolean("main.use_custom_font_with_color_emoji", it)
use_custom_font_with_color_emoji = it
},
)
}
// ---- use custom font that has color emoji AND normal text ----
}

@Composable
private fun tox_settings()
{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed src/main/resources/fonts/Ubuntu-B.ttf
Binary file not shown.
Binary file removed src/main/resources/fonts/Ubuntu-R.ttf
Binary file not shown.
Binary file added tools/NotoColorEmoji-SVG.otf
Binary file not shown.
Loading
Loading