Skip to content

Commit

Permalink
Assembly v 3.4.5 (25.02.24)
Browse files Browse the repository at this point in the history
  • Loading branch information
adslbarxatov committed Feb 25, 2024
1 parent f82c8d4 commit f973806
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
# Константы, используемые далее по тексту
env:
PROJ: ${{ github.event.repository.name }}
TAG: '3.4.2'
TAG: '3.4.5'

steps:
# Проверка состава репозитория (без анализа, как может показаться)
Expand Down
Binary file added .release/FontFinder.exe
Binary file not shown.
15 changes: 15 additions & 0 deletions .release/FontFinder_en_us.dph
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This tool allows you to find the name / family of a font by its image. You only need to provide a sample font in the picture (high contrast, target letters only) and specify the text in the picture. The application allows you to set font search parameters and a break condition (match percentage). Finally, you can manage fonts that will be skipped during the search.

Warning! The tool only works with fonts installed on your operating system.

1. It is recommended to use contrast pictures with dark text and bright background without other elements).Text must be flat (without trajectories). Cropped image will be shown in the field below the image selection button.

2. It is necessary to specify the text from the picture (it’s case sensitive). This version of application allows non-empty text strings no longer than 50 characters.

3. In some cases the font parameters may significantly change results of search. Specify them if you haven’t received needed results.

4. You can use the stop factor if you want to pause search when you get the specified percentage of similarity (between 50 and 99). The “Search” button starts fonts matching with the sample image.

5. After search complete you’ll get a list of most matching fonts (not more than 100). By clicking you can see the specified text in selected font and style. Search may be too long. Use “Cancel” button to finish it immediately and view current results.

6. Application will add fonts that give the same comparison results to skipping list. It will increase the search speed. You can change it manually if needed or turn off using the corresponding flag
15 changes: 15 additions & 0 deletions .release/FontFinder_ru_ru.dph
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Этот инструмент позволяет найти название/семейство шрифта по его изображению. Вам нужно только предоставить образец шрифта на картинке (высококонтрастный, только целевые буквы) и указать текст на картинке. Приложение позволяет задать параметры поиска шрифта и условие прерывания (процент совпадения). Наконец, Вы можете управлять шрифтами, которые будут пропускаться во время поиска.

Предупреждение! Инструмент работает только со шрифтами, установленными в вашей операционной системе.

1. Рекомендуется использование контрастных изображений, на которых тёмный текст расположен на светлом фоне, и кроме него ничего нет. Текст должен быть ровным (без траекторий). Обрезанное до границ текста изображение будет отображено в поле ниже кнопки выбора картинки.

2. Для подбора шрифта необходимо указать текст, изображённый на картинке, с учётом регистра. В данной версии программы текст не может быть длиннее 50 символов. Одновременно он не может отсутствовать.

3. В некоторых случаях параметры шрифта существенно влияют на его отображение. Укажите эти параметры, если поиск не даёт желаемых результатов.

4. Если вы хотите, чтобы поиск был прерван при обнаружении совпадения с некоторым порогом, можно установить соответствующий флажок. Порогом срабатывания этого правила служит число от 50 до 99 процентов. Нажатие кнопки «Поиск» запустит перебор шрифтов на предмет совпадения с тем, который использован в загруженном изображении.

5. По окончании поиска в списке будет отображено не более 100 наиболее подходящих шрифтов и степени их совпадения с оригиналом в процентах. Щелчок по любому результату позволяет отобразить заданный ранее текст с использованием выбранного шрифта и стиля. Поиск может занимать значительное время. Используйте кнопку «Отмена», чтобы остановить поиск и просмотреть уже имеющиеся результаты.

6. Приложение добавит шрифты, которые дают одинаковые результаты сравнения, в список пропуска. Это увеличит скорость поиска. При необходимости вы можете изменить его вручную или отключить, используя соответствующий флажок
8 changes: 4 additions & 4 deletions .release/Release.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
_Changes for v 3.4.2_:
_Changes for v 3.4.5_:
- Removed some unreliable memory operations;
- Fixed some interface bugs;
- Added localized videoguides;
- App now resizes the original image by itself to fit the control window and increase the speed of search;
- Core updates have been applied;
- Added a new version of offline help
- App now resizes the original image by itself to fit the control window and increase the speed of search
4 changes: 4 additions & 0 deletions Changes.log
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Font finder: changes log

