Mercurial > libervia-desktop-kivy
comparison libervia/desktop_kivy/core/common.py @ 518:196483685a63 default tip
Use Font-Awesome instead of Fontello, following change in Libervia Media.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 26 Oct 2024 22:44:37 +0200 |
parents | d1a023280733 |
children |
comparison
equal
deleted
inserted
replaced
517:f316c7f19909 | 518:196483685a63 |
---|---|
173 symbol_map = None | 173 symbol_map = None |
174 symbol = properties.StringProperty() | 174 symbol = properties.StringProperty() |
175 | 175 |
176 def __init__(self, **kwargs): | 176 def __init__(self, **kwargs): |
177 if self.symbol_map is None: | 177 if self.symbol_map is None: |
178 with open(G.host.app.expand('{media}/fonts/fontello/config.json')) as f: | 178 with open( |
179 fontello_conf = json.load(f) | 179 G.host.app.expand('{media}/fonts/fontawesome/metadata/icons.json') |
180 Symbol.symbol_map = {g['css']:g['code'] for g in fontello_conf['glyphs']} | 180 ) as f: |
181 font_conf = json.load(f) | |
182 Symbol.symbol_map = { | |
183 name:int(data["unicode"], 16) | |
184 for name, data in font_conf.items() | |
185 } | |
181 | 186 |
182 super(Symbol, self).__init__(**kwargs) | 187 super(Symbol, self).__init__(**kwargs) |
183 | 188 |
184 def on_symbol(self, instance, symbol): | 189 def on_symbol(self, instance, symbol): |
190 if symbol.startswith("regular "): | |
191 symbol = symbol[8:] | |
192 self.font_name = G.host.app.expand( | |
193 "{media}/fonts/fontawesome/webfonts/fa-regular-400.ttf" | |
194 ) | |
185 try: | 195 try: |
186 code = self.symbol_map[symbol] | 196 code = self.symbol_map[symbol] |
187 except KeyError: | 197 except KeyError: |
188 log.warning(_("Invalid symbol {symbol}").format(symbol=symbol)) | 198 log.warning(_("Invalid symbol {symbol}").format(symbol=symbol)) |
189 else: | 199 else: |