Julow / Unexpected-Keyboard

A lightweight virtual keyboard for developers.
GNU General Public License v3.0
1.58k stars 196 forks source link

Acute accent with Russian vowels #437

Closed vort3 closed 10 months ago

vort3 commented 1 year ago

This might be a bug or just me totally misunderstanding how keyboards work.

I have a Russian ЙЦУКЕН layout. I went to the options and enabled the ◌́ symbol, which I believe to be an «Acute accent» symbol. When I hold (enable) this key, I see some of my letters have this ( ́ ) symbol, which is what we call a «stress mark» in Russian. You probably know that already but symbols like á are not real Russian letters, they are not a part of an alphabet: they're just a letter «a» with a stress mark on top.

The problem I have is that I can only letters «к» and «г» with a stress mark. However, in Russian we use stress mark to show which vowels are stressed in certain words, so only vowels can be stressed (у, е, а, о, и). Some vowels are always stressed so they can't have a stress mark, and consonants can't be «stressed» at all.

As far as I know there are two ways to make «stressed letters»:

  1. There are single symbols for stressed letters. Those only exist for languages where there are real letters with acute symbol on top of them in alphabet.
  2. «Combined» accent symbols, which allow to create combinations of any base letter + any accent symbol, even if they don't exist in any language.

The way I do that on my PC is I enter the base letter (for example, t) then any accent symbol (for example, ̂ ) and create letters like t̂, so, the second method. The way I do Russian «stressed vowels» is the same, so а́, е́, и́ and so on.

What does your ◌́ symbol on keyboard do, how do I combine it with letters? Or does it use the first method and replace letters on keyboard with their stressed variants? If yes, then for Russian layout it's wrong, because letters «к» and «г» don't have «accented» variants. Vowels do. But in Unexpected keyboard this doesn't work properly.

Can I please have some explanation if I'm doing something wrong?

Spike-from-NH commented 1 year ago

This is correct. Moreover, if a user has a Russian keyboard and tries to accent the Russian "a" (which is a different Unicode from the English/Spanish "a", though the glyph is identical), the result should be the Russian "а́", not the Spanish one.

Julow commented 1 year ago

The symbols modified by the acute accents are defined here: https://github.com/Julow/Unexpected-Keyboard/blob/master/srcs/juloo.keyboard2/KeyModifier.java#L503 Symbols not defined here go through the KeyCharacterMap.getDeadChar function, which is incomplete. This problem was reported for some diacritics in the past: https://github.com/Julow/Unexpected-Keyboard/issues/375 Russian stressed letters should be added. PR welcome.

symbols like á are not real Russian letters, they are not a part of an alphabet: they're just a letter «a» with a stress mark on top.

The keyboard is not limited to alphabet letters and can contain composed symbols.

Do you mean they are combining symbols made of several code points ? I doubt this has the Russian stressed letters exist in Unicode and the symbols you typed in the issue are single code points. Anyway, combining symbols can also be added to layouts.

The way I do that on my PC is I enter the base letter (for example, t) then any accent symbol (for example, ̂ ) and create letters like t̂, so, the second method. The way I do Russian «stressed vowels» is the same, so а́, е́, и́ and so on.

Someone suggested this for the app: https://github.com/Julow/Unexpected-Keyboard/issues/431

What does your ◌́ symbol on keyboard do, how do I combine it with letters? Or does it use the first method and replace letters on keyboard with their stressed variants?

Symbols on the keyboard are replaced by their stressed variant when the acute accent is active, as defined by the function I linked above.

If yes, then for Russian layout it's wrong, because letters «к» and «г» don't have «accented» variants

If a symbol exists in Unicode, it's not wrong to show it.

Julow commented 1 year ago

I doubt this has the Russian stressed letters exist in Unicode and the symbols you typed in the issue are single code points.

My bad, the letters you typed in the issue contain a combining symbol: https://codepoints.net/U+0301

The code need some adaptation so I'll take care of the implementation.

Spike-from-NH commented 1 year ago

I think the result should be the single Unicode for the Russian accented vowel, no matter what @vort3 typed above to represent it.

I agree it's a non-problem that characters one doesn't want, appear on the keyboard.

Julow commented 1 year ago

It's possible to output characters made of several code points (40498e7). An example is here: https://github.com/Julow/Unexpected-Keyboard/blob/master/srcs/juloo.keyboard2/KeyModifier.java#L675-L681

I'd prefer if one of you could implement the Russian symbols so I can be sure it's right.

Julow commented 1 year ago

Can you write the one-codepoint accented letters and the corresponding letters without the accent ?

vort3 commented 1 year ago

Can you write the one-codepoint accented letters and the corresponding letters without the accent ?

Turns out I was wrong. There are no one-codepoint cyrillic letters with acute. Source: this video https://youtu.be/xI-YIt3-q-A&t=26 but it's in Russian. There are only 6 letters with acute, all of them are Latin, and only 4 of them can be used in Russian because there are similar latin and cyrillic letters (for example, there are letters «a», «e», «o», «y» in both scripts). So one-codepoint characters are:

All of them are actually latin letters so most likely they will break spellcheckers if used in Russian text.

Maybe I'm wrong again but that's what I could find, and from now on I'll be using «combining acutes» whenever possible when writing texts on my PC, and I wish I could use the same method with Unexpected Keyboard.

Julow commented 10 months ago

I was incorrectly waiting for you to implement it. The fix is in 5beacf3. I'm not against a "combining" accent key that would combine with any letter if there's a use case.