Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adj text size2 #24

Merged
merged 5 commits into from
Feb 11, 2024
Merged

Adj text size2 #24

merged 5 commits into from
Feb 11, 2024

Conversation

Antohhin
Copy link
Contributor

ссылка на прошлый PR

добавил папку с одним из популярных шрифтов /src/fonts/Gidole-Regular.ttf
новая функция подборки размера текста относительно размера картинки check_font_size()
за этим стоит следующая идея:
задать width_ratio какой пропорции относительно размера картинки текст должен быть
задать начальные значения fontsize, learning_rate, где последнее это шаг с которым будем регулировать размер текста
уменьшать/увеличивать текст пока не выбью breakpoint (идея как в бинарном поиске, чтоб поживее, но не перескочить)
подгружаю шрифт с выбранным размером

  1. заменил while loop на строчку для подбора размера текста 50: fontsize = image.size[0] * width_ratio // 2 где 2 это константа
  2. добавил папку static/localization/fonts
  3. исправил работу с путями до папки fonts 72: ```
    fonts_files_dir = (
    Path(file).parent.parent.parent / "static/localization/fonts"
    )
3. добавил прозрачность текста 96: `txt.putalpha(txt.getchannel("A").point(lambda x: x * text_opacity))`

@ohld ohld merged commit 61930c8 into ffmemes:main Feb 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants