diff --git a/internal_filesystem/apps/com.micropythonos.showfonts/META-INF/MANIFEST.JSON b/internal_filesystem/apps/com.micropythonos.showfonts/META-INF/MANIFEST.JSON new file mode 100644 index 00000000..cb484776 --- /dev/null +++ b/internal_filesystem/apps/com.micropythonos.showfonts/META-INF/MANIFEST.JSON @@ -0,0 +1,24 @@ +{ +"name": "ShowFonts", +"publisher": "MicroPythonOS", +"short_description": "Show installed fonts", +"long_description": "Visualize the installed fonts so the user can check them out.", +"icon_url": "https://apps.micropythonos.com/apps/com.micropythonos.showfonts/icons/com.micropythonos.showfonts_0.0.1_64x64.png", +"download_url": "https://apps.micropythonos.com/apps/com.micropythonos.showfonts/mpks/com.micropythonos.showfonts_0.0.1.mpk", +"fullname": "com.micropythonos.showfonts", +"version": "0.0.1", +"category": "development", +"activities": [ + { + "entrypoint": "assets/showfonts.py", + "classname": "ShowFonts", + "intent_filters": [ + { + "action": "main", + "category": "launcher" + } + ] + } + ] +} + diff --git a/internal_filesystem/apps/com.micropythonos.showfonts/assets/showfonts.py b/internal_filesystem/apps/com.micropythonos.showfonts/assets/showfonts.py new file mode 100644 index 00000000..9aa49c7c --- /dev/null +++ b/internal_filesystem/apps/com.micropythonos.showfonts/assets/showfonts.py @@ -0,0 +1,51 @@ +from mpos.apps import Activity +import lvgl as lv + +class ShowFonts(Activity): + def onCreate(self): + screen = lv.obj() + #cont.set_size(320, 240) + #cont.set_scrollbar_mode(lv.SCROLLBAR_MODE.AUTO) + #cont.set_scroll_dir(lv.DIR.VER) + + # Make the screen focusable so it can be scrolled with the arrow keys + focusgroup = lv.group_get_default() + if focusgroup: + focusgroup.add_obj(screen) + + fonts = [ + (lv.font_montserrat_16, "Montserrat 16"), + (lv.font_unscii_16, "Unscii 16"), + (lv.font_unscii_8, "Unscii 8"), + (lv.font_dejavu_16_persian_hebrew, "DejaVu 16 Persian/Hebrew"), + ] + + dsc = lv.font_glyph_dsc_t() + y = 4 + + for font, name in fonts: + title = lv.label(screen) + title.set_text(name) + title.set_style_text_font(lv.font_montserrat_16, 0) + title.set_pos(4, y) + y += title.get_height() + 20 + + line_height = font.get_line_height() + 4 + x = 4 + + for cp in range(0x20, 0xFFFF + 1): + if font.get_glyph_dsc(font, dsc, cp, cp): + lbl = lv.label(screen) + lbl.set_style_text_font(font, 0) + lbl.set_text(chr(cp)) + lbl.set_pos(x, y) + + x += 20 + if x + 20 > screen.get_width(): + x = 4 + y += line_height + + y += line_height + + screen.set_height(y + 20) + self.setContentView(screen) diff --git a/internal_filesystem/apps/com.micropythonos.showfonts/generate_icon.py b/internal_filesystem/apps/com.micropythonos.showfonts/generate_icon.py new file mode 100644 index 00000000..8c0797d3 --- /dev/null +++ b/internal_filesystem/apps/com.micropythonos.showfonts/generate_icon.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +""" +Generate a 64x64 PNG icon with transparent background for the "ShowFonts" app. +The icon features a stylized bold 'F' with a subtle font preview overlay, +using modern flat design with vibrant colors. +""" + +import cairo +from pathlib import Path + +def create_showfonts_icon(output_path: str = "ShowFonts_icon.png"): + # Icon dimensions + WIDTH, HEIGHT = 64, 64 + RADIUS = 12 # Corner radius for rounded square background + + # Create surface with alpha channel + surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT) + ctx = cairo.Context(surface) + + # Fully transparent background + ctx.set_source_rgba(0, 0, 0, 0) + ctx.paint() + + # === Draw subtle rounded background (optional soft glow base) === + ctx.save() + rounded_rect(ctx, 4, 4, 56, 56, RADIUS) + ctx.set_source_rgba(0.1, 0.1, 0.1, 0.15) # Very subtle dark overlay + ctx.fill() + ctx.restore() + + # === Main colorful gradient background === + ctx.save() + rounded_rect(ctx, 6, 6, 52, 52, RADIUS - 2) + + # Create radial gradient for depth + grad = cairo.RadialGradient(32, 20, 5, 32, 32, 30) + grad.add_color_stop_rgb(0, 0.25, 0.6, 1.0) # Bright blue center + grad.add_color_stop_rgb(0.7, 0.1, 0.4, 0.9) # Mid tone + grad.add_color_stop_rgb(1, 0.05, 0.25, 0.7) # Deep blue edge + ctx.set_source(grad) + ctx.fill() + ctx.restore() + + # === Draw bold stylized 'F' === + ctx.save() + ctx.select_font_face("Sans", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD) + ctx.set_font_size(38) + + # Position 'F' centered + x_bearing, y_bearing, text_width, text_height = ctx.text_extents("F")[:4] + x = 32 - text_width / 2 - x_bearing + y = 38 - text_height / 2 - y_bearing + + ctx.move_to(x, y) + ctx.set_source_rgb(1.0, 1.0, 1.0) # Pure white + ctx.show_text("F") + ctx.restore() + + # === Add small font preview overlay (Aa) === + ctx.save() + ctx.select_font_face("Serif", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL) + ctx.set_font_size(11) + + extents = ctx.text_extents("Aa") + x = 32 - extents.width / 2 - extents.x_bearing + y = 50 - extents.height / 2 - extents.y_bearing + + # Shadow for depth + ctx.move_to(x + 0.5, y + 0.5) + ctx.set_source_rgba(0, 0, 0, 0.3) + ctx.show_text("Aa") + + # Main text + ctx.move_to(x, y) + ctx.set_source_rgb(1.0, 1.0, 0.7) # Light yellow + ctx.show_text("Aa") + ctx.restore() + + # === Add subtle highlight on 'F' === + ctx.save() + ctx.set_line_width(1.5) + ctx.set_source_rgba(1, 1, 1, 0.4) + + # Top bar highlight + ctx.move_to(14, 20) + ctx.line_to(26, 20) + ctx.stroke() + + # Middle bar highlight + ctx.move_to(14, 29) + ctx.line_to(23, 29) + ctx.stroke() + ctx.restore() + + # Save to PNG + surface.write_to_png(output_path) + print(f"Icon saved to: {Path(output_path).resolve()}") + +def rounded_rect(ctx, x, y, width, height, radius): + """Draw a rounded rectangle path""" + from math import pi + ctx.move_to(x + radius, y) + ctx.arc(x + width - radius, y + radius, radius, pi * 1.5, pi * 2) + ctx.arc(x + width - radius, y + height - radius, radius, 0, pi * 0.5) + ctx.arc(x + radius, y + height - radius, radius, pi * 0.5, pi) + ctx.arc(x + radius, y + radius, radius, pi, pi * 1.5) + ctx.close_path() + +if __name__ == "__main__": + create_showfonts_icon() diff --git a/internal_filesystem/apps/com.micropythonos.showfonts/res/mipmap-mdpi/icon_64x64.png b/internal_filesystem/apps/com.micropythonos.showfonts/res/mipmap-mdpi/icon_64x64.png new file mode 100644 index 00000000..b848f8e6 Binary files /dev/null and b/internal_filesystem/apps/com.micropythonos.showfonts/res/mipmap-mdpi/icon_64x64.png differ