3 // Copyright (C) 2012-2014 by Werner Lemberg.
5 // This file is part of the ttfautohint library, and may only be used,
6 // modified, and distributed under the terms given in `COPYING'. By
7 // continuing to use, modify, or distribute this file you indicate that you
8 // have read `COPYING' and understand and accept it fully.
10 // The file `COPYING' mentioned in the previous paragraph is distributed
11 // with the ttfautohint library.
25 #include <ttfautohint.h>
28 // XXX Qt 4.8 bug: locale->quoteString("foo")
29 // inserts wrongly encoded quote characters
30 // into rich text QString
31 #if HAVE_QT_QUOTESTRING
32 # define QUOTE_STRING(x) locale->quoteString(x)
33 # define QUOTE_STRING_LITERAL(x) locale->quoteString(x)
35 # define QUOTE_STRING(x) "\"" + x + "\""
36 # define QUOTE_STRING_LITERAL(x) "\"" x "\""
40 // Shorthand for `tr' using a local `TRDOMAIN'.
41 #define Tr(text) QCoreApplication::translate(TRDOMAIN, text)
44 // the available script tags and its descriptions are directly extracted
45 // from `ttfautohint-scripts.h'
46 typedef struct Script_Names_
49 const char* description
;
53 #define SCRIPT(s, S, d, h, sc1, sc2, sc3) \
56 const Script_Names script_names
[] =
58 #include <ttfautohint-scripts.h>
63 Main_GUI::Main_GUI(bool horizontal_layout
,
71 const char* exceptions
,
82 : hinting_range_min(range_min
),
83 hinting_range_max(range_max
),
85 gray_strong_stem_width(gray
),
86 gdi_cleartype_strong_stem_width(gdi
),
87 dw_cleartype_strong_stem_width(dw
),
88 increase_x_height(increase
),
89 x_height_snapping_exceptions_string(exceptions
),
90 fallback_stem_width(stem_width
),
91 ignore_restrictions(ignore
),
92 windows_compatibility(wincomp
),
93 adjust_subglyphs(adjust
),
94 hint_composites(composites
),
101 // map default script tag to an index,
102 // replacing an invalid one with the default value
103 int latn_script_idx
= 0;
104 for (i
= 0; script_names
[i
].tag
; i
++)
106 if (!strcmp("latn", script_names
[i
].tag
))
108 if (!strcmp(dflt
, script_names
[i
].tag
))
111 default_script_idx
= script_names
[i
].tag
? i
: latn_script_idx
;
113 // map fallback script tag to an index,
114 // replacing an invalid one with the default value
115 int none_script_idx
= 0;
116 for (i
= 0; script_names
[i
].tag
; i
++)
118 if (!strcmp("none", script_names
[i
].tag
))
120 if (!strcmp(fallback
, script_names
[i
].tag
))
123 fallback_script_idx
= script_names
[i
].tag
? i
: none_script_idx
;
125 x_height_snapping_exceptions
= NULL
;
127 // if file watching is active, we regularly poll the file status
128 timer
= new QTimer(this);
129 timer
->setInterval(1000);
130 fileinfo_input_file
.setCaching(false);
131 fileinfo_deltas_file
.setCaching(false);
133 // XXX register translations somewhere and loop over them
134 if (QLocale::system().name() == "en_US")
135 locale
= new QLocale
;
137 locale
= new QLocale(QLocale::C
);
139 create_layout(horizontal_layout
);
140 create_connections();
148 setUnifiedTitleAndToolBarOnMac(true);
152 Main_GUI::~Main_GUI()
154 number_set_free(x_height_snapping_exceptions
);
161 Main_GUI::closeEvent(QCloseEvent
* event
)
171 QMessageBox::about(this,
172 tr("About TTFautohint"),
173 tr("<p>This is <b>TTFautohint</b> version %1<br>"
174 " Copyright %2 2011-2014<br>"
175 " by Werner Lemberg <tt><wl@gnu.org></tt></p>"
177 "<p><b>TTFautohint</b> adds new auto-generated hints"
178 " to a TrueType font or TrueType collection.</p>"
181 " <a href='http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT'>FreeType"
182 " License (FTL)</a> or"
183 " <a href='http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/GPLv2.TXT'>GNU"
191 Main_GUI::browse_input()
193 // XXX remember last directory
194 QString file
= QFileDialog::getOpenFileName(
196 tr("Open Input File"),
200 input_line
->setText(QDir::toNativeSeparators(file
));
205 Main_GUI::browse_output()
207 // XXX remember last directory
208 QString file
= QFileDialog::getSaveFileName(
210 tr("Open Output File"),
215 output_line
->setText(QDir::toNativeSeparators(file
));
220 Main_GUI::browse_deltas()
222 // XXX remember last directory
223 QString file
= QFileDialog::getOpenFileName(
225 tr("Open Delta Exceptions File"),
230 deltas_line
->setText(QDir::toNativeSeparators(file
));
235 Main_GUI::check_min()
237 int min
= min_box
->value();
238 int max
= max_box
->value();
239 int limit
= limit_box
->value();
241 max_box
->setValue(min
);
243 limit_box
->setValue(min
);
248 Main_GUI::check_max()
250 int min
= min_box
->value();
251 int max
= max_box
->value();
252 int limit
= limit_box
->value();
254 min_box
->setValue(max
);
256 limit_box
->setValue(max
);
261 Main_GUI::check_limit()
263 int min
= min_box
->value();
264 int max
= max_box
->value();
265 int limit
= limit_box
->value();
267 max_box
->setValue(limit
);
269 min_box
->setValue(limit
);
274 Main_GUI::check_dehint()
276 if (dehint_box
->isChecked())
278 min_label
->setEnabled(false);
279 min_box
->setEnabled(false);
281 max_label
->setEnabled(false);
282 max_box
->setEnabled(false);
284 default_label
->setEnabled(false);
285 default_box
->setEnabled(false);
286 fallback_label
->setEnabled(false);
287 fallback_box
->setEnabled(false);
289 no_limit_box
->setEnabled(false);
290 limit_label
->setEnabled(false);
291 limit_box
->setEnabled(false);
293 no_increase_box
->setEnabled(false);
294 increase_label
->setEnabled(false);
295 increase_box
->setEnabled(false);
297 snapping_label
->setEnabled(false);
298 snapping_line
->setEnabled(false);
300 default_stem_width_box
->setEnabled(false);
301 stem_width_label
->setEnabled(false);
302 stem_width_box
->setEnabled(false);
304 wincomp_box
->setEnabled(false);
305 adjust_box
->setEnabled(false);
306 hint_box
->setEnabled(false);
307 symbol_box
->setEnabled(false);
309 stem_label
->setEnabled(false);
310 gray_box
->setEnabled(false);
311 gdi_box
->setEnabled(false);
312 dw_box
->setEnabled(false);
316 min_label
->setEnabled(true);
317 min_box
->setEnabled(true);
319 max_label
->setEnabled(true);
320 max_box
->setEnabled(true);
322 default_label
->setEnabled(true);
323 default_box
->setEnabled(true);
324 fallback_label
->setEnabled(true);
325 fallback_box
->setEnabled(true);
327 no_limit_box
->setEnabled(true);
330 no_increase_box
->setEnabled(true);
333 snapping_label
->setEnabled(true);
334 snapping_line
->setEnabled(true);
336 default_stem_width_box
->setEnabled(true);
337 check_default_stem_width();
339 wincomp_box
->setEnabled(true);
340 adjust_box
->setEnabled(true);
341 hint_box
->setEnabled(true);
342 symbol_box
->setEnabled(true);
344 stem_label
->setEnabled(true);
345 gray_box
->setEnabled(true);
346 gdi_box
->setEnabled(true);
347 dw_box
->setEnabled(true);
353 Main_GUI::check_no_limit()
355 if (no_limit_box
->isChecked())
357 limit_label
->setEnabled(false);
358 limit_label
->setText(limit_label_text
);
359 limit_box
->setEnabled(false);
360 no_limit_box
->setText(no_limit_box_text_with_key
);
364 limit_label
->setEnabled(true);
365 limit_label
->setText(limit_label_text_with_key
);
366 limit_box
->setEnabled(true);
367 no_limit_box
->setText(no_limit_box_text
);
373 Main_GUI::check_no_increase()
375 if (no_increase_box
->isChecked())
377 increase_label
->setEnabled(false);
378 increase_label
->setText(increase_label_text
);
379 increase_box
->setEnabled(false);
380 no_increase_box
->setText(no_increase_box_text_with_key
);
384 increase_label
->setEnabled(true);
385 increase_label
->setText(increase_label_text_with_key
);
386 increase_box
->setEnabled(true);
387 no_increase_box
->setText(no_increase_box_text
);
393 Main_GUI::check_default_stem_width()
395 if (default_stem_width_box
->isChecked())
397 stem_width_label
->setEnabled(false);
398 stem_width_label
->setText(stem_width_label_text
);
399 stem_width_box
->setEnabled(false);
400 default_stem_width_box
->setText(default_stem_width_box_text_with_key
);
404 stem_width_label
->setEnabled(true);
405 stem_width_label
->setText(stem_width_label_text_with_key
);
406 stem_width_box
->setEnabled(true);
407 default_stem_width_box
->setText(default_stem_width_box_text
);
413 Main_GUI::check_run()
415 if (input_line
->text().isEmpty() || output_line
->text().isEmpty())
416 run_button
->setEnabled(false);
418 run_button
->setEnabled(true);
423 Main_GUI::absolute_input()
425 QString input_name
= QDir::fromNativeSeparators(input_line
->text());
426 if (!input_name
.isEmpty()
427 && QDir::isRelativePath(input_name
))
429 QDir
cur_path(QDir::currentPath() + "/" + input_name
);
430 input_line
->setText(QDir::toNativeSeparators(cur_path
.absolutePath()));
436 Main_GUI::absolute_output()
438 QString output_name
= QDir::fromNativeSeparators(output_line
->text());
439 if (!output_name
.isEmpty()
440 && QDir::isRelativePath(output_name
))
442 QDir
cur_path(QDir::currentPath() + "/" + output_name
);
443 output_line
->setText(QDir::toNativeSeparators(cur_path
.absolutePath()));
449 Main_GUI::absolute_deltas()
451 QString deltas_name
= QDir::fromNativeSeparators(deltas_line
->text());
452 if (!deltas_name
.isEmpty()
453 && QDir::isRelativePath(deltas_name
))
455 QDir
cur_path(QDir::currentPath() + "/" + deltas_name
);
456 deltas_line
->setText(QDir::toNativeSeparators(cur_path
.absolutePath()));
462 Main_GUI::check_number_set()
464 QString text
= snapping_line
->text();
467 // construct ASCII string from arbitrary Unicode data;
468 // the idea is to accept, say, CJK fullwidth digits also
469 for (int i
= 0; i
< text
.size(); i
++)
471 QChar c
= text
.at(i
);
473 int digit
= c
.digitValue();
475 qs
+= QString::number(digit
);
476 else if (c
.isSpace())
478 // U+30FC KATAGANA-HIRAGANA PROLONGED SOUND MARK is assigned
479 // to the `-' key in some Japanese input methods
480 else if (c
.category() == QChar::Punctuation_Dash
481 || c
== QChar(0x30FC))
483 // various Unicode COMMA characters,
484 // including representation forms
485 else if (c
== QChar(',')
486 || c
== QChar(0x055D)
487 || c
== QChar(0x060C)
488 || c
== QChar(0x07F8)
489 || c
== QChar(0x1363)
490 || c
== QChar(0x1802)
491 || c
== QChar(0x1808)
492 || c
== QChar(0x3001)
493 || c
== QChar(0xA4FE)
494 || c
== QChar(0xA60D)
495 || c
== QChar(0xA6F5)
496 || c
== QChar(0xFE10)
497 || c
== QChar(0xFE11)
498 || c
== QChar(0xFE50)
499 || c
== QChar(0xFE51)
500 || c
== QChar(0xFF0C)
501 || c
== QChar(0xFF64))
504 qs
+= c
; // we do error handling below
507 if (x_height_snapping_exceptions
)
508 number_set_free(x_height_snapping_exceptions
);
510 QByteArray str
= qs
.toLocal8Bit();
511 const char* s
= number_set_parse(str
.constData(),
512 &x_height_snapping_exceptions
,
516 statusBar()->setStyleSheet("color: red;");
517 if (x_height_snapping_exceptions
== NUMBERSET_ALLOCATION_ERROR
)
518 statusBar()->showMessage(
519 tr("allocation error"));
520 else if (x_height_snapping_exceptions
== NUMBERSET_INVALID_CHARACTER
)
521 statusBar()->showMessage(
522 tr("invalid character (use digits, dashes, commas, and spaces)"));
523 else if (x_height_snapping_exceptions
== NUMBERSET_OVERFLOW
)
524 statusBar()->showMessage(
526 else if (x_height_snapping_exceptions
== NUMBERSET_INVALID_RANGE
)
527 statusBar()->showMessage(
528 tr("invalid range (minimum is 6, maximum is 32767)"));
529 else if (x_height_snapping_exceptions
== NUMBERSET_OVERLAPPING_RANGES
)
530 statusBar()->showMessage(
531 tr("overlapping ranges"));
532 else if (x_height_snapping_exceptions
== NUMBERSET_NOT_ASCENDING
)
533 statusBar()->showMessage(
534 tr("values und ranges must be specified in ascending order"));
536 snapping_line
->setText(qs
);
537 snapping_line
->setFocus(Qt::OtherFocusReason
);
538 snapping_line
->setCursorPosition(s
- str
.constData());
540 x_height_snapping_exceptions
= NULL
;
544 // normalize if there is no error
545 char* new_str
= number_set_show(x_height_snapping_exceptions
,
547 snapping_line
->setText(new_str
);
554 Main_GUI::clear_status_bar()
556 statusBar()->clearMessage();
557 statusBar()->setStyleSheet("");
562 Main_GUI::check_filenames(const QString
& input_name
,
563 const QString
& output_name
,
564 const QString
& deltas_name
)
566 if (!QFile::exists(input_name
))
568 QMessageBox::warning(
571 tr("The file %1 cannot be found.")
572 .arg(QUOTE_STRING(QDir::toNativeSeparators(input_name
))),
578 if (input_name
== output_name
)
580 QMessageBox::warning(
583 tr("Input and output file names must be different."),
589 // silently overwrite if watching is active
590 if (QFile::exists(output_name
) && !timer
->isActive())
592 int ret
= QMessageBox::warning(
595 tr("The file %1 already exists.\n"
597 .arg(QUOTE_STRING(QDir::toNativeSeparators(output_name
))),
598 QMessageBox::Yes
| QMessageBox::No
,
600 if (ret
== QMessageBox::No
)
604 if (!deltas_name
.isEmpty() && !QFile::exists(deltas_name
))
606 QMessageBox::warning(
609 tr("The file %1 cannot be found.")
610 .arg(QUOTE_STRING(QDir::toNativeSeparators(deltas_name
))),
621 Main_GUI::open_files(const QString
& input_name
,
623 const QString
& output_name
,
625 const QString
& deltas_name
,
628 const int buf_len
= 1024;
631 *in
= fopen(qPrintable(input_name
), "rb");
634 strerror_r(errno
, buf
, buf_len
);
635 QMessageBox::warning(
638 tr("The following error occurred while opening input file %1:\n")
639 .arg(QUOTE_STRING(QDir::toNativeSeparators(input_name
)))
640 + QString::fromLocal8Bit(buf
),
646 *out
= fopen(qPrintable(output_name
), "wb");
649 strerror_r(errno
, buf
, buf_len
);
650 QMessageBox::warning(
653 tr("The following error occurred while opening output file %1:\n")
654 .arg(QUOTE_STRING(QDir::toNativeSeparators(output_name
)))
655 + QString::fromLocal8Bit(buf
),
661 if (!deltas_name
.isEmpty())
663 *deltas
= fopen(qPrintable(deltas_name
), "r");
666 strerror_r(errno
, buf
, buf_len
);
667 QMessageBox::warning(
670 tr("The following error occurred"
671 " while opening delta exceptions file %1:\n")
672 .arg(QUOTE_STRING(QDir::toNativeSeparators(deltas_name
)))
673 + QString::fromLocal8Bit(buf
),
685 Main_GUI::check_watch()
687 if (!watch_box
->isChecked())
689 // the timer gets started in the `run' function
694 Main_GUI::watch_files()
696 if (fileinfo_input_file
.exists()
697 && fileinfo_input_file
.isReadable()
698 && fileinfo_deltas_file
.exists()
699 && fileinfo_deltas_file
.isReadable())
701 QDateTime modified_input
= fileinfo_input_file
.lastModified();
702 QDateTime modified_deltas
= fileinfo_deltas_file
.lastModified();
703 if (modified_input
> datetime_input_file
704 || modified_deltas
> datetime_deltas_file
)
705 run(); // this function sets `datetime_XXX'
708 run(); // let this routine handle all errors
714 struct GUI_Progress_Data
718 QProgressDialog
* dialog
;
723 #define TRDOMAIN "GuiProgress"
726 gui_progress(long curr_idx
,
732 GUI_Progress_Data
* data
= static_cast<GUI_Progress_Data
*>(user
);
734 if (num_sfnts
> 1 && curr_sfnt
!= data
->last_sfnt
)
736 data
->dialog
->setLabelText(Tr("Auto-hinting subfont %1 of %2"
737 " with %3 glyphs...")
742 if (curr_sfnt
+ 1 == num_sfnts
)
744 data
->dialog
->setAutoReset(true);
745 data
->dialog
->setAutoClose(true);
749 data
->dialog
->setAutoReset(false);
750 data
->dialog
->setAutoClose(false);
753 data
->last_sfnt
= curr_sfnt
;
760 data
->dialog
->setLabelText(Tr("Auto-hinting %1 glyphs...")
762 data
->dialog
->setMaximum(num_glyphs
- 1);
767 data
->dialog
->setValue(curr_idx
);
769 if (data
->dialog
->wasCanceled())
776 struct GUI_Error_Data
782 int* ignore_restrictions_p
;
788 #define TRDOMAIN "GuiError"
791 gui_error(TA_Error error
,
792 const char* error_string
,
793 unsigned int errlinenum
,
798 GUI_Error_Data
* data
= static_cast<GUI_Error_Data
*>(user
);
799 QLocale
* locale
= data
->locale
; // for QUOTE_STRING_LITERAL
804 if (error
== TA_Err_Canceled
)
806 else if (error
== TA_Err_Invalid_FreeType_Version
)
807 QMessageBox::critical(
810 Tr("FreeType version 2.4.5 or higher is needed.\n"
811 "Are you perhaps using a wrong FreeType DLL?"),
814 else if (error
== TA_Err_Invalid_Font_Type
)
815 QMessageBox::warning(
818 Tr("This font is not a valid font"
819 " in SFNT format with TrueType outlines.\n"
820 "In particular, CFF outlines are not supported."),
823 else if (error
== TA_Err_Already_Processed
)
824 QMessageBox::warning(
827 Tr("This font has already been processed by TTFautohint."),
830 else if (error
== TA_Err_Missing_Legal_Permission
)
832 int yesno
= QMessageBox::warning(
835 Tr("Bit 1 in the %1 field of the %2 table is set:"
836 " This font must not be modified"
837 " without permission of the legal owner.\n"
838 "Do you have such a permission?")
839 .arg(QUOTE_STRING_LITERAL("fsType"))
840 .arg(QUOTE_STRING_LITERAL("OS/2")),
841 QMessageBox::Yes
| QMessageBox::No
,
843 if (yesno
== QMessageBox::Yes
)
845 *data
->ignore_restrictions_p
= true;
849 else if (error
== TA_Err_Missing_Unicode_CMap
)
850 QMessageBox::warning(
853 Tr("The input font doesn't contain a Unicode character map.\n"
854 "Maybe you haven't set the %1 checkbox?")
855 .arg(QUOTE_STRING_LITERAL(Tr("Symbol Font"))),
858 else if (error
== TA_Err_Missing_Symbol_CMap
)
859 QMessageBox::warning(
862 Tr("The input font does neither contain a symbol"
863 " nor a character map."),
866 else if (error
== TA_Err_Missing_Glyph
)
867 QMessageBox::warning(
870 Tr("No glyph for a standard character"
871 " to derive standard width and height.\n"
872 "Please check the documentation for a list of"
873 " script-specific standard characters.\n"
875 "Set the %1 checkbox if you want to circumvent this test.")
876 .arg(QUOTE_STRING_LITERAL(Tr("Symbol Font"))),
879 else if (error
>= 0x200 && error
< 0x300)
880 QMessageBox::warning(
883 QString::fromLocal8Bit("%1:%2:%3: %4 (0x%5)<br>"
886 .arg(data
->deltas_name
)
888 .arg(int(errpos
- errline
+ 1))
890 .arg(error
, 2, 16, QLatin1Char('0'))
892 .arg('^', int(errpos
- errline
+ 1))
893 .replace(" ", " "),
897 QMessageBox::warning(
900 Tr("Error code 0x%1 while autohinting font:\n")
901 .arg(error
, 2, 16, QLatin1Char('0'))
902 + QString::fromLocal8Bit(error_string
),
906 if (QFile::exists(data
->output_name
)
907 && remove(qPrintable(data
->output_name
)))
909 const int buf_len
= 1024;
912 strerror_r(errno
, buf
, buf_len
);
913 QMessageBox::warning(
916 Tr("The following error occurred while removing output file %1:\n")
917 .arg(QUOTE_STRING(QDir::toNativeSeparators(data
->output_name
)))
918 + QString::fromLocal8Bit(buf
),
930 statusBar()->clearMessage();
932 QString input_name
= QDir::fromNativeSeparators(input_line
->text());
933 QString output_name
= QDir::fromNativeSeparators(output_line
->text());
934 QString deltas_name
= QDir::fromNativeSeparators(deltas_line
->text());
935 if (!check_filenames(input_name
, output_name
, deltas_name
))
941 // we need C file descriptors for communication with TTF_autohint
947 if (!open_files(input_name
, &input
,
948 output_name
, &output
,
949 deltas_name
, &deltas
))
955 QProgressDialog dialog
;
956 dialog
.setCancelButtonText(tr("Cancel"));
957 dialog
.setMinimumDuration(1000);
958 dialog
.setWindowModality(Qt::WindowModal
);
960 TA_Info_Func info_func
= info
;
961 GUI_Progress_Data gui_progress_data
= {-1, true, &dialog
};
962 GUI_Error_Data gui_error_data
= {this, locale
, output_name
, deltas_name
,
963 &ignore_restrictions
, false};
966 info_data
.data
= NULL
; // must be deallocated after use
967 info_data
.data_wide
= NULL
; // must be deallocated after use
968 info_data
.data_len
= 0;
969 info_data
.data_wide_len
= 0;
971 info_data
.hinting_range_min
= min_box
->value();
972 info_data
.hinting_range_max
= max_box
->value();
973 info_data
.hinting_limit
= no_limit_box
->isChecked()
975 : limit_box
->value();
977 info_data
.gray_strong_stem_width
= gray_box
->isChecked();
978 info_data
.gdi_cleartype_strong_stem_width
= gdi_box
->isChecked();
979 info_data
.dw_cleartype_strong_stem_width
= dw_box
->isChecked();
981 info_data
.increase_x_height
= no_increase_box
->isChecked()
983 : increase_box
->value();
984 info_data
.x_height_snapping_exceptions_string
=
985 qPrintable(x_height_snapping_exceptions_string
);
986 info_data
.fallback_stem_width
= default_stem_width_box
->isChecked()
988 : stem_width_box
->value();
990 info_data
.windows_compatibility
= wincomp_box
->isChecked();
991 info_data
.adjust_subglyphs
= adjust_box
->isChecked();
992 info_data
.hint_composites
= hint_box
->isChecked();
993 info_data
.symbol
= symbol_box
->isChecked();
994 info_data
.dehint
= dehint_box
->isChecked();
996 strncpy(info_data
.default_script
,
997 script_names
[default_box
->currentIndex()].tag
,
998 sizeof (info_data
.default_script
));
999 strncpy(info_data
.fallback_script
,
1000 script_names
[fallback_box
->currentIndex()].tag
,
1001 sizeof (info_data
.fallback_script
));
1003 if (info_box
->isChecked())
1005 int ret
= build_version_string(&info_data
);
1007 QMessageBox::information(
1010 tr("Can't allocate memory for <b>TTFautohint</b> options string"
1011 " in <i>name</i> table."),
1015 QMessageBox::information(
1018 tr("<b>TTFautohint</b> options string"
1019 " in <i>name</i> table too long."),
1026 if (info_data
.symbol
1027 && info_data
.fallback_stem_width
1028 && !strcmp(info_data
.fallback_script
, "none"))
1029 QMessageBox::information(
1032 tr("Setting a fallback stem width for a symbol font"
1033 " without setting a fallback script has no effect."),
1037 fileinfo_input_file
.setFile(input_name
);
1038 fileinfo_deltas_file
.setFile(deltas_name
);
1039 datetime_input_file
= fileinfo_input_file
.lastModified();
1040 datetime_deltas_file
= fileinfo_deltas_file
.lastModified();
1042 QByteArray snapping_string
= snapping_line
->text().toLocal8Bit();
1045 TTF_autohint("in-file, out-file, deltas-file,"
1046 "hinting-range-min, hinting-range-max,"
1048 "gray-strong-stem-width,"
1049 "gdi-cleartype-strong-stem-width,"
1050 "dw-cleartype-strong-stem-width,"
1051 "progress-callback, progress-callback-data,"
1052 "error-callback, error-callback-data,"
1053 "info-callback, info-callback-data,"
1054 "ignore-restrictions,"
1055 "windows-compatibility,"
1058 "increase-x-height,"
1059 "x-height-snapping-exceptions, fallback-stem-width,"
1060 "default-script, fallback-script,"
1062 input
, output
, deltas
,
1063 info_data
.hinting_range_min
, info_data
.hinting_range_max
,
1064 info_data
.hinting_limit
,
1065 info_data
.gray_strong_stem_width
,
1066 info_data
.gdi_cleartype_strong_stem_width
,
1067 info_data
.dw_cleartype_strong_stem_width
,
1068 gui_progress
, &gui_progress_data
,
1069 gui_error
, &gui_error_data
,
1070 info_func
, &info_data
,
1071 ignore_restrictions
,
1072 info_data
.windows_compatibility
,
1073 info_data
.adjust_subglyphs
,
1074 info_data
.hint_composites
,
1075 info_data
.increase_x_height
,
1076 snapping_string
.constData(), info_data
.fallback_stem_width
,
1077 info_data
.default_script
, info_data
.fallback_script
,
1078 info_data
.symbol
, info_data
.dehint
);
1080 if (info_box
->isChecked())
1082 free(info_data
.data
);
1083 free(info_data
.data_wide
);
1093 // retry if there is a user request to do so (handled in `gui_error')
1094 if (gui_error_data
.retry
)
1101 statusBar()->showMessage(tr("Auto-hinting finished")
1103 + QDateTime::currentDateTime()
1104 .toString(Qt::TextDate
)
1107 // we have successfully processed a file;
1108 // start file watching now if requested
1109 if (watch_box
->isChecked())
1115 // XXX distances are specified in pixels,
1116 // making the layout dependent on the output device resolution
1118 Main_GUI::create_layout(bool horizontal_layout
)
1123 QCompleter
* completer
= new QCompleter(this);
1124 QFileSystemModel
* model
= new QFileSystemModel(completer
);
1125 model
->setRootPath(QDir::rootPath());
1126 completer
->setModel(model
);
1128 input_label
= new QLabel(tr("&Input File:"));
1129 input_line
= new Drag_Drop_Line_Edit(DRAG_DROP_TRUETYPE
);
1130 input_button
= new QPushButton(tr("Browse..."));
1131 input_label
->setBuddy(input_line
);
1132 // enforce rich text to get nice word wrapping
1133 input_label
->setToolTip(
1134 tr("<b></b>The input file, either a TrueType font (TTF),"
1135 " TrueType collection (TTC), or a TrueType-based OpenType font."));
1136 input_line
->setCompleter(completer
);
1138 output_label
= new QLabel(tr("&Output File:"));
1139 output_line
= new Drag_Drop_Line_Edit(DRAG_DROP_TRUETYPE
);
1140 output_button
= new QPushButton(tr("Browse..."));
1141 output_label
->setBuddy(output_line
);
1142 output_label
->setToolTip(
1143 tr("<b></b>The output file, which will be essentially identical"
1144 " to the input font but will contain new, generated hints."));
1145 output_line
->setCompleter(completer
);
1147 deltas_label
= new QLabel(tr("Delta &Exception File:"));
1148 deltas_line
= new Drag_Drop_Line_Edit(DRAG_DROP_ANY
);
1149 deltas_button
= new QPushButton(tr("Browse..."));
1150 deltas_label
->setBuddy(deltas_line
);
1151 deltas_label
->setToolTip(
1152 tr("<p>An optional delta exceptions file to fine-tune point positions"
1153 " after hinting, using DELTAP TrueType instructions."
1154 " This text file contains lines of the form<br>"
1156 " [ <i>subfont-idx</i> ]"
1157 " <i>glyph-id</i>"
1158 " <tt>p</tt> <i>points</i>"
1159 " [ <tt>x</tt> <i>shift</i> ]"
1160 " [ <tt>y</tt> <i>shift</i> ]"
1161 " <tt>@</tt> <i>ppems</i><br>"
1163 "<i>subfont-idx</i> gives the subfont index in a TTC,"
1164 " <i>glyph-id</i> is a glyph name or index,"
1165 " the x and y <i>shift</i> values are in the range [-1;1],"
1166 " rounded to multiples of 1/8px,"
1167 " <i>points</i> and <i>ppems</i> are ranges for point indices"
1168 " and ppem values as with x height snapping exceptions.<br>"
1169 "<tt>#</tt> starts a line comment, which gets ignored."
1170 " Empty lines are ignored, too.</p>"
1173 " <tt>Adieresis p 3-6 y 0.25 @ 13</tt>"));
1174 deltas_line
->setCompleter(completer
);
1179 min_label
= new QLabel(tr("Hint Set Range Mi&nimum:"));
1180 min_box
= new QSpinBox
;
1181 min_label
->setBuddy(min_box
);
1182 min_label
->setToolTip(
1183 tr("The minimum PPEM value of the range for which"
1184 " <b>TTFautohint</b> computes <i>hint sets</i>."
1185 " A hint set for a given PPEM value hints this size optimally."
1186 " The larger the range, the more hint sets are considered,"
1187 " usually increasing the size of the bytecode.<br>"
1188 "Note that changing this range doesn't influence"
1189 " the <i>gasp</i> table:"
1190 " Hinting is enabled for all sizes."));
1191 min_box
->setKeyboardTracking(false);
1192 min_box
->setRange(2, 10000);
1194 max_label
= new QLabel(tr("Hint Set Range Ma&ximum:"));
1195 max_box
= new QSpinBox
;
1196 max_label
->setBuddy(max_box
);
1197 max_label
->setToolTip(
1198 tr("The maximum PPEM value of the range for which"
1199 " <b>TTFautohint</b> computes <i>hint sets</i>."
1200 " A hint set for a given PPEM value hints this size optimally."
1201 " The larger the range, the more hint sets are considered,"
1202 " usually increasing the size of the bytecode.<br>"
1203 "Note that changing this range doesn't influence"
1204 " the <i>gasp</i> table:"
1205 " Hinting is enabled for all sizes."));
1206 max_box
->setKeyboardTracking(false);
1207 max_box
->setRange(2, 10000);
1210 // OpenType default script
1212 default_label
= new QLabel(tr("Defa&ult Script:"));
1213 default_box
= new QComboBox
;
1214 default_label
->setBuddy(default_box
);
1215 default_label
->setToolTip(
1216 tr("This sets the default script for OpenType features:"
1217 " After applying all features that are handled specially"
1218 " (for example small caps or superscript glyphs),"
1219 " <b>TTFautohint</b> uses this value for the remaining features."));
1220 for (int i
= 0; script_names
[i
].tag
; i
++)
1222 // XXX: how to provide translations?
1223 default_box
->insertItem(i
,
1225 .arg(script_names
[i
].tag
)
1226 .arg(script_names
[i
].description
));
1230 // hinting and fallback controls
1232 fallback_label
= new QLabel(tr("Fallback &Script:"));
1233 fallback_box
= new QComboBox
;
1234 fallback_label
->setBuddy(fallback_box
);
1235 fallback_label
->setToolTip(
1236 tr("This sets the fallback script for glyphs"
1237 " that <b>TTFautohint</b> can't map to a script automatically."));
1238 for (int i
= 0; script_names
[i
].tag
; i
++)
1240 // XXX: how to provide translations?
1241 fallback_box
->insertItem(i
,
1243 .arg(script_names
[i
].tag
)
1244 .arg(script_names
[i
].description
));
1250 limit_label_text_with_key
= tr("Hinting &Limit:");
1251 limit_label_text
= tr("Hinting Limit:");
1252 limit_label
= new QLabel(limit_label_text_with_key
);
1253 limit_box
= new QSpinBox
;
1254 limit_label
->setBuddy(limit_box
);
1255 limit_label
->setToolTip(
1256 tr("Switch off hinting for PPEM values exceeding this limit."
1257 " Changing this value does not influence the size of the bytecode.<br>"
1258 "Note that <b>TTFautohint</b> handles this feature"
1259 " in the output font's bytecode and not in the <i>gasp</i> table."));
1260 limit_box
->setKeyboardTracking(false);
1261 limit_box
->setRange(2, 10000);
1263 no_limit_box_text_with_key
= tr("No Hinting &Limit");
1264 no_limit_box_text
= tr("No Hinting Limit");
1265 no_limit_box
= new QCheckBox(no_limit_box_text
, this);
1266 no_limit_box
->setToolTip(
1267 tr("If switched on, <b>TTFautohint</b> adds no hinting limit"
1268 " to the bytecode.<br>"
1269 "For testing only."));
1272 // x height increase limit
1274 increase_label_text_with_key
= tr("x Height In&crease Limit:");
1275 increase_label_text
= tr("x Height Increase Limit:");
1276 increase_label
= new QLabel(increase_label_text_with_key
);
1277 increase_box
= new QSpinBox
;
1278 increase_label
->setBuddy(increase_box
);
1279 increase_label
->setToolTip(
1280 tr("For PPEM values in the range 5 < PPEM < <i>n</i>,"
1281 " where <i>n</i> is the value selected by this spin box,"
1282 " round up the font's x height much more often than normally.<br>"
1283 "Use this if holes in letters like <i>e</i> get filled,"
1285 increase_box
->setKeyboardTracking(false);
1286 increase_box
->setRange(6, 10000);
1288 no_increase_box_text_with_key
= tr("No x Height In&crease");
1289 no_increase_box_text
= tr("No x Height Increase");
1290 no_increase_box
= new QCheckBox(no_increase_box_text
, this);
1291 no_increase_box
->setToolTip(
1292 tr("If switched on,"
1293 " <b>TTFautohint</b> does not increase the x height."));
1296 // x height snapping exceptions
1298 snapping_label
= new QLabel(tr("x Height Snapping Excep&tions:"));
1299 snapping_line
= new Tooltip_Line_Edit
;
1300 snapping_label
->setBuddy(snapping_line
);
1301 snapping_label
->setToolTip(
1302 tr("<p>A list of comma separated PPEM values or value ranges"
1303 " at which no x height snapping shall be applied"
1304 " (x height snapping usually slightly increases"
1305 " the size of all glyphs).</p>"
1308 " <tt>2, 3-5, 12-17</tt><br>"
1309 " <tt>-20, 40-</tt>"
1310 " (meaning PPEM ≤ 20 or PPEM ≥ 40)<br>"
1311 " <tt>-</tt> (meaning all possible PPEM values)"));
1314 // fallback stem width
1316 stem_width_label_text_with_key
= tr("Fall&back Stem Width:");
1317 stem_width_label_text
= tr("Fallback Stem Width:");
1318 stem_width_label
= new QLabel(stem_width_label_text_with_key
);
1319 stem_width_box
= new QSpinBox
;
1320 stem_width_label
->setBuddy(stem_width_box
);
1321 stem_width_label
->setToolTip(
1322 tr("Set horizontal stem width (in font units) for all scripts"
1323 " that lack proper standard characters in the font.<br>"
1324 "If not set, <b>TTFautohint</b> uses a hard-coded default value."));
1325 stem_width_box
->setKeyboardTracking(false);
1326 stem_width_box
->setRange(1, 10000);
1328 default_stem_width_box_text_with_key
= tr("Default Fall&back Stem Width");
1329 default_stem_width_box_text
= tr("Default Fallback Stem Width");
1330 default_stem_width_box
= new QCheckBox(default_stem_width_box_text
, this);
1331 default_stem_width_box
->setToolTip(
1332 tr("If switched on, <b>TTFautohint</b> uses a default value"
1333 " for the fallback stem width (50 font units at 2048 UPEM)."));
1338 wincomp_box
= new QCheckBox(tr("Windows Com&patibility"), this);
1339 wincomp_box
->setToolTip(
1340 tr("If switched on, add two artificial blue zones positioned at the"
1341 " <tt>usWinAscent</tt> and <tt>usWinDescent</tt> values"
1342 " (from the font's <i>OS/2</i> table)."
1343 " This option, usually in combination"
1344 " with value <tt>-</tt> (a single dash)"
1345 " for the <i>x Height Snapping Exceptions</i> option,"
1346 " should be used if those two <i>OS/2</i> values are tight,"
1347 " and you are experiencing clipping during rendering."));
1349 adjust_box
= new QCheckBox(tr("Ad&just Subglyphs"), this);
1350 adjust_box
->setToolTip(
1351 tr("If switched on, the original bytecode of the input font"
1352 " gets applied (at EM size, usually 2048ppem)"
1353 " to derive the glyph outlines for <b>TTFautohint</b>.<br>"
1354 "Use this option only if subglyphs"
1355 " are incorrectly scaled and shifted.<br>"
1356 "Note that the original bytecode will always be discarded."));
1358 hint_box
= new QCheckBox(tr("Hint Co&mposites")
1359 + " ", this); // make label wider
1360 hint_box
->setToolTip(
1361 tr("If switched on, <b>TTFautohint</b> hints composite glyphs"
1362 " as a whole, including subglyphs."
1363 " Otherwise, glyph components get hinted separately.<br>"
1364 "Deactivating this flag reduces the bytecode size enormously,"
1365 " however, it might yield worse results."));
1367 symbol_box
= new QCheckBox(tr("S&ymbol Font"), this);
1368 symbol_box
->setToolTip(
1369 tr("If switched on, <b>TTFautohint</b> accepts fonts"
1370 " that don't contain a single standard character"
1371 " for any of the supported scripts.<br>"
1372 "Use this for symbol or dingbat fonts, for example."));
1374 dehint_box
= new QCheckBox(tr("&Dehint"), this);
1375 dehint_box
->setToolTip(
1376 tr("If set, remove all hints from the font.<br>"
1377 "For testing only."));
1379 info_box
= new QCheckBox(tr("Add ttf&autohint Info"), this);
1380 info_box
->setToolTip(
1381 tr("If switched on, information about <b>TTFautohint</b>"
1382 " and its calling parameters are added to the version string(s)"
1383 " (name ID 5) in the <i>name</i> table."));
1386 // stem width and positioning
1388 stem_label
= new QLabel(tr("Stron&g Stem Width and Positioning:"));
1389 stem_label
->setToolTip(
1390 tr("<b>TTFautohint</b> provides two different hinting algorithms"
1391 " that can be selected for various hinting modes."
1393 "<p><i>strong</i> (checkbox set):"
1394 " Position horizontal stems and snap stem widths"
1395 " to integer pixel values. While making the output look crisper,"
1396 " outlines become more distorted.</p>"
1398 "<p><i>smooth</i> (checkbox not set):"
1399 " Use discrete values for horizontal stems and stem widths."
1400 " This only slightly increases the contrast"
1401 " but avoids larger outline distortion.</p>"));
1403 gray_box
= new QCheckBox(tr("Grayscale"), this);
1404 gray_box
->setToolTip(
1405 tr("<b></b>Grayscale rendering, no ClearType activated."));
1406 stem_label
->setBuddy(gray_box
);
1408 gdi_box
= new QCheckBox(tr("GDI ClearType"), this);
1409 gdi_box
->setToolTip(
1410 tr("GDI ClearType rendering,"
1411 " introduced in 2000 for Windows XP.<br>"
1412 "The rasterizer version (as returned by the"
1413 " GETINFO bytecode instruction) is in the range"
1414 " 36 ≤ version < 38, and ClearType is enabled.<br>"
1415 "Along the vertical axis, this mode behaves like B/W rendering."));
1417 dw_box
= new QCheckBox(tr("DW ClearType"), this);
1419 tr("DirectWrite ClearType rendering,"
1420 " introduced in 2008 for Windows Vista.<br>"
1421 "The rasterizer version (as returned by the"
1422 " GETINFO bytecode instruction) is ≥ 38,"
1423 " ClearType is enabled, and subpixel positioning is enabled also.<br>"
1424 "Smooth rendering along the vertical axis."));
1429 watch_box
= new QCheckBox(tr("&Watch Input Files"), this);
1430 watch_box
->setToolTip(
1431 tr("If switched on, <b>TTFautohint</b> automatically re-runs"
1432 " the hinting process as soon as an input file"
1433 " (either the font or the delta exceptions file) is modified.<br>"
1434 "Pressing the %1 button starts watching.<br>"
1435 "If an error occurs, watching stops and must be restarted"
1436 " with the %1 button.")
1437 .arg(QUOTE_STRING_LITERAL(tr("Run"))));
1439 run_button
= new QPushButton(" "
1441 + " "); // make label wider
1443 if (horizontal_layout
)
1444 create_horizontal_layout();
1446 create_vertical_layout();
1450 // XXX distances are specified in pixels,
1451 // making the layout dependent on the output device resolution
1453 Main_GUI::create_vertical_layout()
1456 QGridLayout
* file_layout
= new QGridLayout
;
1458 file_layout
->addWidget(input_label
, 0, 0, Qt::AlignRight
);
1459 file_layout
->addWidget(input_line
, 0, 1);
1460 file_layout
->addWidget(input_button
, 0, 2);
1462 file_layout
->setRowStretch(1, 1);
1464 file_layout
->addWidget(output_label
, 2, 0, Qt::AlignRight
);
1465 file_layout
->addWidget(output_line
, 2, 1);
1466 file_layout
->addWidget(output_button
, 2, 2);
1468 file_layout
->setRowStretch(3, 1);
1470 file_layout
->addWidget(deltas_label
, 4, 0, Qt::AlignRight
);
1471 file_layout
->addWidget(deltas_line
, 4, 1);
1472 file_layout
->addWidget(deltas_button
, 4, 2);
1475 QGridLayout
* run_layout
= new QGridLayout
;
1477 run_layout
->addWidget(watch_box
, 0, 1);
1478 run_layout
->addWidget(run_button
, 0, 3, Qt::AlignRight
);
1479 run_layout
->setColumnStretch(0, 1);
1480 run_layout
->setColumnStretch(2, 2);
1485 QGridLayout
* gui_layout
= new QGridLayout
;
1486 QFrame
* hline
= new QFrame
;
1487 hline
->setFrameShape(QFrame::HLine
);
1488 int row
= 0; // this counter simplifies inserting new items
1490 gui_layout
->setRowMinimumHeight(row
, 10); // XXX urgh, pixels...
1491 gui_layout
->setRowStretch(row
++, 1);
1493 gui_layout
->addLayout(file_layout
, row
, 0, row
, -1);
1494 gui_layout
->setRowStretch(row
++, 1);
1496 gui_layout
->addWidget(hline
, row
, 0, row
, -1);
1497 gui_layout
->setRowStretch(row
++, 1);
1499 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1500 gui_layout
->setRowStretch(row
++, 1);
1502 gui_layout
->addWidget(min_label
, row
, 0, Qt::AlignRight
);
1503 gui_layout
->addWidget(min_box
, row
++, 1, Qt::AlignLeft
);
1504 gui_layout
->addWidget(max_label
, row
, 0, Qt::AlignRight
);
1505 gui_layout
->addWidget(max_box
, row
++, 1, Qt::AlignLeft
);
1507 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1508 gui_layout
->setRowStretch(row
++, 1);
1510 gui_layout
->addWidget(default_label
, row
, 0, Qt::AlignRight
);
1511 gui_layout
->addWidget(default_box
, row
++, 1, Qt::AlignLeft
);
1512 gui_layout
->addWidget(fallback_label
, row
, 0, Qt::AlignRight
);
1513 gui_layout
->addWidget(fallback_box
, row
++, 1, Qt::AlignLeft
);
1515 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1516 gui_layout
->setRowStretch(row
++, 1);
1518 gui_layout
->addWidget(limit_label
, row
, 0, Qt::AlignRight
);
1519 gui_layout
->addWidget(limit_box
, row
++, 1, Qt::AlignLeft
);
1520 gui_layout
->addWidget(no_limit_box
, row
++, 1);
1522 gui_layout
->addWidget(increase_label
, row
, 0, Qt::AlignRight
);
1523 gui_layout
->addWidget(increase_box
, row
++, 1, Qt::AlignLeft
);
1524 gui_layout
->addWidget(no_increase_box
, row
++, 1);
1526 gui_layout
->addWidget(snapping_label
, row
, 0, Qt::AlignRight
);
1527 gui_layout
->addWidget(snapping_line
, row
++, 1, Qt::AlignLeft
);
1529 gui_layout
->addWidget(stem_width_label
, row
, 0, Qt::AlignRight
);
1530 gui_layout
->addWidget(stem_width_box
, row
++, 1, Qt::AlignLeft
);
1531 gui_layout
->addWidget(default_stem_width_box
, row
++, 1);
1533 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1534 gui_layout
->setRowStretch(row
++, 1);
1536 gui_layout
->addWidget(wincomp_box
, row
++, 1);
1537 gui_layout
->addWidget(adjust_box
, row
++, 1);
1538 gui_layout
->addWidget(hint_box
, row
++, 1);
1539 gui_layout
->addWidget(symbol_box
, row
++, 1);
1540 gui_layout
->addWidget(dehint_box
, row
++, 1);
1541 gui_layout
->addWidget(info_box
, row
++, 1);
1543 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1544 gui_layout
->setRowStretch(row
++, 1);
1546 gui_layout
->addWidget(stem_label
, row
, 0, Qt::AlignRight
);
1547 gui_layout
->addWidget(gray_box
, row
++, 1);
1548 gui_layout
->addWidget(gdi_box
, row
++, 1);
1549 gui_layout
->addWidget(dw_box
, row
++, 1);
1551 gui_layout
->setRowMinimumHeight(row
, 30); // XXX urgh, pixels...
1552 gui_layout
->setRowStretch(row
++, 1);
1554 gui_layout
->addLayout(run_layout
, row
, 0, row
, -1);
1556 // create dummy widget to register layout
1557 QWidget
* main_widget
= new QWidget
;
1558 main_widget
->setLayout(gui_layout
);
1559 setCentralWidget(main_widget
);
1560 setWindowTitle("TTFautohint");
1564 // XXX distances are specified in pixels,
1565 // making the layout dependent on the output device resolution
1567 Main_GUI::create_horizontal_layout()
1570 QGridLayout
* file_layout
= new QGridLayout
;
1572 file_layout
->addWidget(input_label
, 0, 0, Qt::AlignRight
);
1573 file_layout
->addWidget(input_line
, 0, 1);
1574 file_layout
->addWidget(input_button
, 0, 2);
1576 file_layout
->setRowStretch(1, 1);
1578 file_layout
->addWidget(output_label
, 2, 0, Qt::AlignRight
);
1579 file_layout
->addWidget(output_line
, 2, 1);
1580 file_layout
->addWidget(output_button
, 2, 2);
1582 file_layout
->setRowStretch(3, 1);
1584 file_layout
->addWidget(deltas_label
, 4, 0, Qt::AlignRight
);
1585 file_layout
->addWidget(deltas_line
, 4, 1);
1586 file_layout
->addWidget(deltas_button
, 4, 2);
1589 QGridLayout
* run_layout
= new QGridLayout
;
1591 run_layout
->addWidget(watch_box
, 0, 1);
1592 run_layout
->addWidget(run_button
, 0, 3, Qt::AlignRight
);
1593 run_layout
->setColumnStretch(0, 2);
1594 run_layout
->setColumnStretch(2, 3);
1595 run_layout
->setColumnStretch(4, 1);
1600 QGridLayout
* gui_layout
= new QGridLayout
;
1601 QFrame
* hline
= new QFrame
;
1602 hline
->setFrameShape(QFrame::HLine
);
1603 int row
= 0; // this counter simplifies inserting new items
1606 gui_layout
->setColumnMinimumWidth(0, 10); // XXX urgh, pixels...
1607 gui_layout
->setColumnStretch(0, 1);
1610 gui_layout
->setRowMinimumHeight(row
, 10); // XXX urgh, pixels...
1611 gui_layout
->setRowStretch(row
++, 1);
1613 gui_layout
->addLayout(file_layout
, row
, 0, row
, -1);
1614 gui_layout
->setRowStretch(row
++, 1);
1616 gui_layout
->addWidget(hline
, row
, 0, row
, -1);
1617 gui_layout
->setRowStretch(row
++, 1);
1619 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1620 gui_layout
->setRowStretch(row
++, 1);
1622 gui_layout
->addWidget(min_label
, row
, 1, Qt::AlignRight
);
1623 gui_layout
->addWidget(min_box
, row
++, 2, Qt::AlignLeft
);
1624 gui_layout
->addWidget(max_label
, row
, 1, Qt::AlignRight
);
1625 gui_layout
->addWidget(max_box
, row
++, 2, Qt::AlignLeft
);
1627 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1628 gui_layout
->setRowStretch(row
++, 1);
1630 gui_layout
->addWidget(default_label
, row
, 1, Qt::AlignRight
);
1631 gui_layout
->addWidget(default_box
, row
++, 2, Qt::AlignLeft
);
1632 gui_layout
->addWidget(fallback_label
, row
, 1, Qt::AlignRight
);
1633 gui_layout
->addWidget(fallback_box
, row
++, 2, Qt::AlignLeft
);
1635 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1636 gui_layout
->setRowStretch(row
++, 1);
1638 gui_layout
->addWidget(limit_label
, row
, 1, Qt::AlignRight
);
1639 gui_layout
->addWidget(limit_box
, row
++, 2, Qt::AlignLeft
);
1640 gui_layout
->addWidget(no_limit_box
, row
++, 2);
1642 gui_layout
->addWidget(increase_label
, row
, 1, Qt::AlignRight
);
1643 gui_layout
->addWidget(increase_box
, row
++, 2, Qt::AlignLeft
);
1644 gui_layout
->addWidget(no_increase_box
, row
++, 2);
1646 gui_layout
->addWidget(snapping_label
, row
, 1, Qt::AlignRight
);
1647 gui_layout
->addWidget(snapping_line
, row
++, 2, Qt::AlignLeft
);
1649 gui_layout
->addWidget(stem_width_label
, row
, 1, Qt::AlignRight
);
1650 gui_layout
->addWidget(stem_width_box
, row
++, 2, Qt::AlignLeft
);
1651 gui_layout
->addWidget(default_stem_width_box
, row
++, 2);
1653 gui_layout
->setRowMinimumHeight(row
, 30); // XXX urgh, pixels...
1654 gui_layout
->setRowStretch(row
++, 1);
1656 gui_layout
->addLayout(run_layout
, row
, 0, row
, -1);
1659 gui_layout
->setColumnMinimumWidth(3, 20); // XXX urgh, pixels...
1660 gui_layout
->setColumnStretch(3, 1);
1664 gui_layout
->addWidget(wincomp_box
, row
++, 4);
1665 gui_layout
->addWidget(adjust_box
, row
++, 4);
1666 gui_layout
->addWidget(hint_box
, row
++, 4);
1667 gui_layout
->addWidget(symbol_box
, row
++, 4);
1668 gui_layout
->addWidget(dehint_box
, row
++, 4);
1669 gui_layout
->addWidget(info_box
, row
++, 4);
1671 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1672 gui_layout
->setRowStretch(row
++, 1);
1674 gui_layout
->addWidget(stem_label
, row
++, 4);
1676 QGridLayout
* stem_layout
= new QGridLayout
;
1677 stem_layout
->setColumnMinimumWidth(0, 20); // XXX urgh, pixels...
1678 stem_layout
->addWidget(gray_box
, 0, 1);
1679 stem_layout
->addWidget(gdi_box
, 1, 1);
1680 stem_layout
->addWidget(dw_box
, 2, 1);
1682 gui_layout
->addLayout(stem_layout
, row
, 4, 3, 1);
1686 gui_layout
->setColumnMinimumWidth(5, 10); // XXX urgh, pixels...
1687 gui_layout
->setColumnStretch(5, 1);
1689 // create dummy widget to register layout
1690 QWidget
* main_widget
= new QWidget
;
1691 main_widget
->setLayout(gui_layout
);
1692 setCentralWidget(main_widget
);
1693 setWindowTitle("TTFautohint");
1698 Main_GUI::create_connections()
1700 connect(input_button
, SIGNAL(clicked()), this,
1701 SLOT(browse_input()));
1702 connect(output_button
, SIGNAL(clicked()), this,
1703 SLOT(browse_output()));
1704 connect(deltas_button
, SIGNAL(clicked()), this,
1705 SLOT(browse_deltas()));
1707 connect(input_line
, SIGNAL(textChanged(QString
)), this,
1709 connect(output_line
, SIGNAL(textChanged(QString
)), this,
1712 connect(input_line
, SIGNAL(editingFinished()), this,
1713 SLOT(absolute_input()));
1714 connect(output_line
, SIGNAL(editingFinished()), this,
1715 SLOT(absolute_output()));
1716 connect(deltas_line
, SIGNAL(editingFinished()), this,
1717 SLOT(absolute_deltas()));
1719 connect(min_box
, SIGNAL(valueChanged(int)), this,
1721 connect(max_box
, SIGNAL(valueChanged(int)), this,
1724 connect(limit_box
, SIGNAL(valueChanged(int)), this,
1725 SLOT(check_limit()));
1726 connect(no_limit_box
, SIGNAL(clicked()), this,
1727 SLOT(check_no_limit()));
1729 connect(no_increase_box
, SIGNAL(clicked()), this,
1730 SLOT(check_no_increase()));
1732 connect(snapping_line
, SIGNAL(editingFinished()), this,
1733 SLOT(check_number_set()));
1734 connect(snapping_line
, SIGNAL(textEdited(QString
)), this,
1735 SLOT(clear_status_bar()));
1737 connect(default_stem_width_box
, SIGNAL(clicked()), this,
1738 SLOT(check_default_stem_width()));
1740 connect(dehint_box
, SIGNAL(clicked()), this,
1741 SLOT(check_dehint()));
1743 connect(timer
, SIGNAL(timeout()), this,
1744 SLOT(watch_files()));
1746 connect(watch_box
, SIGNAL(clicked()), this,
1747 SLOT(check_watch()));
1749 connect(run_button
, SIGNAL(clicked()), this,
1755 Main_GUI::create_actions()
1757 exit_act
= new QAction(tr("E&xit"), this);
1758 exit_act
->setShortcuts(QKeySequence::Quit
);
1759 connect(exit_act
, SIGNAL(triggered()), this, SLOT(close()));
1761 about_act
= new QAction(tr("&About"), this);
1762 connect(about_act
, SIGNAL(triggered()), this, SLOT(about()));
1764 about_Qt_act
= new QAction(tr("About &Qt"), this);
1765 connect(about_Qt_act
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
1770 Main_GUI::create_menus()
1772 file_menu
= menuBar()->addMenu(tr("&File"));
1773 file_menu
->addAction(exit_act
);
1775 help_menu
= menuBar()->addMenu(tr("&Help"));
1776 help_menu
->addAction(about_act
);
1777 help_menu
->addAction(about_Qt_act
);
1782 Main_GUI::create_status_bar()
1784 statusBar()->showMessage("");
1789 Main_GUI::set_defaults()
1791 min_box
->setValue(hinting_range_min
);
1792 max_box
->setValue(hinting_range_max
);
1794 default_box
->setCurrentIndex(default_script_idx
);
1795 fallback_box
->setCurrentIndex(fallback_script_idx
);
1797 limit_box
->setValue(hinting_limit
? hinting_limit
: hinting_range_max
);
1798 // handle command line option `--hinting-limit=0'
1801 hinting_limit
= max_box
->value();
1802 no_limit_box
->setChecked(true);
1805 increase_box
->setValue(increase_x_height
? increase_x_height
1806 : TA_INCREASE_X_HEIGHT
);
1807 // handle command line option `--increase-x-height=0'
1808 if (!increase_x_height
)
1810 increase_x_height
= TA_INCREASE_X_HEIGHT
;
1811 no_increase_box
->setChecked(true);
1814 snapping_line
->setText(x_height_snapping_exceptions_string
);
1816 if (fallback_stem_width
)
1817 stem_width_box
->setValue(fallback_stem_width
);
1820 stem_width_box
->setValue(50);
1821 default_stem_width_box
->setChecked(true);
1824 if (windows_compatibility
)
1825 wincomp_box
->setChecked(true);
1826 if (adjust_subglyphs
)
1827 adjust_box
->setChecked(true);
1828 if (hint_composites
)
1829 hint_box
->setChecked(true);
1831 symbol_box
->setChecked(true);
1833 dehint_box
->setChecked(true);
1835 info_box
->setChecked(true);
1837 if (gray_strong_stem_width
)
1838 gray_box
->setChecked(true);
1839 if (gdi_cleartype_strong_stem_width
)
1840 gdi_box
->setChecked(true);
1841 if (dw_cleartype_strong_stem_width
)
1842 dw_box
->setChecked(true);
1844 run_button
->setEnabled(false);
1851 check_no_increase();
1854 // do this last since it disables almost everything
1860 Main_GUI::read_settings()
1863 // QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
1864 // QSize size = settings.value("size", QSize(400, 400)).toSize();
1871 Main_GUI::write_settings()
1874 // settings.setValue("pos", pos());
1875 // settings.setValue("size", size());
1878 // end of maingui.cpp