From bbf0a26a24de252be762e157a8e77450524f7ab1 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Fri, 16 Feb 2024 21:11:22 +0100 Subject: contrib/ayatana-indicator-keyboard-icon-generator.py: Update and improve the script --- .../ayatana-indicator-keyboard-icon-generator.py | 359 +++++++++++---------- 1 file changed, 187 insertions(+), 172 deletions(-) mode change 100755 => 100644 contrib/ayatana-indicator-keyboard-icon-generator.py diff --git a/contrib/ayatana-indicator-keyboard-icon-generator.py b/contrib/ayatana-indicator-keyboard-icon-generator.py old mode 100755 new mode 100644 index 5d631d33..9600f601 --- a/contrib/ayatana-indicator-keyboard-icon-generator.py +++ b/contrib/ayatana-indicator-keyboard-icon-generator.py @@ -12,166 +12,165 @@ import getopt #import subprocess m_lLanguages = [ -'Ap', #APL -'Fa', #Afghani -'Ak', #Akan -'Sq', #Albanian -'Am', #Amharic -'Ar', #Arabic -'Hy', #Armenian -'As', #Asturian -'At', #Atsina -'Av', #Avatime -'Ae', #Avestan -'Az', #Azerbaijani -'Bm', #Bambara -'Bn', #Bangla -'Ba', #Bashkirian -'Be', #Belarusian -'Bl', #Belgian -'Bb', #Berber -'Bs', #Bosnian -'Bi', #Braille -'Bg', #Bulgarian -'By', #Burmese -'Zg', #Zawgyi -'Cm', #Cameroon -'Cn', #Canadian -'Ca', #Catalan -'Ck', #Cherokee -'Zh', #Chinese -'Cu', #Church Slavonic -'Cv', #Chuvash -'Cl', #CloGaelach -'Sx', #Coeur d'Alene Salish -'Cp', #Coptic -'Tt', #Tatar -'Hr', #Croatian -'Cs', #Czech -'Da', #Danish -'Dv', #Dhivehi -'Dl', #Dutch -'Dz', #Dzongkha -'Ed', #Elfdalian -'En', #English -'Eo', #Esperanto -'Et', #Estonian -'Ek', #EurKEY -'Ee', #Ewe -'Fo', #Faroese -'Ph', #Filipino -'Fi', #Finnish -'Fr', #French -'Fu', #Friulian -'Ff', #Fula -'Gh', #Ga -'Ka', #Georgian -'De', #German -'Gr', #Greek -'Gu', #Gujarati -'Hp', #Hanyu Pinyin -'Ha', #Hausa -'Hw', #Hawaiian -'He', #Hebrew -'Hi', #Hindi -'Hu', #Hungarian -'Is', #Icelandic -'Ig', #Igbo -'Il', #Indian -'Ip', #Indic -'Id', #Indonesian -'Ix', #International Phonetic Alphabet -'Iu', #Inuktitut -'Iq', #Iraqi -'Ga', #Irish -'It', #Italian -'Ja', #Japanese -'Kb', #Kabyle -'Kx', #Kalmyk -'Kn', #Kannada -'Kp', #Kashubian -'Kk', #Kazakh -'Km', #Khmer -'Ki', #Kikuyu -'Kv', #Komi -'Ko', #Korean -'Ku', #Kurdish -'Kt', #Kutenai -'Ky', #Kyrgyz -'Lo', #Lao -'Lv', #Latvian -'Lt', #Lithuanian -'Sb', #Lower Sorbian -'Mk', #Macedonian -'Ms', #Malay -'Ml', #Malayalam -'Mt', #Maltese -'Ma', #Manipuri -'Mi', #Maori -'Mr', #Marathi -'Mx', #Mari -'Mu', #Mmuock -'Md', #Modi -'Ro', #Moldavian -'Mn', #Mongolian -'Me', #Montenegrin -'Mb', #Multilingual -'Nk', #N'Ko -'Ne', #Nepali -'Ns', #Saami -'No', #Norwegian -'Oc', #Occitan -'Og', #Ogham -'Ol', #Ol Chiki -'Or', #Oriya -'Os', #Ossetian -'Rs', #Rusyn -'Ps', #Pashto -'Fa', #Persian -'Pl', #Polish -'Pt', #Portuguese -'Pa', #Punjabi -'Ro', #Romanian -'Ru', #Russian -'Sy', #Saisiyat -'Sf', #Samogitian -'Sa', #Sanskrit -'Sp', #Secwepemctsin -'Sr', #Serbian -'Hs', #Serbo-Croatian -'Sj', #Sicilian -'Sj', #Silesian -'Sd', #Sindhi -'Si', #Sinhala -'Sk', #Slovak -'Sl', #Slovenian -'Es', #Spanish -'Sw', #Swahili -'Sv', #Swedish -'Ls', #Syriac -'Tw', #Taiwanese -'Tg', #Tajik -'Ta', #Tamil -'Tt', #Tatar -'Te', #Telugu -'Th', #Thai -'Bo', #Tibetan -'Tn', #Tswana -'Tr', #Turkish -'Tk', #Turkmen -'Ud', #Udmurt -'Ua', #Ugaritic -'Uk', #Ukrainian -'Ur', #Urdu -'Ug', #Uyghur -'Uz', #Uzbek -'Vi', #Vietnamese -'Wo', #Wolof -'Ya', #Yakut -'Yo', #Yoruba -'emoji', #Emoji -'custom', #Custom -'00' #Unknown +'00', +'Ae', +'Ak', +'Am', +'An', +'Ap', +'Ar', +'As', +'At', +'Av', +'Az', +'Ba', +'Bb', +'Be', +'Bg', +'Bi', +'Bl', +'Bm', +'Bn', +'Bo', +'Bs', +'By', +'Ca', +'Ck', +'Cl', +'Cm', +'Cn', +'Cp', +'Cs', +'Cu', +'custom', +'Cv', +'Da', +'De', +'Dl', +'Dv', +'Dz', +'Ed', +'Ee', +'Ek', +'emoji', +'En', +'Eo', +'Es', +'Et', +'Fa', +'Ff', +'Fi', +'Fo', +'Fr', +'Fu', +'Ga', +'Gh', +'Go', +'Gr', +'Gu', +'Ha', +'He', +'Hi', +'Hp', +'Hr', +'Hs', +'Hu', +'Hw', +'Hy', +'Id', +'Ig', +'Il', +'Ip', +'Iq', +'Is', +'It', +'Iu', +'Ix', +'Ja', +'Ka', +'Kb', +'Ki', +'Kk', +'Km', +'Kn', +'Ko', +'Kp', +'Kt', +'Ku', +'Kv', +'Kx', +'Ky', +'Lo', +'Ls', +'Lt', +'Lv', +'Ma', +'Mb', +'Md', +'Me', +'Mi', +'Mk', +'Ml', +'Mn', +'Mr', +'Ms', +'Mt', +'Mu', +'Mx', +'Ne', +'Nk', +'No', +'Ns', +'Oc', +'Og', +'Ol', +'Or', +'Os', +'Pa', +'Ph', +'Pl', +'Ps', +'Pt', +'Ro', +'Rs', +'Ru', +'Sa', +'Sb', +'Sd', +'Sf', +'Si', +'Sj', +'Sk', +'Sl', +'Sp', +'Sq', +'Sr', +'Sv', +'Sw', +'Sx', +'Sy', +'Sz', +'Ta', +'Te', +'Tg', +'Th', +'Tk', +'Tn', +'Tr', +'Tt', +'Tw', +'Ua', +'Ud', +'Ug', +'Uk', +'Ur', +'Uz', +'Vi', +'Wo', +'Ya', +'Yo', +'Zg', +'Zh' ] def printHelp(): @@ -179,7 +178,7 @@ def printHelp(): print('') print('Usage:') print('') - print('ayatana-indicator-keyboard-icon-generator -p -c -f -n -o ') + print('ayatana-indicator-keyboard-icon-generator -p -c -f -n -x -o ') print('') print(' The padding between the fill and the edges of the image') print(' Defaults to 0.8') @@ -189,6 +188,8 @@ def printHelp(): print(' Defaults to "Sans Regular"') print('-n Do not fill the icon, draw the border only') print(' Not used by default') + print('-x Generate high colour icons') + print(' Overrides all other options') print(' The output directory') print(' Defaults to the current directory') print('') @@ -202,11 +203,12 @@ if __name__ == '__main__': nFont = 15 nWeight = 500 bNoFill = False + bHighColour = False lOpts = [] try: - lOpts = getopt.getopt(sys.argv[1:], 'hp:c:f:no:')[0] + lOpts = getopt.getopt(sys.argv[1:], 'hp:c:f:nxo:')[0] except getopt.GetoptError: @@ -236,6 +238,11 @@ if __name__ == '__main__': bNoFill = True + elif sOpt == '-x': + + bHighColour = True + fBorder = 0.0 + elif sOpt == '-o': pOutDir = Path(sArg) @@ -243,16 +250,11 @@ if __name__ == '__main__': pOutDir.mkdir(parents=True, exist_ok=True) fRx = 2.4 - - if fRx == 0: - - fRx = 3.0 - fSize = 24.0 - (fBorder * 2) fIconX = (24.0 - fSize) / 2 fIconY = (24.0 - fSize) / 2 - if bNoFill == True: + if bNoFill: nWeight = 300 nFont = 13 @@ -260,6 +262,14 @@ if __name__ == '__main__': fIconX = fBorder + 0.4 fIconY = fBorder + 0.4 + if bHighColour: + + nWeight = 500 + nFont = 13 + fSize -= 0.8 + fIconX = fBorder + 0.4 + fIconY = fBorder + 0.4 + pFontMap = PangoFT2.FontMap.new() pContext = Pango.FontMap.create_context(pFontMap) pFontDescription = Pango.FontDescription.new() @@ -293,13 +303,18 @@ if __name__ == '__main__': fLayoutX = (24.0 - (nLayoutWidth / Pango.SCALE)) / 2 + (fBorder * 0.1) fLayoutY = (24.0 - (nLayoutHeight / Pango.SCALE)) / 2 + (nBaseline / Pango.SCALE) + (fBorder * 0.1) - if bNoFill == False: + if bHighColour: - pFile.write('' + sLanguage + '') + pFile.write('' + sLanguage + '') - else: + elif bNoFill: pFile.write('' + sLanguage + '') - #subprocess.run('inkscape "' + str(sOutPath) + '" --export-text-to-path --export-plain-svg --export-filename="' + str(sOutPath) + '"', shell=True, check=True); + + else: + + pFile.write('' + sLanguage + '') + + #subprocess.run('inkscape "' + str(sOutPath) + '" --export-text-to-path --export-plain-svg --export-filename="' + str(sOutPath) + '"', shell=True, check=True); sys.exit(0) -- cgit v1.2.3