Version 3.4.5:
• Removed some unreliable memory operations;
• Fixed some interface bugs

Version 3.4.2:
• Added localized videoguides

Expand Down
47 changes: 21 additions & 26 deletions src/FontFinderForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public partial class MainForm: Form
// Исходное изображение
private Bitmap image = null;

// Текст на нём
// Интерфейсные параметры, передаваемые в поисковый процесс
private string imageText = "";
private double searchPauseFactor = 90.0;
private bool pauseSearch = false;

// Найденные шрифты
private List<FontFamily> foundFF = new List<FontFamily> ();
Expand All @@ -27,9 +29,6 @@ public partial class MainForm: Form
private FontStyle searchFontStyle = FontStyle.Regular;
private SkipListProcessor slp = new SkipListProcessor ();

// Порог срабатывания правила приостановки поиска
private double searchPauseFactor = 90.0;

// Максимальная длина строки для сравнения
private const uint MaxSearchStringLength = 50;

Expand Down Expand Up @@ -99,8 +98,6 @@ private void OpenImage_FileOk (object sender, CancelEventArgs e)
{
case ImageLoaderStatuses.FileNotFound:
RDGenerics.MessageBox (RDMessageTypes.Warning_Center,
/*Localization.GetFileProcessingMessage (OpenImage.FileName,
LzFileProcessingMessageTypes.Load_Failure)*/
string.Format (RDLocale.GetDefaultText (RDLDefaultTexts.Message_LoadFailure_Fmt),
OpenImage.FileName));
break;
Expand All @@ -126,9 +123,6 @@ private void OpenImage_FileOk (object sender, CancelEventArgs e)
}

// Обработка
/*if ((image.Width > LoadedPicture.Width) || (image.Height > LoadedPicture.Height))
RDGenerics.LocalizedMessageBox (RDMessageTypes.Information_Center, "LargePicture");*/

