3 // Copyright (C) 2012-2017 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.
24 #include FT_FREETYPE_H
29 #include <ttfautohint.h>
32 // XXX Qt 4.8 bug: locale->quoteString("foo")
33 // inserts wrongly encoded quote characters
34 // into rich text QString
35 #if HAVE_QT_QUOTESTRING
36 # define QUOTE_STRING(x) locale->quoteString(x)
37 # define QUOTE_STRING_LITERAL(x) locale->quoteString(x)
39 # define QUOTE_STRING(x) "\"" + x + "\""
40 # define QUOTE_STRING_LITERAL(x) "\"" x "\""
44 // Shorthand for `tr' using a local `TRDOMAIN'.
45 #define Tr(text) QCoreApplication::translate(TRDOMAIN, text)
48 typedef struct Tag_Names_
51 const char* description
;
55 // the available script tags and its descriptions are directly extracted
56 // from `ttfautohint-scripts.h'
58 #define SCRIPT(s, S, d, h, H, ss) \
61 const Tag_Names script_names
[] =
63 #include <ttfautohint-scripts.h>
68 // the available feature tags and its descriptions are directly extracted
69 // from `ttfautohint-coverages.h'
71 #define COVERAGE(n, N, d, t, t1, t2, t3, t4) \
74 const Tag_Names feature_names
[] =
76 #include <ttfautohint-coverages.h>
82 // a: Add ttf&autohint Info
83 // b: Add TTFA info ta&ble
84 // c: x Height In&crease Limit / No x Height In&crease
86 // e: Control Instructions Fil&e
88 // g: Stron&g Stem Width and Positioning
91 // j: Ad&just Subglyphs
92 // k: Fallbac&k Script
93 // l: Hinting &Limit / No Hinting &Limit
94 // m: Hint Co&mposites
95 // n: Hint Set Range Mi&nimum
97 // p: Windows Com&patibility
100 // s: Fallback &Stem Width / Default Fallback &Stem Width
101 // t: x Height Snapping Excep&tions
102 // u: Defa&ult Script
104 // w: &Watch Input Files
105 // x: Hint Set Range Ma&ximum
107 // z: Blue &Zone Reference Font
108 // :: Family Suffix&:
110 Main_GUI::Main_GUI(bool horizontal_layout
,
118 const char* exceptions
,
127 const char* fallback
,
133 : hinting_range_min(range_min
),
134 hinting_range_max(range_max
),
135 hinting_limit(limit
),
136 gray_strong_stem_width(gray
),
137 gdi_cleartype_strong_stem_width(gdi
),
138 dw_cleartype_strong_stem_width(dw
),
139 increase_x_height(increase
),
140 x_height_snapping_exceptions_string(exceptions
),
141 fallback_stem_width(stem_width
),
142 ignore_restrictions(ignore
),
143 windows_compatibility(wincomp
),
144 adjust_subglyphs(adjust
),
145 hint_composites(composites
),
147 detailed_info(detailed
),
148 fallback_scaling(scaling
),
149 family_suffix(suffix
),
154 fallback_do_scale(1),
159 for (i
= 0; script_names
[i
].tag
; i
++)
161 if (!strcmp("latn", script_names
[i
].tag
))
163 if (!strcmp("none", script_names
[i
].tag
))
167 // map default script and fallback script tags to indices
168 for (i
= 0; script_names
[i
].tag
; i
++)
169 if (!strcmp(dflt
, script_names
[i
].tag
))
171 default_script_idx
= script_names
[i
].tag
? i
: latn_script_idx
;
173 for (i
= 0; script_names
[i
].tag
; i
++)
174 if (!strcmp(fallback
, script_names
[i
].tag
))
176 fallback_script_idx
= script_names
[i
].tag
? i
: none_script_idx
;
178 x_height_snapping_exceptions
= NULL
;
180 // if the current input files have been updated
181 // we wait a given time interval, then we reload the files
182 file_watcher
= new QFileSystemWatcher(this);
183 timer
= new QTimer(this);
184 timer
->setInterval(1000); // XXX make this configurable
185 timer
->setSingleShot(true);
186 fileinfo_input_file
.setCaching(false);
187 fileinfo_control_file
.setCaching(false);
188 fileinfo_reference_file
.setCaching(false);
190 // XXX register translations somewhere and loop over them
191 if (QLocale::system().name() == "en_US")
192 locale
= new QLocale
;
194 locale
= new QLocale(QLocale::C
);
196 // For real numbers (both parsing and displaying) we only use `.' as the
197 // decimal separator; similarly, we don't want localized formats like a
198 // thousands separator for any number.
199 setlocale(LC_NUMERIC
, "C");
201 create_layout(horizontal_layout
);
202 create_connections();
210 setUnifiedTitleAndToolBarOnMac(true);
214 Main_GUI::~Main_GUI()
216 number_set_free(x_height_snapping_exceptions
);
223 Main_GUI::closeEvent(QCloseEvent
* event
)
233 QMessageBox::about(this,
234 tr("About TTFautohint"),
235 tr("<p>This is <b>TTFautohint</b> version %1<br>"
236 " Copyright %2 2011-2017<br>"
237 " by Werner Lemberg <tt><wl@gnu.org></tt></p>"
239 "<p><b>TTFautohint</b> adds new auto-generated hints"
240 " to a TrueType font or TrueType collection.</p>"
243 " <a href='http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT'>FreeType"
244 " License (FTL)</a> or"
245 " <a href='http://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/GPLv2.TXT'>GNU"
253 Main_GUI::browse_input()
255 // XXX remember last directory
256 QString file
= QFileDialog::getOpenFileName(
258 tr("Open Input Font"),
263 input_line
->setText(QDir::toNativeSeparators(file
));
268 Main_GUI::browse_output()
270 // XXX remember last directory
271 QString file
= QFileDialog::getSaveFileName(
273 tr("Open Output Font"),
278 output_line
->setText(QDir::toNativeSeparators(file
));
283 Main_GUI::browse_control()
285 // XXX remember last directory
286 QString file
= QFileDialog::getOpenFileName(
288 tr("Open Control Instructions File"),
293 control_line
->setText(QDir::toNativeSeparators(file
));
298 Main_GUI::browse_reference()
300 // XXX remember last directory
301 QString file
= QFileDialog::getOpenFileName(
303 tr("Open Blue Zone Reference Font"),
308 reference_line
->setText(QDir::toNativeSeparators(file
));
313 Main_GUI::check_min()
315 int min
= min_box
->value();
316 int max
= max_box
->value();
317 int limit
= limit_box
->value();
319 max_box
->setValue(min
);
321 limit_box
->setValue(min
);
326 Main_GUI::check_max()
328 int min
= min_box
->value();
329 int max
= max_box
->value();
330 int limit
= limit_box
->value();
332 min_box
->setValue(max
);
334 limit_box
->setValue(max
);
339 Main_GUI::check_limit()
341 int min
= min_box
->value();
342 int max
= max_box
->value();
343 int limit
= limit_box
->value();
345 max_box
->setValue(limit
);
347 min_box
->setValue(limit
);
352 Main_GUI::check_dehint()
354 if (dehint_box
->isChecked())
356 control_label
->setEnabled(false);
357 control_line
->setEnabled(false);
358 control_button
->setEnabled(false);
360 reference_label
->setEnabled(false);
361 reference_line
->setEnabled(false);
362 reference_button
->setEnabled(false);
364 min_label
->setEnabled(false);
365 min_box
->setEnabled(false);
367 max_label
->setEnabled(false);
368 max_box
->setEnabled(false);
370 default_label
->setEnabled(false);
371 default_box
->setEnabled(false);
372 fallback_label
->setEnabled(false);
373 fallback_hint_or_scale_box
->setEnabled(false);
374 fallback_box
->setEnabled(false);
376 no_limit_box
->setEnabled(false);
377 limit_label
->setEnabled(false);
378 limit_box
->setEnabled(false);
380 no_x_increase_box
->setEnabled(false);
381 x_increase_label
->setEnabled(false);
382 x_increase_box
->setEnabled(false);
384 snapping_label
->setEnabled(false);
385 snapping_line
->setEnabled(false);
387 default_stem_width_box
->setEnabled(false);
388 stem_width_label
->setEnabled(false);
389 stem_width_box
->setEnabled(false);
391 wincomp_box
->setEnabled(false);
392 adjust_box
->setEnabled(false);
393 hint_box
->setEnabled(false);
394 symbol_box
->setEnabled(false);
396 ref_idx_label
->setEnabled(false);
397 ref_idx_box
->setEnabled(false);
399 stem_label
->setEnabled(false);
400 gray_box
->setEnabled(false);
401 gdi_box
->setEnabled(false);
402 dw_box
->setEnabled(false);
406 control_label
->setEnabled(true);
407 control_line
->setEnabled(true);
408 control_button
->setEnabled(true);
410 reference_label
->setEnabled(true);
411 reference_line
->setEnabled(true);
412 reference_button
->setEnabled(true);
414 min_label
->setEnabled(true);
415 min_box
->setEnabled(true);
417 max_label
->setEnabled(true);
418 max_box
->setEnabled(true);
420 default_label
->setEnabled(true);
421 default_box
->setEnabled(true);
422 fallback_label
->setEnabled(true);
423 fallback_hint_or_scale_box
->setEnabled(true);
424 fallback_box
->setEnabled(true);
426 no_limit_box
->setEnabled(true);
429 no_x_increase_box
->setEnabled(true);
430 check_no_x_increase();
432 snapping_label
->setEnabled(true);
433 snapping_line
->setEnabled(true);
435 default_stem_width_box
->setEnabled(true);
436 check_default_stem_width();
438 wincomp_box
->setEnabled(true);
439 adjust_box
->setEnabled(true);
440 hint_box
->setEnabled(true);
441 symbol_box
->setEnabled(true);
443 ref_idx_label
->setEnabled(true);
444 ref_idx_box
->setEnabled(true);
446 stem_label
->setEnabled(true);
447 gray_box
->setEnabled(true);
448 gdi_box
->setEnabled(true);
449 dw_box
->setEnabled(true);
455 Main_GUI::check_no_limit()
457 if (no_limit_box
->isChecked())
459 limit_label
->setEnabled(false);
460 limit_label
->setText(limit_label_text
);
461 limit_box
->setEnabled(false);
462 no_limit_box
->setText(no_limit_box_text_with_key
);
466 limit_label
->setEnabled(true);
467 limit_label
->setText(limit_label_text_with_key
);
468 limit_box
->setEnabled(true);
469 no_limit_box
->setText(no_limit_box_text
);
475 Main_GUI::check_no_x_increase()
477 if (no_x_increase_box
->isChecked())
479 x_increase_label
->setEnabled(false);
480 x_increase_label
->setText(x_increase_label_text
);
481 x_increase_box
->setEnabled(false);
482 no_x_increase_box
->setText(no_x_increase_box_text_with_key
);
486 x_increase_label
->setEnabled(true);
487 x_increase_label
->setText(x_increase_label_text_with_key
);
488 x_increase_box
->setEnabled(true);
489 no_x_increase_box
->setText(no_x_increase_box_text
);
495 Main_GUI::check_default_stem_width()
497 if (default_stem_width_box
->isChecked())
499 stem_width_label
->setEnabled(false);
500 stem_width_label
->setText(stem_width_label_text
);
501 stem_width_box
->setEnabled(false);
502 default_stem_width_box
->setText(default_stem_width_box_text_with_key
);
506 stem_width_label
->setEnabled(true);
507 stem_width_label
->setText(stem_width_label_text_with_key
);
508 stem_width_box
->setEnabled(true);
509 default_stem_width_box
->setText(default_stem_width_box_text
);
515 Main_GUI::check_run()
517 if (input_line
->text().isEmpty() || output_line
->text().isEmpty())
518 run_button
->setEnabled(false);
520 run_button
->setEnabled(true);
525 Main_GUI::absolute_input()
527 QString input_name
= QDir::fromNativeSeparators(input_line
->text());
528 if (!input_name
.isEmpty()
529 && QDir::isRelativePath(input_name
))
531 QDir
cur_path(QDir::currentPath() + "/" + input_name
);
532 input_line
->setText(QDir::toNativeSeparators(cur_path
.absolutePath()));
538 Main_GUI::absolute_output()
540 QString output_name
= QDir::fromNativeSeparators(output_line
->text());
541 if (!output_name
.isEmpty()
542 && QDir::isRelativePath(output_name
))
544 QDir
cur_path(QDir::currentPath() + "/" + output_name
);
545 output_line
->setText(QDir::toNativeSeparators(cur_path
.absolutePath()));
551 Main_GUI::absolute_control()
553 QString control_name
= QDir::fromNativeSeparators(control_line
->text());
554 if (!control_name
.isEmpty()
555 && QDir::isRelativePath(control_name
))
557 QDir
cur_path(QDir::currentPath() + "/" + control_name
);
558 control_line
->setText(QDir::toNativeSeparators(cur_path
.absolutePath()));
564 Main_GUI::absolute_reference()
566 QString reference_name
= QDir::fromNativeSeparators(reference_line
->text());
567 if (!reference_name
.isEmpty()
568 && QDir::isRelativePath(reference_name
))
570 QDir
cur_path(QDir::currentPath() + "/" + reference_name
);
571 reference_line
->setText(QDir::toNativeSeparators(cur_path
.absolutePath()));
577 Main_GUI::set_ref_idx_box_max()
579 QString reference_name
= QDir::fromNativeSeparators(reference_line
->text());
581 FT_Library library
= NULL
;
585 // we don't handle errors
586 // since `TTF_autohint' checks the reference font (and index) later on
587 error
= FT_Init_FreeType(&library
);
589 error
= FT_New_Face(library
, qPrintable(reference_name
), -1, &face
);
591 ref_idx_box
->setRange(0, error
? 100 : int(face
->num_faces
- 1));
594 FT_Done_FreeType(library
);
599 Main_GUI::check_number_set()
601 QString text
= snapping_line
->text();
604 // construct ASCII string from arbitrary Unicode data;
605 // the idea is to accept, say, CJK fullwidth digits also
606 for (int i
= 0; i
< text
.size(); i
++)
608 QChar c
= text
.at(i
);
610 int digit
= c
.digitValue();
612 qs
+= QString::number(digit
);
613 else if (c
.isSpace())
615 // U+30FC KATAGANA-HIRAGANA PROLONGED SOUND MARK is assigned
616 // to the `-' key in some Japanese input methods
617 else if (c
.category() == QChar::Punctuation_Dash
618 || c
== QChar(0x30FC))
620 // various Unicode COMMA characters,
621 // including representation forms
622 else if (c
== QChar(',')
623 || c
== QChar(0x055D)
624 || c
== QChar(0x060C)
625 || c
== QChar(0x07F8)
626 || c
== QChar(0x1363)
627 || c
== QChar(0x1802)
628 || c
== QChar(0x1808)
629 || c
== QChar(0x3001)
630 || c
== QChar(0xA4FE)
631 || c
== QChar(0xA60D)
632 || c
== QChar(0xA6F5)
633 || c
== QChar(0xFE10)
634 || c
== QChar(0xFE11)
635 || c
== QChar(0xFE50)
636 || c
== QChar(0xFE51)
637 || c
== QChar(0xFF0C)
638 || c
== QChar(0xFF64))
641 qs
+= c
; // we do error handling below
644 if (x_height_snapping_exceptions
)
645 number_set_free(x_height_snapping_exceptions
);
647 QByteArray str
= qs
.toLocal8Bit();
648 const char* s
= number_set_parse(str
.constData(),
649 &x_height_snapping_exceptions
,
653 statusBar()->setStyleSheet("color: red;");
654 if (x_height_snapping_exceptions
== NUMBERSET_ALLOCATION_ERROR
)
655 statusBar()->showMessage(
656 tr("allocation error"));
657 else if (x_height_snapping_exceptions
== NUMBERSET_INVALID_CHARACTER
)
658 statusBar()->showMessage(
659 tr("invalid character (use digits, dashes, commas, and spaces)"));
660 else if (x_height_snapping_exceptions
== NUMBERSET_OVERFLOW
)
661 statusBar()->showMessage(
663 else if (x_height_snapping_exceptions
== NUMBERSET_INVALID_RANGE
)
664 statusBar()->showMessage(
665 tr("invalid range (minimum is 6, maximum is 32767)"));
666 else if (x_height_snapping_exceptions
== NUMBERSET_OVERLAPPING_RANGES
)
667 statusBar()->showMessage(
668 tr("overlapping ranges"));
669 else if (x_height_snapping_exceptions
== NUMBERSET_NOT_ASCENDING
)
670 statusBar()->showMessage(
671 tr("values und ranges must be specified in ascending order"));
673 snapping_line
->setText(qs
);
674 snapping_line
->setFocus(Qt::OtherFocusReason
);
675 snapping_line
->setCursorPosition(int(s
- str
.constData()));
677 x_height_snapping_exceptions
= NULL
;
681 // normalize if there is no error
682 char* new_str
= number_set_show(x_height_snapping_exceptions
,
684 snapping_line
->setText(new_str
);
691 Main_GUI::check_family_suffix()
693 QByteArray text
= family_suffix_line
->text().toLocal8Bit();
694 const char* s
= text
.constData();
696 if (const char* pos
= ::check_family_suffix(s
))
698 statusBar()->setStyleSheet("color: red;");
699 statusBar()->showMessage(
700 tr("invalid character (use printable ASCII except %()/<>[]{})"));
701 family_suffix_line
->setFocus(Qt::OtherFocusReason
);
702 family_suffix_line
->setCursorPosition(int(pos
- s
));
708 Main_GUI::clear_status_bar()
710 statusBar()->clearMessage();
711 statusBar()->setStyleSheet("");
716 Main_GUI::check_filenames(const QString
& input_name
,
717 const QString
& output_name
,
718 const QString
& control_name
,
719 const QString
& reference_name
)
721 if (!QFile::exists(input_name
))
723 QMessageBox::warning(
726 tr("The file %1 cannot be found.")
727 .arg(QUOTE_STRING(QDir::toNativeSeparators(input_name
))),
733 if (input_name
== output_name
)
735 QMessageBox::warning(
738 tr("Input and output file names must be different."),
744 // silently overwrite if watching is active
745 if (QFile::exists(output_name
) && !watch_box
->isChecked())
747 int ret
= QMessageBox::warning(
750 tr("The file %1 already exists.\n"
752 .arg(QUOTE_STRING(QDir::toNativeSeparators(output_name
))),
753 QMessageBox::Yes
| QMessageBox::No
,
755 if (ret
== QMessageBox::No
)
759 if (!control_name
.isEmpty() && !QFile::exists(control_name
))
761 QMessageBox::warning(
764 tr("The file %1 cannot be found.")
765 .arg(QUOTE_STRING(QDir::toNativeSeparators(control_name
))),
771 if (!reference_name
.isEmpty() && !QFile::exists(reference_name
))
773 QMessageBox::warning(
776 tr("The file %1 cannot be found.")
777 .arg(QUOTE_STRING(QDir::toNativeSeparators(reference_name
))),
788 Main_GUI::open_files(const QString
& input_name
,
790 const QString
& output_name
,
792 const QString
& control_name
,
794 const QString
& reference_name
,
797 const int buf_len
= 1024;
800 *in
= fopen(qPrintable(input_name
), "rb");
803 strerror_r(errno
, buf
, buf_len
);
804 QMessageBox::warning(
807 tr("The following error occurred while opening input file %1:\n")
808 .arg(QUOTE_STRING(QDir::toNativeSeparators(input_name
)))
809 + QString::fromLocal8Bit(buf
),
815 *out
= fopen(qPrintable(output_name
), "wb");
818 strerror_r(errno
, buf
, buf_len
);
819 QMessageBox::warning(
822 tr("The following error occurred while opening output file %1:\n")
823 .arg(QUOTE_STRING(QDir::toNativeSeparators(output_name
)))
824 + QString::fromLocal8Bit(buf
),
830 if (!control_name
.isEmpty())
832 *control
= fopen(qPrintable(control_name
), "r");
835 strerror_r(errno
, buf
, buf_len
);
836 QMessageBox::warning(
839 tr("The following error occurred"
840 " while opening control instructions file %1:\n")
841 .arg(QUOTE_STRING(QDir::toNativeSeparators(control_name
)))
842 + QString::fromLocal8Bit(buf
),
851 if (!reference_name
.isEmpty())
853 *reference
= fopen(qPrintable(reference_name
), "rb");
856 strerror_r(errno
, buf
, buf_len
);
857 QMessageBox::warning(
860 tr("The following error occurred"
861 " while opening blue zone reference file %1:\n")
862 .arg(QUOTE_STRING(QDir::toNativeSeparators(reference_name
)))
863 + QString::fromLocal8Bit(buf
),
877 Main_GUI::check_watch()
879 if (watch_box
->isChecked())
881 // file watching gets started in the `run' function
890 Main_GUI::start_timer()
892 // we delay the file watching action, mainly to ensure
893 // that newly generated files have been completely written to disk
900 Main_GUI::stop_watching()
903 if (!fileinfo_input_file
.fileName().isEmpty())
904 file_watcher
->removePath(fileinfo_input_file
.fileName());
905 if (!fileinfo_control_file
.fileName().isEmpty())
906 file_watcher
->removePath(fileinfo_control_file
.fileName());
907 if (!fileinfo_reference_file
.fileName().isEmpty())
908 file_watcher
->removePath(fileinfo_reference_file
.fileName());
913 Main_GUI::watch_files()
915 if (fileinfo_input_file
.exists()
916 && fileinfo_input_file
.isReadable()
917 && (fileinfo_control_file
.fileName().isEmpty()
919 : (fileinfo_control_file
.exists()
920 && fileinfo_control_file
.isReadable()))
921 && (fileinfo_reference_file
.fileName().isEmpty()
923 : (fileinfo_reference_file
.exists()
924 && fileinfo_reference_file
.isReadable())))
926 QDateTime modified_input
= fileinfo_input_file
.lastModified();
927 QDateTime modified_control
= fileinfo_control_file
.lastModified();
928 QDateTime modified_reference
= fileinfo_reference_file
.lastModified();
929 // XXX make this configurable
930 if (datetime_input_file
.msecsTo(modified_input
) > 1000
931 || datetime_control_file
.msecsTo(modified_control
) > 1000
932 || datetime_reference_file
.msecsTo(modified_reference
) > 1000)
935 run(); // this function sets `datetime_XXX'
939 // restart timer for symlinks
940 if (watch_box
->isChecked())
942 if (fileinfo_input_file
.isSymLink()
943 || fileinfo_control_file
.isSymLink()
944 || fileinfo_reference_file
.isSymLink())
951 if (check
== DoCheck
)
953 else if (check
== CheckLater
)
956 run(); // let this routine handle all errors
963 struct GUI_Progress_Data
967 QProgressDialog
* dialog
;
972 #define TRDOMAIN "GuiProgress"
975 gui_progress(long curr_idx
,
981 GUI_Progress_Data
* data
= static_cast<GUI_Progress_Data
*>(user
);
983 if (num_sfnts
> 1 && curr_sfnt
!= data
->last_sfnt
)
985 data
->dialog
->setLabelText(Tr("Auto-hinting subfont %1 of %2"
986 " with %3 glyphs...")
991 if (curr_sfnt
+ 1 == num_sfnts
)
993 data
->dialog
->setAutoReset(true);
994 data
->dialog
->setAutoClose(true);
998 data
->dialog
->setAutoReset(false);
999 data
->dialog
->setAutoClose(false);
1002 data
->last_sfnt
= curr_sfnt
;
1009 data
->dialog
->setLabelText(Tr("Auto-hinting %1 glyphs...")
1011 data
->dialog
->setMaximum(int(num_glyphs
- 1));
1013 data
->begin
= false;
1016 data
->dialog
->setValue(int(curr_idx
));
1018 if (data
->dialog
->wasCanceled())
1025 struct GUI_Error_Data
1029 QString output_name
;
1030 QString control_name
;
1031 QString reference_name
;
1032 int* ignore_restrictions_p
;
1038 #define TRDOMAIN "GuiError"
1041 gui_error(TA_Error error
,
1042 const char* error_string
,
1043 unsigned int errlinenum
,
1044 const char* errline
,
1048 GUI_Error_Data
* data
= static_cast<GUI_Error_Data
*>(user
);
1049 QLocale
* locale
= data
->locale
; // for QUOTE_STRING_LITERAL
1054 if (error
== TA_Err_Canceled
)
1056 else if (error
== TA_Err_Invalid_FreeType_Version
)
1057 QMessageBox::critical(
1060 Tr("FreeType version 2.4.5 or higher is needed.\n"
1061 "Are you perhaps using a wrong FreeType DLL?"),
1064 else if (error
== TA_Err_Invalid_Font_Type
)
1065 QMessageBox::warning(
1068 Tr("This font is not a valid font"
1069 " in SFNT format with TrueType outlines.\n"
1070 "In particular, CFF outlines are not supported."),
1073 else if (error
== TA_Err_Already_Processed
)
1074 QMessageBox::warning(
1077 Tr("This font has already been processed by TTFautohint."),
1080 else if (error
== TA_Err_Missing_Legal_Permission
)
1082 int yesno
= QMessageBox::warning(
1085 Tr("Bit 1 in the %1 field of the %2 table is set:"
1086 " This font must not be modified"
1087 " without permission of the legal owner.\n"
1088 "Do you have such a permission?")
1089 .arg(QUOTE_STRING_LITERAL("fsType"))
1090 .arg(QUOTE_STRING_LITERAL("OS/2")),
1091 QMessageBox::Yes
| QMessageBox::No
,
1093 if (yesno
== QMessageBox::Yes
)
1095 *data
->ignore_restrictions_p
= true;
1099 else if (error
== TA_Err_Missing_Unicode_CMap
)
1100 QMessageBox::warning(
1103 Tr("The input font doesn't contain a Unicode character map.\n"
1104 "Maybe you haven't set the %1 checkbox?")
1105 .arg(QUOTE_STRING_LITERAL(Tr("Symbol Font"))),
1108 else if (error
== TA_Err_Missing_Symbol_CMap
)
1109 QMessageBox::warning(
1112 Tr("The input font does neither contain a symbol"
1113 " nor a character map."),
1116 else if (error
== TA_Err_Missing_Glyph
)
1117 QMessageBox::warning(
1120 Tr("No glyph for a standard character"
1121 " to derive standard width and height.\n"
1122 "Please check the documentation for a list of"
1123 " script-specific standard characters.\n"
1125 "Set the %1 checkbox if you want to circumvent this test.")
1126 .arg(QUOTE_STRING_LITERAL(Tr("Symbol Font"))),
1129 else if (error
>= 0x200 && error
< 0x300)
1130 QMessageBox::warning(
1133 QString::fromLocal8Bit("%1:%2:%3: %4 (0x%5)<br>"
1136 .arg(data
->control_name
)
1138 .arg(int(errpos
- errline
+ 1))
1140 .arg(error
, 2, 16, QLatin1Char('0'))
1142 .arg('^', int(errpos
- errline
+ 1))
1143 .replace(" ", " "),
1146 else if (error
>= 0x300 && error
< 0x400)
1147 QMessageBox::warning(
1150 Tr("Error code 0x%1 while loading blue zone reference file:\n")
1151 .arg(error
- 0x300, 2, 16, QLatin1Char('0'))
1152 + QString::fromLocal8Bit(error_string
),
1156 QMessageBox::warning(
1159 Tr("Error code 0x%1 while autohinting font:\n")
1160 .arg(error
, 2, 16, QLatin1Char('0'))
1161 + QString::fromLocal8Bit(error_string
),
1165 if (QFile::exists(data
->output_name
)
1166 && remove(qPrintable(data
->output_name
)))
1168 const int buf_len
= 1024;
1171 strerror_r(errno
, buf
, buf_len
);
1172 QMessageBox::warning(
1175 Tr("The following error occurred while removing output file %1:\n")
1176 .arg(QUOTE_STRING(QDir::toNativeSeparators(data
->output_name
)))
1177 + QString::fromLocal8Bit(buf
),
1191 if (check
== CheckLater
)
1197 QString input_name
= QDir::fromNativeSeparators(input_line
->text());
1198 QString output_name
= QDir::fromNativeSeparators(output_line
->text());
1199 QString control_name
= QDir::fromNativeSeparators(control_line
->text());
1200 QString reference_name
= QDir::fromNativeSeparators(reference_line
->text());
1201 if (!check_filenames(input_name
, output_name
, control_name
, reference_name
))
1207 // we need C file descriptors for communication with TTF_autohint
1214 if (!open_files(input_name
, &input
,
1215 output_name
, &output
,
1216 control_name
, &control
,
1217 reference_name
, &reference
))
1223 QProgressDialog dialog
;
1224 dialog
.setCancelButtonText(tr("Cancel"));
1225 dialog
.setMinimumDuration(1000);
1226 dialog
.setWindowModality(Qt::WindowModal
);
1228 TA_Info_Func info_func
= info
;
1229 TA_Info_Post_Func info_post_func
= info_post
;
1230 GUI_Progress_Data gui_progress_data
= {-1, true, &dialog
};
1231 GUI_Error_Data gui_error_data
= {this, locale
,
1232 output_name
, control_name
, reference_name
,
1233 &ignore_restrictions
, false};
1235 fileinfo_input_file
.setFile(input_name
);
1236 fileinfo_control_file
.setFile(control_name
);
1237 fileinfo_reference_file
.setFile(reference_name
);
1239 // prepare C strings
1240 QByteArray ctrl_name
= fileinfo_control_file
.fileName().toLocal8Bit();
1241 QByteArray ref_name
= fileinfo_reference_file
.fileName().toLocal8Bit();
1242 QByteArray except_str
= x_height_snapping_exceptions_string
.toLocal8Bit();
1243 QByteArray fam_suff
= family_suffix_line
->text().toLocal8Bit();
1245 Info_Data info_data
;
1247 info_data
.info_string
= NULL
; // must be deallocated after use
1248 info_data
.info_string_wide
= NULL
; // must be deallocated after use
1249 info_data
.info_string_len
= 0;
1250 info_data
.info_string_wide_len
= 0;
1252 info_data
.control_name
= ctrl_name
.isEmpty() ? NULL
1253 : ctrl_name
.constData();
1254 info_data
.reference_name
= ref_name
.isEmpty() ? NULL
1255 : ref_name
.constData();
1256 info_data
.reference_index
= ref_idx_box
->value();
1258 info_data
.hinting_range_min
= min_box
->value();
1259 info_data
.hinting_range_max
= max_box
->value();
1260 info_data
.hinting_limit
= no_limit_box
->isChecked()
1262 : limit_box
->value();
1264 info_data
.gray_strong_stem_width
= gray_box
->isChecked();
1265 info_data
.gdi_cleartype_strong_stem_width
= gdi_box
->isChecked();
1266 info_data
.dw_cleartype_strong_stem_width
= dw_box
->isChecked();
1268 info_data
.increase_x_height
= no_x_increase_box
->isChecked()
1270 : x_increase_box
->value();
1271 info_data
.x_height_snapping_exceptions_string
= except_str
.constData();
1273 info_data
.family_suffix
= fam_suff
.constData();
1274 info_data
.family_data_head
= NULL
;
1276 info_data
.fallback_stem_width
= default_stem_width_box
->isChecked()
1278 : stem_width_box
->value();
1280 info_data
.windows_compatibility
= wincomp_box
->isChecked();
1281 info_data
.adjust_subglyphs
= adjust_box
->isChecked();
1282 info_data
.hint_composites
= hint_box
->isChecked();
1283 info_data
.symbol
= symbol_box
->isChecked();
1284 info_data
.fallback_scaling
= fallback_hint_or_scale_box
->currentIndex();
1285 info_data
.no_info
= info_box
->currentIndex() == 0;
1286 info_data
.detailed_info
= info_box
->currentIndex() == 2;
1287 info_data
.dehint
= dehint_box
->isChecked();
1288 info_data
.TTFA_info
= TTFA_box
->isChecked();
1290 strncpy(info_data
.default_script
,
1291 script_names
[default_box
->currentIndex()].tag
,
1292 sizeof (info_data
.default_script
));
1293 strncpy(info_data
.fallback_script
,
1294 script_names
[fallback_box
->currentIndex()].tag
,
1295 sizeof (info_data
.fallback_script
));
1297 if (info_box
->currentIndex())
1299 int ret
= build_version_string(&info_data
);
1301 QMessageBox::information(
1304 tr("Can't allocate memory for <b>TTFautohint</b> options string"
1305 " in <i>name</i> table."),
1309 QMessageBox::information(
1312 tr("<b>TTFautohint</b> options string"
1313 " in <i>name</i> table too long."),
1318 if (!*info_data
.family_suffix
)
1319 info_post_func
= NULL
;
1321 if (info_data
.symbol
1322 && info_data
.fallback_stem_width
1323 && info_data
.fallback_scaling
)
1324 QMessageBox::information(
1327 tr("Setting a fallback stem width for a symbol font"
1328 " with fallback scaling only has no effect."),
1332 datetime_input_file
= fileinfo_input_file
.lastModified();
1333 datetime_control_file
= fileinfo_control_file
.lastModified();
1334 datetime_reference_file
= fileinfo_reference_file
.lastModified();
1336 QByteArray snapping_string
= snapping_line
->text().toLocal8Bit();
1339 TTF_autohint("in-file, out-file, control-file, reference-file,"
1340 "reference-index, reference-name,"
1341 "hinting-range-min, hinting-range-max,"
1343 "gray-strong-stem-width,"
1344 "gdi-cleartype-strong-stem-width,"
1345 "dw-cleartype-strong-stem-width,"
1346 "progress-callback, progress-callback-data,"
1347 "error-callback, error-callback-data,"
1348 "info-callback, info-post-callback, info-callback-data,"
1349 "ignore-restrictions,"
1350 "windows-compatibility,"
1353 "increase-x-height,"
1354 "x-height-snapping-exceptions, fallback-stem-width,"
1356 "fallback-script, fallback-scaling,"
1357 "symbol, dehint, TTFA-info",
1358 input
, output
, control
, reference
,
1359 info_data
.reference_index
, info_data
.reference_name
,
1360 info_data
.hinting_range_min
, info_data
.hinting_range_max
,
1361 info_data
.hinting_limit
,
1362 info_data
.gray_strong_stem_width
,
1363 info_data
.gdi_cleartype_strong_stem_width
,
1364 info_data
.dw_cleartype_strong_stem_width
,
1365 gui_progress
, &gui_progress_data
,
1366 gui_error
, &gui_error_data
,
1367 info_func
, info_post_func
, &info_data
,
1368 ignore_restrictions
,
1369 info_data
.windows_compatibility
,
1370 info_data
.adjust_subglyphs
,
1371 info_data
.hint_composites
,
1372 info_data
.increase_x_height
,
1373 snapping_string
.constData(), info_data
.fallback_stem_width
,
1374 info_data
.default_script
,
1375 info_data
.fallback_script
, info_data
.fallback_scaling
,
1376 info_data
.symbol
, info_data
.dehint
, info_data
.TTFA_info
);
1378 if (info_box
->currentIndex())
1380 free(info_data
.info_string
);
1381 free(info_data
.info_string_wide
);
1393 // retry if there is a user request to do so (handled in `gui_error')
1394 if (gui_error_data
.retry
)
1401 statusBar()->showMessage(tr("Auto-hinting finished")
1403 + QDateTime::currentDateTime()
1404 .toString(Qt::TextDate
)
1407 // we have successfully processed a file;
1408 // start file watching now if requested
1409 if (watch_box
->isChecked())
1413 // Qt's file watcher doesn't handle symlinks;
1414 // we thus fall back to polling
1415 if (fileinfo_input_file
.isSymLink()
1416 || fileinfo_control_file
.isSymLink()
1417 || fileinfo_reference_file
.isSymLink())
1421 file_watcher
->addPath(input_name
);
1422 file_watcher
->addPath(control_name
);
1423 file_watcher
->addPath(reference_name
);
1430 // XXX distances are specified in pixels,
1431 // making the layout dependent on the output device resolution
1433 Main_GUI::create_layout(bool horizontal_layout
)
1438 QCompleter
* completer
= new QCompleter(this);
1439 QFileSystemModel
* model
= new QFileSystemModel(completer
);
1440 model
->setRootPath(QDir::rootPath());
1441 completer
->setModel(model
);
1443 input_label
= new QLabel(tr("&Input Font:"));
1444 input_line
= new Drag_Drop_Line_Edit(DRAG_DROP_TRUETYPE
);
1445 input_button
= new QPushButton(tr("Browse..."));
1446 input_label
->setBuddy(input_line
);
1447 // enforce rich text to get nice word wrapping
1448 input_label
->setToolTip(
1449 tr("<b></b>The input file, either a TrueType font (TTF),"
1450 " TrueType collection (TTC), or a TrueType-based OpenType font."));
1451 input_line
->setCompleter(completer
);
1453 output_label
= new QLabel(tr("&Output Font:"));
1454 output_line
= new Drag_Drop_Line_Edit(DRAG_DROP_TRUETYPE
);
1455 output_button
= new QPushButton(tr("Browse..."));
1456 output_label
->setBuddy(output_line
);
1457 output_label
->setToolTip(
1458 tr("<b></b>The output file, which will be essentially identical"
1459 " to the input font but will contain new, generated hints."));
1460 output_line
->setCompleter(completer
);
1462 control_label
= new QLabel(tr("Control Instructions Fil&e:"));
1463 control_line
= new Drag_Drop_Line_Edit(DRAG_DROP_ANY
);
1464 control_button
= new QPushButton(tr("Browse..."));
1465 control_label
->setBuddy(control_line
);
1466 // we use the non-breaking hyphen U+2011 (‑) where necessary
1467 QString tooltip_string
=
1468 tr("<p>An optional control instructions file to tweak hinting"
1469 " and to override glyph assignments to styles."
1470 " This text file contains entries"
1471 " of one of the following syntax forms"
1472 " (with brackets indicating optional elements).<br>"
1475 " [ <i>subfont‑idx</i> ]"
1476 " <i>script</i>"
1477 " <i>feature</i>"
1478 " <tt>@</tt> <i>glyph‑ids</i><br>"
1480 " [ <i>subfont‑idx</i> ]"
1481 " <i>glyph‑id</i>"
1482 " <tt>left</tt> | <tt>right</tt> <i>points</i>"
1483 " [ <tt>(</tt><i>left‑offset</i><tt>,"
1484 "</tt><i>right‑offset</i><tt>)</tt> ]<br>"
1486 " [ <i>subfont‑idx</i> ]"
1487 " <i>glyph‑id</i>"
1488 " <tt>nodir</tt> <i>points</i><br>"
1490 " [ <i>subfont‑idx</i> ]"
1491 " <i>glyph‑id</i>"
1492 " <tt>touch</tt> | <tt>point</tt> <i>points</i>"
1493 " [ <tt>xshift</tt> <i>shift</i> ]"
1494 " [ <tt>yshift</tt> <i>shift</i> ]"
1495 " <tt>@</tt> <i>ppems</i><br>"
1498 "<i>subfont‑idx</i> gives the subfont index in a TTC,"
1499 " <i>glyph‑id</i> is a glyph name or index.<br>"
1502 "<i>script</i> and <i>feature</i> are four-letter tags"
1503 " that define a style the <i>glyph‑ids</i> are assigned to."
1504 " <i>glyph‑ids</i> is a comma-separated list of"
1505 " <i>glyph‑id</i> values and value ranges.<br>");
1507 tooltip_string
+= tr("Possible values for <i>script</i> are ");
1508 const Tag_Names
* sn
= script_names
;
1511 tooltip_string
+= QString::fromLocal8Bit("<tt>%1</tt> (%2)")
1513 .arg(sn
->description
);
1516 tooltip_string
+= ", ";
1519 tooltip_string
+= ".<br>";
1524 tooltip_string
+= tr("Possible values for <i>feature</i> are ");
1525 const Tag_Names
* fn
= feature_names
;
1528 tooltip_string
+= QString::fromLocal8Bit("<tt>%1</tt> (%2)")
1530 .arg(fn
->description
);
1533 tooltip_string
+= ", ";
1536 tooltip_string
+= ".<br>";
1541 tooltip_string
+= " <br>";
1544 tr("<tt>left</tt> (<tt>right</tt>) creates one-point segments"
1545 " with direction left (right), possibly having a width (in font units)"
1546 " given by <i>left‑offset</i> and <i>right‑offset</i>"
1547 " relative to the corresponding points.<br>"
1550 "<tt>nodir</tt> removes points from horizontal segments,"
1551 " making them <i>weak</i> points.<br>"
1554 "<tt>touch </tt> (<tt>point</tt>) defines delta exceptions"
1555 " to be applied before (after) the final"
1556 " <tt>IUP</tt> bytecode instructions."
1557 " <tt>touch</tt> also touches points, making them <i>strong</i>."
1558 " In ClearType mode, <tt>point</tt> and <tt>xshift</tt>"
1559 " have no effect.<br>"
1562 "x and y <i>shift</i> values are in the range [-1;1],"
1563 " rounded to multiples of 1/8px.<br>"
1565 "<i>points</i> and <i>ppems</i> are ranges for point indices"
1566 " and ppem values as with x height snapping exceptions.<br>"
1568 "Keywords <tt>left</tt>, <tt>right</tt>, <tt>nodir</tt>,"
1569 " <tt>point</tt>, <tt>touch</tt>, <tt>xshift</tt>, and"
1570 " <tt>yshift</tt> can be abbreviated as <tt>l</tt>, <tt>r</tt>,"
1571 " <tt>n</tt>, <tt>p</tt>, <tt>t</tt>, <tt>x</tt>, and <tt>y</tt>,"
1572 " respectively.<br>"
1574 "Control instruction entries are separated"
1575 " by character <tt>;</tt> or by a newline.<br>"
1577 "A trailing character <tt>\\</tt> continues the current line"
1578 " on the next line.<br>"
1580 "<tt>#</tt> starts a line comment, which gets ignored."
1581 " Empty lines are ignored, too.</p>"
1584 " <tt>cyrl sups @ one.sups-nine.sups, zero.sups</tt><br>"
1585 " <tt>Q left 38 (-70,20)</tt><br>"
1586 " <tt>Adieresis touch 3-6 yshift 0.25 @ 13</tt>");
1588 control_label
->setToolTip(tooltip_string
);
1589 control_line
->setCompleter(completer
);
1591 reference_label
= new QLabel(tr("Blue &Zone Reference Font:"));
1592 reference_line
= new Drag_Drop_Line_Edit(DRAG_DROP_TRUETYPE
);
1593 reference_button
= new QPushButton(tr("Browse..."));
1594 reference_label
->setBuddy(reference_line
);
1595 reference_label
->setToolTip(
1596 tr("<b></b>A reference font file"
1597 " from which all blue zone values are taken."));
1598 reference_line
->setCompleter(completer
);
1600 ref_idx_label
= new QLabel(tr("Reference Face Index:"));
1601 ref_idx_box
= new QSpinBox
;
1602 ref_idx_label
->setBuddy(ref_idx_box
);
1603 ref_idx_label
->setToolTip(
1604 tr("The face index of the blue zone reference font to be used"
1605 " in case it is a TrueType Collection (<tt>.ttc</tt>)."));
1606 ref_idx_box
->setKeyboardTracking(false);
1607 // the range maximum gets updated interactively
1608 // after a (more or less) valid reference font has been selected
1609 ref_idx_box
->setRange(0, 100);
1614 min_label
= new QLabel(tr("Hint Set Range Mi&nimum:"));
1615 min_box
= new QSpinBox
;
1616 min_label
->setBuddy(min_box
);
1617 min_label
->setToolTip(
1618 tr("The minimum PPEM value of the range for which"
1619 " <b>TTFautohint</b> computes <i>hint sets</i>."
1620 " A hint set for a given PPEM value hints this size optimally."
1621 " The larger the range, the more hint sets are considered,"
1622 " usually increasing the size of the bytecode.<br>"
1623 "Note that changing this range doesn't influence"
1624 " the <i>gasp</i> table:"
1625 " Hinting is enabled for all sizes."));
1626 min_box
->setKeyboardTracking(false);
1627 min_box
->setRange(2, 10000);
1629 max_label
= new QLabel(tr("Hint Set Range Ma&ximum:"));
1630 max_box
= new QSpinBox
;
1631 max_label
->setBuddy(max_box
);
1632 max_label
->setToolTip(
1633 tr("The maximum PPEM value of the range for which"
1634 " <b>TTFautohint</b> computes <i>hint sets</i>."
1635 " A hint set for a given PPEM value hints this size optimally."
1636 " The larger the range, the more hint sets are considered,"
1637 " usually increasing the size of the bytecode.<br>"
1638 "Note that changing this range doesn't influence"
1639 " the <i>gasp</i> table:"
1640 " Hinting is enabled for all sizes."));
1641 max_box
->setKeyboardTracking(false);
1642 max_box
->setRange(2, 10000);
1645 // OpenType default script
1647 default_label
= new QLabel(tr("Defa&ult Script:"));
1648 default_box
= new QComboBox
;
1649 default_label
->setBuddy(default_box
);
1650 default_label
->setToolTip(
1651 tr("This sets the default script for OpenType features:"
1652 " After applying all features that are handled specially"
1653 " (for example small caps or superscript glyphs),"
1654 " <b>TTFautohint</b> uses this value for the remaining features."
1656 "<p>In most cases, you don't want to change this value.</p>"));
1657 for (int i
= 0; script_names
[i
].tag
; i
++)
1659 // XXX: how to provide translations?
1660 default_box
->insertItem(i
,
1662 .arg(script_names
[i
].tag
)
1663 .arg(script_names
[i
].description
));
1667 // hinting and fallback controls
1669 fallback_label
= new QLabel(tr("Fallbac&k Script"));
1670 fallback_hint_or_scale_box
= new QComboBox
;
1671 fallback_box
= new QComboBox
;
1672 fallback_label
->setBuddy(fallback_hint_or_scale_box
);
1673 fallback_label
->setToolTip(
1674 tr("This sets the fallback script for glyphs"
1675 " that <b>TTFautohint</b> can't map to a script automatically."
1676 " Either hinting with the script's blue zone values"
1677 " or simple scaling with the script's scaling value"
1678 " can be selected."));
1679 fallback_hint_or_scale_box
->insertItem(fallback_do_scale
, tr("Scaling:"));
1680 fallback_hint_or_scale_box
->insertItem(fallback_do_hint
, tr("Hinting:"));
1681 for (int i
= 0; script_names
[i
].tag
; i
++)
1683 // XXX: how to provide translations?
1684 fallback_box
->insertItem(i
,
1686 .arg(script_names
[i
].tag
)
1687 .arg(script_names
[i
].description
));
1693 limit_label_text_with_key
= tr("Hinting &Limit:");
1694 limit_label_text
= tr("Hinting Limit:");
1695 limit_label
= new QLabel(limit_label_text_with_key
);
1696 limit_box
= new QSpinBox
;
1697 limit_label
->setBuddy(limit_box
);
1698 limit_label
->setToolTip(
1699 tr("Switch off hinting for PPEM values exceeding this limit."
1700 " Changing this value does not influence the size of the bytecode.<br>"
1701 "Note that <b>TTFautohint</b> handles this feature"
1702 " in the output font's bytecode and not in the <i>gasp</i> table."));
1703 limit_box
->setKeyboardTracking(false);
1704 limit_box
->setRange(2, 10000);
1706 no_limit_box_text_with_key
= tr("No Hinting &Limit");
1707 no_limit_box_text
= tr("No Hinting Limit");
1708 no_limit_box
= new QCheckBox(no_limit_box_text
);
1709 no_limit_box
->setToolTip(
1710 tr("If switched on, <b>TTFautohint</b> adds no hinting limit"
1711 " to the bytecode.<br>"
1712 "For testing only."));
1715 // x height increase limit
1717 x_increase_label_text_with_key
= tr("x Height In&crease Limit:");
1718 x_increase_label_text
= tr("x Height Increase Limit:");
1719 x_increase_label
= new QLabel(x_increase_label_text_with_key
);
1720 x_increase_box
= new QSpinBox
;
1721 x_increase_label
->setBuddy(x_increase_box
);
1722 x_increase_label
->setToolTip(
1723 tr("For PPEM values in the range 6 ≤ PPEM ≤ <i>n</i>,"
1724 " where <i>n</i> is the value selected by this spin box,"
1725 " round up the font's x height much more often than normally.<br>"
1726 "Use this if holes in letters like <i>e</i> get filled,"
1728 x_increase_box
->setKeyboardTracking(false);
1729 x_increase_box
->setRange(6, 10000);
1731 no_x_increase_box_text_with_key
= tr("No x Height In&crease");
1732 no_x_increase_box_text
= tr("No x Height Increase");
1733 no_x_increase_box
= new QCheckBox(no_x_increase_box_text
);
1734 no_x_increase_box
->setToolTip(
1735 tr("If switched on,"
1736 " <b>TTFautohint</b> does not increase the x height."));
1739 // x height snapping exceptions
1741 snapping_label
= new QLabel(tr("x Height Snapping Excep&tions:"));
1742 snapping_line
= new Tooltip_Line_Edit
;
1743 snapping_label
->setBuddy(snapping_line
);
1744 snapping_label
->setToolTip(
1745 tr("<p>A list of comma separated PPEM values or value ranges"
1746 " at which no x height snapping shall be applied"
1747 " (x height snapping usually slightly increases"
1748 " the size of all glyphs).</p>"
1751 " <tt>2, 3-5, 12-17</tt><br>"
1752 " <tt>-20, 40-</tt>"
1753 " (meaning PPEM ≤ 20 or PPEM ≥ 40)<br>"
1754 " <tt>-</tt> (meaning all possible PPEM values)"));
1759 family_suffix_label
= new QLabel(tr("Family Suffix&:"));
1760 family_suffix_line
= new Tooltip_Line_Edit
;
1761 family_suffix_label
->setBuddy(family_suffix_line
);
1762 family_suffix_label
->setToolTip(
1763 tr("A string that gets appended to the family name entries"
1764 " (name IDs 1, 4, 6, 16, and 21)"
1765 " in the font's <i>name</i> table.<br>"
1766 "Mainly for testing purposes, enabling the operating system"
1767 " to display fonts simultaneously that are hinted"
1768 " with different <b>TTFautohint</b> parameters."));
1771 // fallback stem width
1773 stem_width_label_text_with_key
= tr("Fallback &Stem Width:");
1774 stem_width_label_text
= tr("Fallback Stem Width:");
1775 stem_width_label
= new QLabel(stem_width_label_text_with_key
);
1776 stem_width_box
= new QSpinBox
;
1777 stem_width_label
->setBuddy(stem_width_box
);
1778 stem_width_label
->setToolTip(
1779 tr("Set horizontal stem width (in font units) for all scripts"
1780 " that lack proper standard characters in the font.<br>"
1781 "If not set, <b>TTFautohint</b> uses a hard-coded default value."));
1782 stem_width_box
->setKeyboardTracking(false);
1783 stem_width_box
->setRange(1, 10000);
1785 default_stem_width_box_text_with_key
= tr("Default Fallback &Stem Width");
1786 default_stem_width_box_text
= tr("Default Fallback Stem Width");
1787 default_stem_width_box
= new QCheckBox(default_stem_width_box_text
);
1788 default_stem_width_box
->setToolTip(
1789 tr("If switched on, <b>TTFautohint</b> uses a default value"
1790 " for the fallback stem width (50 font units at 2048 UPEM)."));
1795 wincomp_box
= new QCheckBox(tr("Windows Com&patibility"));
1796 wincomp_box
->setToolTip(
1797 tr("If switched on, add two artificial blue zones positioned at the"
1798 " <tt>usWinAscent</tt> and <tt>usWinDescent</tt> values"
1799 " (from the font's <i>OS/2</i> table)."
1800 " This option, usually in combination"
1801 " with value <tt>-</tt> (a single dash)"
1802 " for the <i>x Height Snapping Exceptions</i> option,"
1803 " should be used if those two <i>OS/2</i> values are tight,"
1804 " and you are experiencing clipping during rendering."));
1806 adjust_box
= new QCheckBox(tr("Ad&just Subglyphs"));
1807 adjust_box
->setToolTip(
1808 tr("If switched on, the original bytecode of the input font"
1809 " gets applied (at EM size, usually 2048ppem)"
1810 " to derive the glyph outlines for <b>TTFautohint</b>.<br>"
1811 "Use this option only if subglyphs"
1812 " are incorrectly scaled and shifted.<br>"
1813 "Note that the original bytecode will always be discarded."));
1815 hint_box
= new QCheckBox(tr("Hint Co&mposites")
1816 + " "); // make label wider
1817 hint_box
->setToolTip(
1818 tr("If switched on, <b>TTFautohint</b> hints composite glyphs"
1819 " as a whole, including subglyphs."
1820 " Otherwise, glyph components get hinted separately.<br>"
1821 "Deactivating this flag reduces the bytecode size enormously,"
1822 " however, it might yield worse results."));
1824 symbol_box
= new QCheckBox(tr("S&ymbol Font"));
1825 symbol_box
->setToolTip(
1826 tr("If switched on, <b>TTFautohint</b> accepts fonts"
1827 " that don't contain a single standard character"
1828 " for any of the supported scripts.<br>"
1829 "Use this for symbol or dingbat fonts, for example."));
1831 dehint_box
= new QCheckBox(tr("&Dehint"));
1832 dehint_box
->setToolTip(
1833 tr("If set, remove all hints from the font.<br>"
1834 "For testing only."));
1836 info_label
= new QLabel(tr("ttf&autohint Info:"));
1837 info_box
= new QComboBox
;
1838 info_label
->setBuddy(info_box
);
1839 info_label
->setToolTip(
1840 tr("Specify which information about <b>TTFautohint</b>"
1841 " and its calling parameters gets added to the version string(s)"
1842 " (name ID 5) in the <i>name</i> table.<br>"
1843 "If you want to archive control instruction information,"
1844 " use a <i>TTFA</i> table."));
1845 info_box
->insertItem(0, tr("None"));
1846 info_box
->insertItem(1, tr("Version"));
1847 info_box
->insertItem(2, tr("Version and Parameters"));
1849 TTFA_box
= new QCheckBox(tr("Add TTFA Info Ta&ble"));
1850 TTFA_box
->setToolTip(
1851 tr("If switched on, an SFNT table called <i>TTFA</i>"
1852 " gets added to the output font,"
1853 " holding a dump of all parameters."
1854 " In particular, it lists all control instructions."));
1857 // stem width and positioning
1859 stem_label
= new QLabel(tr("Stron&g Stem Width <br>"
1860 "and Positioning:"));
1861 stem_label
->setToolTip(
1862 tr("<b>TTFautohint</b> provides two different hinting algorithms"
1863 " that can be selected for various hinting modes."
1865 "<p><i>strong</i> (checkbox set):"
1866 " Position horizontal stems and snap stem widths"
1867 " to integer pixel values. While making the output look crisper,"
1868 " outlines become more distorted.</p>"
1870 "<p><i>smooth</i> (checkbox not set):"
1871 " Use discrete values for horizontal stems and stem widths."
1872 " This only slightly increases the contrast"
1873 " but avoids larger outline distortion.</p>"));
1875 gray_box
= new QCheckBox(tr("Grayscale"));
1876 gray_box
->setToolTip(
1877 tr("<b></b>Grayscale rendering, no ClearType activated."));
1878 stem_label
->setBuddy(gray_box
);
1880 gdi_box
= new QCheckBox(tr("GDI ClearType"));
1881 gdi_box
->setToolTip(
1882 tr("GDI ClearType rendering,"
1883 " introduced in 2000 for Windows XP.<br>"
1884 "The rasterizer version (as returned by the"
1885 " GETINFO bytecode instruction) is in the range"
1886 " 36 ≤ version < 38, and ClearType is enabled.<br>"
1887 "Along the vertical axis, this mode behaves like B/W rendering."));
1889 dw_box
= new QCheckBox(tr("DW ClearType"));
1891 tr("DirectWrite ClearType rendering,"
1892 " introduced in 2008 for Windows Vista.<br>"
1893 "The rasterizer version (as returned by the"
1894 " GETINFO bytecode instruction) is ≥ 38,"
1895 " ClearType is enabled, and subpixel positioning is enabled also.<br>"
1896 "Smooth rendering along the vertical axis."));
1901 watch_box
= new QCheckBox(tr("&Watch Input Files"));
1902 watch_box
->setToolTip(
1903 tr("If switched on, <b>TTFautohint</b> automatically re-runs"
1904 " the hinting process as soon as an input file"
1905 " (either the font, the reference font,"
1906 " or the control instructions file) is modified.<br>"
1907 "Pressing the %1 button starts watching.<br>"
1908 "If an error occurs, watching stops and must be restarted"
1909 " with the %1 button.")
1910 .arg(QUOTE_STRING_LITERAL(tr("Run"))));
1912 run_button
= new QPushButton(" "
1914 + " "); // make label wider
1916 if (horizontal_layout
)
1917 create_horizontal_layout();
1919 create_vertical_layout();
1923 // XXX distances are specified in pixels,
1924 // making the layout dependent on the output device resolution
1926 Main_GUI::create_vertical_layout()
1929 QGridLayout
* file_layout
= new QGridLayout
;
1931 file_layout
->addWidget(input_label
, 0, 0, Qt::AlignRight
);
1932 file_layout
->addWidget(input_line
, 0, 1);
1933 file_layout
->addWidget(input_button
, 0, 2);
1935 file_layout
->setRowStretch(1, 1);
1937 file_layout
->addWidget(output_label
, 2, 0, Qt::AlignRight
);
1938 file_layout
->addWidget(output_line
, 2, 1);
1939 file_layout
->addWidget(output_button
, 2, 2);
1941 file_layout
->setRowStretch(3, 1);
1943 file_layout
->addWidget(control_label
, 4, 0, Qt::AlignRight
);
1944 file_layout
->addWidget(control_line
, 4, 1);
1945 file_layout
->addWidget(control_button
, 4, 2);
1947 file_layout
->setRowStretch(5, 1);
1949 file_layout
->addWidget(reference_label
, 6, 0, Qt::AlignRight
);
1950 file_layout
->addWidget(reference_line
, 6, 1);
1951 file_layout
->addWidget(reference_button
, 6, 2);
1954 QGridLayout
* run_layout
= new QGridLayout
;
1956 run_layout
->addWidget(watch_box
, 0, 1);
1957 run_layout
->addWidget(run_button
, 0, 3, Qt::AlignRight
);
1958 run_layout
->setColumnStretch(0, 1);
1959 run_layout
->setColumnStretch(2, 2);
1964 QGridLayout
* gui_layout
= new QGridLayout
;
1965 QFrame
* hline
= new QFrame
;
1966 hline
->setFrameShape(QFrame::HLine
);
1967 int row
= 0; // this counter simplifies inserting new items
1969 gui_layout
->setRowMinimumHeight(row
, 10); // XXX urgh, pixels...
1970 gui_layout
->setRowStretch(row
++, 1);
1972 gui_layout
->addLayout(file_layout
, row
, 0, row
, -1);
1973 gui_layout
->setRowStretch(row
++, 1);
1975 gui_layout
->addWidget(hline
, row
, 0, row
, -1);
1976 gui_layout
->setRowStretch(row
++, 1);
1978 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1979 gui_layout
->setRowStretch(row
++, 1);
1981 gui_layout
->addWidget(min_label
, row
, 0, Qt::AlignRight
);
1982 gui_layout
->addWidget(min_box
, row
++, 1, Qt::AlignLeft
);
1983 gui_layout
->addWidget(max_label
, row
, 0, Qt::AlignRight
);
1984 gui_layout
->addWidget(max_box
, row
++, 1, Qt::AlignLeft
);
1986 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
1987 gui_layout
->setRowStretch(row
++, 1);
1989 gui_layout
->addWidget(default_label
, row
, 0, Qt::AlignRight
);
1990 gui_layout
->addWidget(default_box
, row
++, 1, Qt::AlignLeft
);
1992 QGridLayout
* fallback_layout
= new QGridLayout
;
1993 fallback_layout
->addWidget(fallback_label
, 0, 0, Qt::AlignRight
);
1994 fallback_layout
->addWidget(fallback_hint_or_scale_box
, 0, 1, Qt::AlignLeft
);
1996 gui_layout
->addLayout(fallback_layout
, row
++, 0, Qt::AlignRight
);
1997 gui_layout
->addWidget(fallback_box
, row
++, 1, Qt::AlignLeft
);
1999 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
2000 gui_layout
->setRowStretch(row
++, 1);
2002 gui_layout
->addWidget(limit_label
, row
, 0, Qt::AlignRight
);
2003 gui_layout
->addWidget(limit_box
, row
++, 1, Qt::AlignLeft
);
2004 gui_layout
->addWidget(no_limit_box
, row
++, 1);
2006 gui_layout
->addWidget(x_increase_label
, row
, 0, Qt::AlignRight
);
2007 gui_layout
->addWidget(x_increase_box
, row
++, 1, Qt::AlignLeft
);
2008 gui_layout
->addWidget(no_x_increase_box
, row
++, 1);
2010 gui_layout
->addWidget(snapping_label
, row
, 0, Qt::AlignRight
);
2011 gui_layout
->addWidget(snapping_line
, row
++, 1, Qt::AlignLeft
);
2013 gui_layout
->addWidget(stem_width_label
, row
, 0, Qt::AlignRight
);
2014 gui_layout
->addWidget(stem_width_box
, row
++, 1, Qt::AlignLeft
);
2015 gui_layout
->addWidget(default_stem_width_box
, row
++, 1);
2017 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
2018 gui_layout
->setRowStretch(row
++, 1);
2020 gui_layout
->addWidget(wincomp_box
, row
++, 1);
2021 gui_layout
->addWidget(adjust_box
, row
++, 1);
2022 gui_layout
->addWidget(hint_box
, row
++, 1);
2023 gui_layout
->addWidget(symbol_box
, row
++, 1);
2024 gui_layout
->addWidget(dehint_box
, row
++, 1);
2026 gui_layout
->addWidget(info_label
, row
, 0, Qt::AlignRight
);
2027 gui_layout
->addWidget(info_box
, row
++, 1, Qt::AlignLeft
);
2028 gui_layout
->addWidget(TTFA_box
, row
++, 1);
2029 gui_layout
->addWidget(family_suffix_label
, row
, 0, Qt::AlignRight
);
2030 gui_layout
->addWidget(family_suffix_line
, row
++, 1, Qt::AlignLeft
);
2031 gui_layout
->addWidget(ref_idx_label
, row
, 0, Qt::AlignRight
);
2032 gui_layout
->addWidget(ref_idx_box
, row
++, 1, Qt::AlignLeft
);
2034 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
2035 gui_layout
->setRowStretch(row
++, 1);
2037 gui_layout
->addWidget(stem_label
, row
, 0, Qt::AlignRight
| Qt::AlignBottom
);
2038 gui_layout
->addWidget(gray_box
, row
++, 1, Qt::AlignBottom
);
2039 gui_layout
->addWidget(gdi_box
, row
++, 1);
2040 gui_layout
->addWidget(dw_box
, row
++, 1);
2042 gui_layout
->setRowMinimumHeight(row
, 30); // XXX urgh, pixels...
2043 gui_layout
->setRowStretch(row
++, 1);
2045 gui_layout
->addLayout(run_layout
, row
, 0, row
, -1);
2047 // create dummy widget to register layout
2048 QWidget
* main_widget
= new QWidget
;
2049 main_widget
->setLayout(gui_layout
);
2050 setCentralWidget(main_widget
);
2051 setWindowTitle("TTFautohint");
2055 // XXX distances are specified in pixels,
2056 // making the layout dependent on the output device resolution
2058 Main_GUI::create_horizontal_layout()
2061 QGridLayout
* file_layout
= new QGridLayout
;
2063 file_layout
->addWidget(input_label
, 0, 0, Qt::AlignRight
);
2064 file_layout
->addWidget(input_line
, 0, 1);
2065 file_layout
->addWidget(input_button
, 0, 2);
2067 file_layout
->setRowStretch(1, 1);
2069 file_layout
->addWidget(output_label
, 2, 0, Qt::AlignRight
);
2070 file_layout
->addWidget(output_line
, 2, 1);
2071 file_layout
->addWidget(output_button
, 2, 2);
2073 file_layout
->setRowStretch(3, 1);
2075 file_layout
->addWidget(control_label
, 4, 0, Qt::AlignRight
);
2076 file_layout
->addWidget(control_line
, 4, 1);
2077 file_layout
->addWidget(control_button
, 4, 2);
2079 file_layout
->setRowStretch(5, 1);
2081 file_layout
->addWidget(reference_label
, 6, 0, Qt::AlignRight
);
2082 file_layout
->addWidget(reference_line
, 6, 1);
2083 file_layout
->addWidget(reference_button
, 6, 2);
2086 QGridLayout
* run_layout
= new QGridLayout
;
2088 run_layout
->addWidget(watch_box
, 0, 1);
2089 run_layout
->addWidget(run_button
, 0, 3, Qt::AlignRight
);
2090 run_layout
->setColumnStretch(0, 2);
2091 run_layout
->setColumnStretch(2, 3);
2092 run_layout
->setColumnStretch(4, 1);
2097 QGridLayout
* gui_layout
= new QGridLayout
;
2098 QFrame
* hline
= new QFrame
;
2099 hline
->setFrameShape(QFrame::HLine
);
2100 int row
= 0; // this counter simplifies inserting new items
2103 gui_layout
->setColumnMinimumWidth(0, 10); // XXX urgh, pixels...
2104 gui_layout
->setColumnStretch(0, 1);
2107 gui_layout
->setRowMinimumHeight(row
, 10); // XXX urgh, pixels...
2108 gui_layout
->setRowStretch(row
++, 1);
2110 gui_layout
->addLayout(file_layout
, row
, 0, row
, -1);
2111 gui_layout
->setRowStretch(row
++, 1);
2113 gui_layout
->addWidget(hline
, row
, 0, row
, -1);
2114 gui_layout
->setRowStretch(row
++, 1);
2116 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
2117 gui_layout
->setRowStretch(row
++, 1);
2119 gui_layout
->addWidget(min_label
, row
, 1, Qt::AlignRight
);
2120 gui_layout
->addWidget(min_box
, row
++, 2, Qt::AlignLeft
);
2121 gui_layout
->addWidget(max_label
, row
, 1, Qt::AlignRight
);
2122 gui_layout
->addWidget(max_box
, row
++, 2, Qt::AlignLeft
);
2124 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
2125 gui_layout
->setRowStretch(row
++, 1);
2127 gui_layout
->addWidget(default_label
, row
, 1, Qt::AlignRight
);
2128 gui_layout
->addWidget(default_box
, row
++, 2, Qt::AlignLeft
);
2130 QGridLayout
* fallback_layout
= new QGridLayout
;
2131 fallback_layout
->addWidget(fallback_label
, 0, 0, Qt::AlignRight
);
2132 fallback_layout
->addWidget(fallback_hint_or_scale_box
, 0, 1, Qt::AlignLeft
);
2134 gui_layout
->addLayout(fallback_layout
, row
, 1, Qt::AlignRight
);
2135 gui_layout
->addWidget(fallback_box
, row
++, 2, Qt::AlignLeft
);
2137 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
2138 gui_layout
->setRowStretch(row
++, 1);
2140 gui_layout
->addWidget(limit_label
, row
, 1, Qt::AlignRight
);
2141 gui_layout
->addWidget(limit_box
, row
++, 2, Qt::AlignLeft
);
2142 gui_layout
->addWidget(no_limit_box
, row
++, 2);
2144 gui_layout
->addWidget(x_increase_label
, row
, 1, Qt::AlignRight
);
2145 gui_layout
->addWidget(x_increase_box
, row
++, 2, Qt::AlignLeft
);
2146 gui_layout
->addWidget(no_x_increase_box
, row
++, 2);
2148 gui_layout
->addWidget(snapping_label
, row
, 1, Qt::AlignRight
);
2149 gui_layout
->addWidget(snapping_line
, row
++, 2, Qt::AlignLeft
);
2151 gui_layout
->addWidget(stem_width_label
, row
, 1, Qt::AlignRight
);
2152 gui_layout
->addWidget(stem_width_box
, row
++, 2, Qt::AlignLeft
);
2153 gui_layout
->addWidget(default_stem_width_box
, row
++, 2);
2155 gui_layout
->setRowMinimumHeight(row
, 30); // XXX urgh, pixels...
2156 gui_layout
->setRowStretch(row
++, 1);
2158 gui_layout
->addLayout(run_layout
, row
, 0, row
, -1);
2161 gui_layout
->setColumnMinimumWidth(3, 20); // XXX urgh, pixels...
2162 gui_layout
->setColumnStretch(3, 1);
2166 gui_layout
->addWidget(wincomp_box
, row
++, 4);
2167 gui_layout
->addWidget(adjust_box
, row
++, 4);
2168 gui_layout
->addWidget(hint_box
, row
++, 4);
2169 gui_layout
->addWidget(symbol_box
, row
++, 4);
2170 gui_layout
->addWidget(dehint_box
, row
++, 4);
2172 gui_layout
->addWidget(info_label
, row
, 3, Qt::AlignRight
);
2173 gui_layout
->addWidget(info_box
, row
++, 4, Qt::AlignLeft
);
2174 gui_layout
->addWidget(TTFA_box
, row
++, 4);
2175 gui_layout
->addWidget(family_suffix_label
, row
, 3, Qt::AlignRight
);
2176 gui_layout
->addWidget(family_suffix_line
, row
++, 4, Qt::AlignLeft
);
2177 gui_layout
->addWidget(ref_idx_label
, row
, 3, Qt::AlignRight
);
2178 gui_layout
->addWidget(ref_idx_box
, row
++, 4, Qt::AlignLeft
);
2180 gui_layout
->setRowMinimumHeight(row
, 20); // XXX urgh, pixels...
2181 gui_layout
->setRowStretch(row
++, 1);
2183 gui_layout
->addWidget(stem_label
, row
, 3, Qt::AlignRight
| Qt::AlignBottom
);
2184 gui_layout
->addWidget(gray_box
, row
++, 4, Qt::AlignBottom
);
2185 gui_layout
->addWidget(gdi_box
, row
++, 4);
2186 gui_layout
->addWidget(dw_box
, row
++, 4);
2189 gui_layout
->setColumnMinimumWidth(5, 10); // XXX urgh, pixels...
2190 gui_layout
->setColumnStretch(5, 1);
2192 // create dummy widget to register layout
2193 QWidget
* main_widget
= new QWidget
;
2194 main_widget
->setLayout(gui_layout
);
2195 setCentralWidget(main_widget
);
2196 setWindowTitle("TTFautohint");
2201 Main_GUI::create_connections()
2203 connect(input_button
, SIGNAL(clicked()),
2204 SLOT(browse_input()));
2205 connect(output_button
, SIGNAL(clicked()),
2206 SLOT(browse_output()));
2207 connect(control_button
, SIGNAL(clicked()),
2208 SLOT(browse_control()));
2209 connect(reference_button
, SIGNAL(clicked()),
2210 SLOT(browse_reference()));
2212 connect(input_line
, SIGNAL(textChanged(QString
)),
2214 connect(output_line
, SIGNAL(textChanged(QString
)),
2217 connect(input_line
, SIGNAL(editingFinished()),
2218 SLOT(absolute_input()));
2219 connect(output_line
, SIGNAL(editingFinished()),
2220 SLOT(absolute_output()));
2221 connect(control_line
, SIGNAL(editingFinished()),
2222 SLOT(absolute_control()));
2223 connect(reference_line
, SIGNAL(editingFinished()),
2224 SLOT(absolute_reference()));
2226 connect(reference_line
, SIGNAL(editingFinished()),
2227 SLOT(set_ref_idx_box_max()));
2229 connect(min_box
, SIGNAL(valueChanged(int)),
2231 connect(max_box
, SIGNAL(valueChanged(int)),
2234 connect(limit_box
, SIGNAL(valueChanged(int)),
2235 SLOT(check_limit()));
2236 connect(no_limit_box
, SIGNAL(clicked()),
2237 SLOT(check_no_limit()));
2239 connect(no_x_increase_box
, SIGNAL(clicked()),
2240 SLOT(check_no_x_increase()));
2242 connect(snapping_line
, SIGNAL(editingFinished()),
2243 SLOT(check_number_set()));
2244 connect(snapping_line
, SIGNAL(textEdited(QString
)),
2245 SLOT(clear_status_bar()));
2247 connect(family_suffix_line
, SIGNAL(editingFinished()),
2248 SLOT(check_family_suffix()));
2249 connect(family_suffix_line
, SIGNAL(textEdited(QString
)),
2250 SLOT(clear_status_bar()));
2252 connect(default_stem_width_box
, SIGNAL(clicked()),
2253 SLOT(check_default_stem_width()));
2255 connect(dehint_box
, SIGNAL(clicked()),
2256 SLOT(check_dehint()));
2258 connect(file_watcher
, SIGNAL(fileChanged(const QString
&)),
2259 SLOT(start_timer()));
2260 connect(timer
, SIGNAL(timeout()),
2261 SLOT(watch_files()));
2263 connect(watch_box
, SIGNAL(clicked()),
2264 SLOT(check_watch()));
2266 connect(run_button
, SIGNAL(clicked()),
2272 Main_GUI::create_actions()
2274 exit_act
= new QAction(tr("E&xit"), this);
2275 exit_act
->setShortcuts(QKeySequence::Quit
);
2276 connect(exit_act
, SIGNAL(triggered()), SLOT(close()));
2278 about_act
= new QAction(tr("&About"), this);
2279 connect(about_act
, SIGNAL(triggered()), SLOT(about()));
2281 about_Qt_act
= new QAction(tr("About &Qt"), this);
2282 connect(about_Qt_act
, SIGNAL(triggered()), qApp
, SLOT(aboutQt()));
2287 Main_GUI::create_menus()
2289 file_menu
= menuBar()->addMenu(tr("&File"));
2290 file_menu
->addAction(exit_act
);
2292 help_menu
= menuBar()->addMenu(tr("&Help"));
2293 help_menu
->addAction(about_act
);
2294 help_menu
->addAction(about_Qt_act
);
2299 Main_GUI::create_status_bar()
2301 statusBar()->showMessage("");
2306 Main_GUI::set_defaults()
2308 min_box
->setValue(hinting_range_min
);
2309 max_box
->setValue(hinting_range_max
);
2311 default_box
->setCurrentIndex(default_script_idx
);
2312 fallback_hint_or_scale_box
->setCurrentIndex(fallback_scaling
);
2313 fallback_box
->setCurrentIndex(fallback_script_idx
);
2315 limit_box
->setValue(hinting_limit
? hinting_limit
: hinting_range_max
);
2316 // handle command line option `--hinting-limit=0'
2319 hinting_limit
= max_box
->value();
2320 no_limit_box
->setChecked(true);
2323 x_increase_box
->setValue(increase_x_height
? increase_x_height
2324 : TA_INCREASE_X_HEIGHT
);
2325 // handle command line option `--increase-x-height=0'
2326 if (!increase_x_height
)
2328 increase_x_height
= TA_INCREASE_X_HEIGHT
;
2329 no_x_increase_box
->setChecked(true);
2332 snapping_line
->setText(x_height_snapping_exceptions_string
);
2333 family_suffix_line
->setText(family_suffix
);
2335 if (fallback_stem_width
)
2336 stem_width_box
->setValue(fallback_stem_width
);
2339 stem_width_box
->setValue(50);
2340 default_stem_width_box
->setChecked(true);
2343 if (windows_compatibility
)
2344 wincomp_box
->setChecked(true);
2345 if (adjust_subglyphs
)
2346 adjust_box
->setChecked(true);
2347 if (hint_composites
)
2348 hint_box
->setChecked(true);
2350 symbol_box
->setChecked(true);
2352 dehint_box
->setChecked(true);
2354 info_box
->setCurrentIndex(0);
2355 else if (detailed_info
)
2356 info_box
->setCurrentIndex(2);
2358 info_box
->setCurrentIndex(1);
2360 TTFA_box
->setChecked(true);
2362 if (gray_strong_stem_width
)
2363 gray_box
->setChecked(true);
2364 if (gdi_cleartype_strong_stem_width
)
2365 gdi_box
->setChecked(true);
2366 if (dw_cleartype_strong_stem_width
)
2367 dw_box
->setChecked(true);
2369 run_button
->setEnabled(false);
2376 check_no_x_increase();
2381 // do this last since it disables almost everything
2387 Main_GUI::read_settings()
2390 // QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
2391 // QSize size = settings.value("size", QSize(400, 400)).toSize();
2398 Main_GUI::write_settings()
2401 // settings.setValue("pos", pos());
2402 // settings.setValue("size", size());
2405 // end of maingui.cpp