mirror of
https://github.com/SeedSigner/seedsigner.git
synced 2026-10-05 23:18:25 +00:00
Merge pull request #774 from alvroble/include_libraqm
[l10n] Remove libraqm workarounds and enforce libraqm dependency
This commit is contained in:
@@ -77,7 +77,7 @@ You will be prompted to enter the current password ("raspberry") and then to ent
|
||||
# * libsqlite3-dev: required by `coverage`
|
||||
sudo apt update && sudo apt install -y build-essential zlib1g-dev \
|
||||
libncurses5-dev libgdbm-dev libnss3-dev openssl libssl-dev \
|
||||
libreadline-dev libffi-dev wget libsqlite3-dev
|
||||
libreadline-dev libffi-dev wget libsqlite3-dev libraqm-dev
|
||||
|
||||
# Grab the python3.10 source
|
||||
wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz
|
||||
|
||||
@@ -432,10 +432,6 @@ class TextArea(BaseComponent):
|
||||
self.text_y = self.text_height_above_baseline
|
||||
|
||||
self.visible_width = self.width - max(self.edge_padding, self.min_text_x) - self.edge_padding
|
||||
if not ImageFont.core.HAVE_RAQM:
|
||||
# Fudge factor for imprecise width calcs w/out libraqm
|
||||
full_text_width = int(full_text_width * 1.05)
|
||||
self.visible_width = int(self.visible_width * 1.05)
|
||||
|
||||
if self.is_horizontal_scrolling_enabled or not self.auto_line_break:
|
||||
# Guaranteed to be a single line of text, possibly wider than self.width
|
||||
@@ -589,10 +585,6 @@ class TextArea(BaseComponent):
|
||||
|
||||
self.rendered_text_img = img
|
||||
|
||||
if not ImageFont.core.HAVE_RAQM:
|
||||
# At this point we need the visible_width to be the "actual" (yet still incorrect) width
|
||||
self.visible_width = int(self.visible_width * 0.95)
|
||||
|
||||
self.horizontal_text_scroll_thread: TextArea.HorizontalTextScrollThread = None
|
||||
if self.is_horizontal_scrolling_enabled:
|
||||
self.horizontal_text_scroll_thread = TextArea.HorizontalTextScrollThread(
|
||||
@@ -1843,10 +1835,6 @@ def reflow_text_for_width(text: str,
|
||||
# Measure from left baseline ("ls")
|
||||
(left, top, full_text_width, px_below_baseline) = font.getbbox(text, anchor="ls")
|
||||
|
||||
if not ImageFont.core.HAVE_RAQM:
|
||||
# Fudge factor for imprecise width calcs w/out libraqm
|
||||
full_text_width = int(full_text_width * 1.05)
|
||||
|
||||
# Assume we can break Asian text on any character
|
||||
treat_chars_as_words = Settings.get_instance().get_value(SettingsConstants.SETTING__LOCALE) in [
|
||||
SettingsConstants.LOCALE__CHINESE_SIMPLIFIED,
|
||||
@@ -1880,10 +1868,6 @@ def reflow_text_for_width(text: str,
|
||||
(left, top, right, px_below_baseline) = font.getbbox(word_spacer.join(words[0:index]), anchor="ls")
|
||||
line_width = right - left
|
||||
|
||||
if not ImageFont.core.HAVE_RAQM:
|
||||
# Fudge factor for imprecise width calcs w/out libraqm
|
||||
line_width = int(line_width * 1.05)
|
||||
|
||||
if line_width >= width:
|
||||
# Candidate line is still too long. Restrict search range down.
|
||||
if min_index + 1 == index:
|
||||
|
||||
@@ -6,6 +6,7 @@ import random
|
||||
import sys
|
||||
import time
|
||||
from unittest.mock import Mock, patch, MagicMock
|
||||
from PIL import ImageFont
|
||||
|
||||
from embit import compact
|
||||
from embit.psbt import PSBT, OutputScope
|
||||
@@ -21,9 +22,6 @@ sys.modules['RPi.GPIO'] = MagicMock()
|
||||
sys.modules['seedsigner.hardware.camera'] = MagicMock()
|
||||
sys.modules['seedsigner.hardware.microsd'] = MagicMock()
|
||||
|
||||
# Force the screenshots to mimic Pi Zero's output without libraqm
|
||||
patch('PIL.ImageFont.core.HAVE_RAQM', False).start()
|
||||
|
||||
from seedsigner.controller import Controller
|
||||
from seedsigner.gui.components import GUIConstants
|
||||
from seedsigner.gui.renderer import Renderer
|
||||
@@ -47,8 +45,6 @@ from .utils import ScreenshotComplete, ScreenshotConfig, ScreenshotRenderer
|
||||
|
||||
import warnings; warnings.warn = lambda *args, **kwargs: None
|
||||
|
||||
|
||||
|
||||
# Dynamically generate a pytest test run for each locale
|
||||
@pytest.mark.parametrize("locale", [x for x, y in SettingsConstants.get_detected_languages()])
|
||||
def test_generate_all(locale, target_locale):
|
||||
@@ -60,6 +56,11 @@ def test_generate_all(locale, target_locale):
|
||||
if target_locale and locale != target_locale:
|
||||
pytest.skip(f"Skipping {locale}")
|
||||
|
||||
if not ImageFont.core.HAVE_RAQM:
|
||||
# We can't generate pixel-perfect screenshots that match what gets rendered on
|
||||
# the device if we don't have libraqm.
|
||||
pytest.fail("libraqm is not installed.")
|
||||
|
||||
generate_screenshots(locale)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user