if (LoadedPicture.BackgroundImage != null)
LoadedPicture.BackgroundImage.Dispose ();
LoadedPicture.BackgroundImage = (Bitmap)image.Clone ();
Expand All @@ -140,7 +134,7 @@ private void OpenImage_FileOk (object sender, CancelEventArgs e)
// Запуск поиска
private void StartSearch_Click (object sender, EventArgs e)
{
if (LoadedPicText.Text == "")
if (string.IsNullOrWhiteSpace (LoadedPicText.Text))
{
RDGenerics.LocalizedMessageBox (RDMessageTypes.Warning_Center, "SpecifyTextFromImage");
return;
Expand All @@ -156,6 +150,7 @@ private void StartSearch_Click (object sender, EventArgs e)
// Считывание параметров поиска
imageText = LoadedPicText.Text;
searchPauseFactor = (double)SearchPauseFactor.Value;
pauseSearch = PauseSearch.Checked;

// Настройка стиля поиска
CBold_CheckedChanged (null, null);
Expand All @@ -167,8 +162,6 @@ private void StartSearch_Click (object sender, EventArgs e)
foundFFMatch.Clear ();

// Запуск потока поиска и ожидание его завершения
/*HardWorkExecutor hwe = new HardWorkExecutor (Search, null, " ", false, true);
*/
RDGenerics.RunWork (Search, null, null, RDRunWorkFlags.AllowOperationAbort);
slp.FinishFilling ();

Expand All @@ -191,6 +184,7 @@ private void Search (object sender, DoWorkEventArgs e)
{
// Переменные
Bitmap createdImage;
BackgroundWorker bw = ((BackgroundWorker)sender);

// Поиск
double maxRes = 0;
Expand All @@ -203,9 +197,20 @@ private void Search (object sender, DoWorkEventArgs e)
// Создание изображения с выбранным шрифтом
FontStyle resultStyle = ImageProcessor.CreateBitmapFromFont (imageText, slp.ExistentFonts[i],
image.Height, searchFontStyle, CUnder.Checked, CStrike.Checked, out createdImage);

// Отображение прогресса
string msg = string.Format (RDLocale.GetText ("ProcessingMessage"), i, slp.ExistentFonts.Length,
slp.ExistentFonts[i].Name);
if (resultStyle != searchFontStyle)
msg += string.Format (RDLocale.GetText ("ProcessingStyle"), resultStyle.ToString ());
msg += string.Format (RDLocale.GetText ("SkippingFontsCountAndPercentage"),
slp.SkippingFontsCount, maxRes.ToString ("F2"));

bw.ReportProgress ((int)(HardWorkExecutor.ProgressBarSize * i / slp.ExistentFonts.Length), msg);

// Защита
if (createdImage == null)
continue;
// Здесь шрифты не пропускаем, т.к. есть шрифты, где лишь некоторые символы дают такой результат

// Сравнение
double res = 0;
Expand All @@ -226,7 +231,7 @@ private void Search (object sender, DoWorkEventArgs e)
}

// Запрос на прерывание поиска
if (PauseSearch.Checked && (res >= searchPauseFactor))
if (pauseSearch /*PauseSearch.Checked*/ && (res >= searchPauseFactor))
{
PreviewForm prf = new PreviewForm (createdImage, slp.ExistentFonts[i].Name +
", " + resultStyle.ToString ());
Expand Down Expand Up @@ -259,22 +264,12 @@ private void Search (object sender, DoWorkEventArgs e)
// Очистка памяти
createdImage.Dispose ();

// Возврат прогресса
// Обновление максимума
if (maxRes < res)
maxRes = res;

string msg = string.Format (RDLocale.GetText ("ProcessingMessage"), i, slp.ExistentFonts.Length,
slp.ExistentFonts[i].Name);
if (resultStyle != searchFontStyle)
msg += string.Format (RDLocale.GetText ("ProcessingStyle"), resultStyle.ToString ());
msg += string.Format (RDLocale.GetText ("SkippingFontsCountAndPercentage"),
slp.SkippingFontsCount, maxRes.ToString ("F2"));

((BackgroundWorker)sender).ReportProgress ((int)(HardWorkExecutor.ProgressBarSize *
i / slp.ExistentFonts.Length), msg);

// Завершение работы, если получено требование от диалога
if (((BackgroundWorker)sender).CancellationPending || e.Cancel)
if (bw.CancellationPending || e.Cancel)
{
e.Cancel = true;
return;
Expand Down
12 changes: 6 additions & 6 deletions src/ImageProcessing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public ImageCreator (string Text, Font UsedFont)

// Отрисовка текста
g.DrawString (Text, UsedFont, blackBrush, (image.Width - sz.Width) / 2, (image.Height - sz.Height) / 2);
g.Dispose ();

// Обрезка изображения
ImageLoader il = new ImageLoader (image);
Expand All @@ -211,7 +212,6 @@ public ImageCreator (string Text, Font UsedFont)

// Очистка памяти
il.Dispose ();
g.Dispose ();
}

/// <summary>
Expand Down Expand Up @@ -337,9 +337,9 @@ private Rectangle GetBorder ()
goto ll;
}
}
ll:
ll:

// Эта ситуация возможна лишь при полностью белом рисунке
// Эта ситуация возможна лишь при полностью белом рисунке
if (x == image.Width)
return new Rectangle ();

Expand All @@ -358,7 +358,7 @@ private Rectangle GetBorder ()
}
}

lr:
lr:
r.Width = x + 1 - r.X;

// Верхняя
Expand All @@ -370,7 +370,7 @@ private Rectangle GetBorder ()
goto lt;
}
}
lt:
lt:
r.Y = y;

// Нижняя
Expand All @@ -382,7 +382,7 @@ private Rectangle GetBorder ()
goto lb;
}
}
lb:
lb:
r.Height = y + 1 - r.Y;

// Готово
Expand Down
4 changes: 2 additions & 2 deletions src/PreviewForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ private void FClose_Click (object sender, EventArgs e)
this.Close ();
}

// Изменение размера формы
/* Изменение размера формы
private void PreviewForm_Resize (object sender, EventArgs e)
{
FClose.Top = this.Height - 62;
FClose.Left = (this.Width - FClose.Width) / 2;
ViewBox.Width = this.Width - 30;
ViewBox.Height = this.Height - 80;
}
}*/
}
}

0 comments on commit f973806

Please sign in to comment.