NickelMenu icon indicating copy to clipboard operation
NickelMenu copied to clipboard

Formatting of the cmd_output for Cyrilic symbols

Open degiz opened this issue 2 years ago • 14 comments

Hey @pgaskin

When I use cmd_output to run a command that returns Cyrillic symbols, the formatting looks different than for Latin ones (attached photo). To me, it looks like there's a space inserted after every letter.

My use case is to print translations received from DeepL, and all the available screen real estate matters 😅

Is it possible to display the Cyrillic symbols without offsets?

IMG_8952

degiz avatar Jan 02 '23 22:01 degiz

UTF-16 shenanigans?

NiLuJe avatar Jan 02 '23 22:01 NiLuJe

You can reproduce that using a UTF-8 encoded config file

menu_item :selection_search :Test Cyrillic :cmd_output :9999:echo 'Привет'

If that's a shenanigan issue, then I'm not sure what to do with it.

degiz avatar Jan 02 '23 22:01 degiz

Can you upload (i.e., drag and drop into the attachment area) the syslog showing the execution of that item? Also, run the command manually, redirecting (not copy-pasting) the output into a file, and upload that too.

pgaskin avatar Jan 03 '23 18:01 pgaskin

Hey @pgaskin

My config:

menu_item :main :Test russian :cmd_output :9999:echo 'Привет'
menu_item :main :Dump Syslog :cmd_spawn :logread > /mnt/onboard/.adds/syslog_bug.log

What I did:

  • Modified the config (as stated above)
  • Launched kobo
  • In the NickelMenu, pressed Test russian

Attaching the syslog_bug.log, I only stripped the first lines with book names.

Thanks a lot for looking into this!

syslog_bug.log

degiz avatar Jan 04 '23 20:01 degiz

This looks very similar to problems we've seen before when Cyrillic is used as part of the GUI. I think it's caused when the GUI is trying to use Cyrillic in a widget which is expecting to use the built-in default sans-serif font, Avenir.

I'm not sure whether it's because the Cyrillic glyphs in Kobo's version of Avenir are useless or whether it's because the Kobo can't find any Cyrillic glyphs and uses a fallback font instead, which will probably by one of the built-in CJK fonts.

Whatever the reason, one way it can be "fixed" is by replacing the default system 'Avenir Next' with a font better suited to Cyrillic. On my own devices I've replaced Avenir with a copy of Calibri masquerading as 'Avenir Next'. I didn't do this because I need Cyrillic but I have just tested menu_item :main :Test russian :cmd_output :9999:echo 'Привет' in NickelMenu and the output looks fine to me, i.e. no "double spacing" effect.

ETA: If NickelMenu could (optionally???) force the cmd_output widget to use Georgia instead, that might also work.

jackiew1 avatar Jan 05 '23 21:01 jackiew1

Hey @pgaskin

When I use cmd_output to run a command that returns Cyrillic symbols, the formatting looks different than for Latin ones (attached photo). To me, it looks like there's a space inserted after every letter.

My use case is to print translations received from DeepL, and all the available screen real estate matters 😅

Is it possible to display the Cyrillic symbols without offsets?

IMG_8952

Hi, would you be so kind and share the line you used to get this output of translation. Are you using KOreader or anything similar or is this a device native reader?

n3w6i3 avatar May 01 '23 22:05 n3w6i3

Hey @n3w6i3 I'm using the following command:

menu_item :selection_search :DeepL Translation :cmd_output :9999:/usr/bin/wget --header='Authorization: DeepL-Auth-Key $MY_KEY' --post-data='target_lang=RU&text={1|S|%}' -qO - https://api-free.deepl.com/v2/translate | jq '.translations[0].text' | fold -s -w 55

No KOreader, pure Kobo + nickelmenu

degiz avatar May 14 '23 15:05 degiz

Hey @n3w6i3 I'm using the following command:

menu_item :selection_search :DeepL Translation :cmd_output :9999:/usr/bin/wget --header='Authorization: DeepL-Auth-Key $MY_KEY' --post-data='target_lang=RU&text={1|S|%}' -qO - https://api-free.deepl.com/v2/translate | jq '.translations[0].text' | fold -s -w 55

No KOreader, pure Kobo + nickelmenu

I tried it (used my api key) but i get the following message instead of translation: /bin/sh: jq: not found... any idea how to solve it?

n3w6i3 avatar May 14 '23 20:05 n3w6i3

I ship it as part of my KoboStuff bundle of tools, so I imagine @degiz has that installed ;).

NiLuJe avatar May 15 '23 00:05 NiLuJe

I ship it as part of my KoboStuff bundle of tools, so I imagine @degiz has that installed ;).

Thank you all, it works like a charm 😁

n3w6i3 avatar May 15 '23 08:05 n3w6i3

I ship it as part of my KoboStuff bundle of tools, so I imagine @degiz has that installed ;).

Thank you all, it works like a charm 😁

Wait, so how did you fix it?

EdNanda avatar May 16 '23 19:05 EdNanda

I ship it as part of my KoboStuff bundle of tools, so I imagine @degiz has that installed ;).

Thank you all, it works like a charm 😁

Wait, so how did you fix it?

By installing the whole package from NiLuJe.

n3w6i3 avatar May 16 '23 19:05 n3w6i3

By installing the whole package from NiLuJe.

Ahhh I get it, rookie mistake. Now it works, this is very cool! Thanks :D

EdNanda avatar May 16 '23 19:05 EdNanda

@degiz Hi! Have you fixed it? Does replacing the default system 'Avenir Next' with something like 'Calibri' helped you? If so, how can I do it? Even after fixing 'double spacing' effect I still have a problem: Cyrillic (latin works as should) symbols at the end of the line are disappearing sometimes (pretty often but not always). E.g. with the longer text: echo "\"Давай сходим в парк,\" - предложил Даниил, улыбаясь. \"Почему бы и нет,\" - согласилась Наташа, радостно кивнув. Они вышли из дома и направились к парку, наслаждаясь свежим воздухом. \"Какой замечательный день,\" - восхищенно вздохнула Наташа, глядя на яркое солнце. \"А вот и городское озеро,\" - указал Даниил, указывая на водную гладь. Они прогуливались, наслаждаясь природой и обществом друг друга. \"Скоро будем здесь снова,\" - обещала Наташа, улыбаясь своему другу. \"Да, это было замечательно,\" - согласился Даниил, чувствуя прилив счастья." | fold -s -w 50 @jackiew1 maybe you can also test it in your enviroment

P.S. if you replace spaces (" ") with "_" for example, no characters will be missing

photo_2024-01-27_01-28-42

Eikthyrnir avatar Jan 27 '24 00:01 Eikthyrnir