From 1c741ee9f841bfb15ca34340b8ad5f08ff2aa5fe Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 28 Jan 2013 10:37:42 +0100 Subject: [PATCH] Implement option `--dehint' in front-ends. --- doc/ttfautohint-1.pandoc | 7 ++++ frontend/info.cpp | 7 ++++ frontend/info.h | 1 + frontend/main.cpp | 29 +++++++++++-- frontend/maingui.cpp | 104 +++++++++++++++++++++++++++++++++++++++++++---- frontend/maingui.h | 11 ++++- 6 files changed, 145 insertions(+), 14 deletions(-) diff --git a/doc/ttfautohint-1.pandoc b/doc/ttfautohint-1.pandoc index 20285f0..e92588b 100644 --- a/doc/ttfautohint-1.pandoc +++ b/doc/ttfautohint-1.pandoc @@ -373,6 +373,13 @@ See ['Hint Sets'](#hint-sets) for a definition and explanation. or dingbat fonts or math glyphs, for example, which lack character 'o', at the expense of possibly poor hinting results at small sizes. +### Dehint + +`--dehint`, `-d` +: Strip off all hints without generating new hints. Consequently, all + other hinting options are ignored. This option is intended for testing + purposes. + ### Add ttfautohint Info `--no-info`, `-n` diff --git a/frontend/info.cpp b/frontend/info.cpp index c3fd04c..1d98db5 100644 --- a/frontend/info.cpp +++ b/frontend/info.cpp @@ -53,6 +53,12 @@ build_version_string(Info_Data* idata) d = (char*)idata->data; d += sprintf(d, TTFAUTOHINT_STRING " (v%s)", VERSION); + if (idata->dehint) + { + d += sprintf(d, " -d"); + goto Dehint_only; + } + d += sprintf(d, " -l %d", idata->hinting_range_min); d += sprintf(d, " -r %d", idata->hinting_range_max); d += sprintf(d, " -G %d", idata->hinting_limit); @@ -84,6 +90,7 @@ build_version_string(Info_Data* idata) if (idata->x_height_snapping_exceptions) d += sprintf(d, " -X \"\""); // fill in data later +Dehint_only: idata->data_len = d - (char*)idata->data; if (idata->x_height_snapping_exceptions) diff --git a/frontend/info.h b/frontend/info.h index c8e20d5..c6802db 100644 --- a/frontend/info.h +++ b/frontend/info.h @@ -42,6 +42,7 @@ typedef struct Info_Data_ bool hint_with_components; int latin_fallback; bool symbol; + bool dehint; } Info_Data; diff --git a/frontend/main.cpp b/frontend/main.cpp index 770af3a..fa24d9c 100644 --- a/frontend/main.cpp +++ b/frontend/main.cpp @@ -162,6 +162,7 @@ show_help(bool " --debug print debugging information\n" #endif " -c, --components hint glyph components separately\n" +" -d, --dehint remove all hints\n" " -f, --latin-fallback set fallback script to latin\n" " -G, --hinting-limit=N switch off hinting above this PPEM value\n" " (default: %d); value 0 means no limit\n" @@ -331,6 +332,8 @@ main(int argc, const char* x_height_snapping_exceptions_string = NULL; bool have_x_height_snapping_exceptions_string = false; + bool dehint = false; + #ifndef BUILD_GUI bool debug = false; @@ -368,6 +371,7 @@ main(int argc, #ifndef BUILD_GUI {"debug", no_argument, NULL, DEBUG_OPTION}, #endif + {"dehint", no_argument, NULL, 'd'}, {"hinting-limit", required_argument, NULL, 'G'}, {"hinting-range-max", required_argument, NULL, 'r'}, {"hinting-range-min", required_argument, NULL, 'l'}, @@ -413,7 +417,7 @@ main(int argc, }; int option_index; - int c = getopt_long_only(argc, argv, "cfG:hil:npr:stVvw:Wx:X:", + int c = getopt_long_only(argc, argv, "cdfG:hil:npr:stVvw:Wx:X:", long_options, &option_index); if (c == -1) break; @@ -424,6 +428,10 @@ main(int argc, hint_with_components = false; break; + case 'd': + dehint = true; + break; + case 'f': latin_fallback = 1; break; @@ -529,6 +537,16 @@ main(int argc, } } + if (dehint) + { + // -d makes ttfautohint ignore all other hinting options + have_hinting_range_min = false; + have_hinting_range_max = false; + have_hinting_limit = false; + have_increase_x_height = false; + have_x_height_snapping_exceptions_string = false; + } + if (!have_hinting_range_min) hinting_range_min = TA_HINTING_RANGE_MIN; if (!have_hinting_range_max) @@ -687,6 +705,8 @@ main(int argc, info_data.latin_fallback = latin_fallback; info_data.symbol = symbol; + info_data.dehint = dehint; + int ret = build_version_string(&info_data); if (ret == 1) fprintf(stderr, "Warning: Can't allocate memory" @@ -713,7 +733,7 @@ main(int argc, "pre-hinting, hint-with-components," "increase-x-height, x-height-snapping-exceptions," "fallback-script, symbol," - "debug", + "dehint, debug", in, out, hinting_range_min, hinting_range_max, hinting_limit, gray_strong_stem_width, gdi_cleartype_strong_stem_width, @@ -725,7 +745,7 @@ main(int argc, pre_hinting, hint_with_components, increase_x_height, x_height_snapping_exceptions_string, latin_fallback, symbol, - debug); + dehint, debug); if (!no_info) { @@ -803,7 +823,8 @@ main(int argc, dw_cleartype_strong_stem_width, increase_x_height, x_height_snapping_exceptions_string, ignore_restrictions, windows_compatibility, pre_hinting, - hint_with_components, no_info, latin_fallback, symbol); + hint_with_components, no_info, latin_fallback, symbol, + dehint); gui.show(); return app.exec(); diff --git a/frontend/maingui.cpp b/frontend/maingui.cpp index 677751b..8f4ab9d 100644 --- a/frontend/maingui.cpp +++ b/frontend/maingui.cpp @@ -51,7 +51,8 @@ Main_GUI::Main_GUI(int range_min, bool components, bool no, int fallback, - bool symb) + bool symb, + bool dh) : hinting_range_min(range_min), hinting_range_max(range_max), hinting_limit(limit), @@ -66,7 +67,8 @@ Main_GUI::Main_GUI(int range_min, hint_with_components(components), no_info(no), latin_fallback(fallback), - symbol(symb) + symbol(symb), + dehint(dh) { x_height_snapping_exceptions = NULL; @@ -196,6 +198,74 @@ Main_GUI::check_limit() void +Main_GUI::check_dehint() +{ + if (dehint_box->isChecked()) + { + min_label->setEnabled(false); + min_box->setEnabled(false); + + max_label->setEnabled(false); + max_box->setEnabled(false); + + fallback_label->setEnabled(false); + fallback_box->setEnabled(false); + + no_limit_box->setEnabled(false); + limit_label->setEnabled(false); + limit_box->setEnabled(false); + + no_increase_box->setEnabled(false); + increase_label->setEnabled(false); + increase_box->setEnabled(false); + + snapping_label->setEnabled(false); + snapping_line->setEnabled(false); + + wincomp_box->setEnabled(false); + pre_box->setEnabled(false); + hint_box->setEnabled(false); + symbol_box->setEnabled(false); + + stem_label->setEnabled(false); + gray_box->setEnabled(false); + gdi_box->setEnabled(false); + dw_box->setEnabled(false); + } + else + { + min_label->setEnabled(true); + min_box->setEnabled(true); + + max_label->setEnabled(true); + max_box->setEnabled(true); + + fallback_label->setEnabled(true); + fallback_box->setEnabled(true); + + no_limit_box->setEnabled(true); + check_no_limit(); + + no_increase_box->setEnabled(true); + check_no_increase(); + + snapping_label->setEnabled(true); + snapping_line->setEnabled(true); + + wincomp_box->setEnabled(true); + pre_box->setEnabled(true); + hint_box->setEnabled(true); + symbol_box->setEnabled(true); + + stem_label->setEnabled(true); + gray_box->setEnabled(true); + gdi_box->setEnabled(true); + dw_box->setEnabled(true); + } +} + + +void Main_GUI::check_no_limit() { if (no_limit_box->isChecked()) @@ -682,6 +752,7 @@ again: info_data.hint_with_components = hint_box->isChecked(); info_data.latin_fallback = fallback_box->currentIndex(); info_data.symbol = symbol_box->isChecked(); + info_data.dehint = dehint_box->isChecked(); if (info_box->isChecked()) { @@ -724,7 +795,8 @@ again: "hint-with-components," "increase-x-height," "x-height-snapping-exceptions," - "fallback-script, symbol", + "fallback-script, symbol," + "dehint", input, output, info_data.hinting_range_min, info_data.hinting_range_max, info_data.hinting_limit, @@ -740,7 +812,8 @@ again: info_data.hint_with_components, info_data.increase_x_height, snapping_string.constData(), - info_data.latin_fallback, info_data.symbol); + info_data.latin_fallback, info_data.symbol, + info_data.dehint); if (info_box->isChecked()) { @@ -809,7 +882,7 @@ Main_GUI::create_layout() // // minmax controls // - QLabel* min_label = new QLabel(tr("Hint Set Range Mi&nimum:")); + min_label = new QLabel(tr("Hint Set Range Mi&nimum:")); min_box = new QSpinBox; min_label->setBuddy(min_box); min_label->setToolTip( @@ -824,7 +897,7 @@ Main_GUI::create_layout() min_box->setKeyboardTracking(false); min_box->setRange(2, 10000); - QLabel* max_label = new QLabel(tr("Hint Set Range Ma&ximum:")); + max_label = new QLabel(tr("Hint Set Range Ma&ximum:")); max_box = new QSpinBox; max_label->setBuddy(max_box); max_label->setToolTip( @@ -842,7 +915,7 @@ Main_GUI::create_layout() // // hinting and fallback controls // - QLabel* fallback_label = new QLabel(tr("Fallback &Script:")); + fallback_label = new QLabel(tr("Fallback &Script:")); fallback_box = new QComboBox; fallback_label->setBuddy(fallback_box); fallback_label->setToolTip( @@ -892,7 +965,7 @@ Main_GUI::create_layout() // // x height snapping exceptions // - QLabel* snapping_label = new QLabel(tr("x Height Snapping Excep&tions:")); + snapping_label = new QLabel(tr("x Height Snapping Excep&tions:")); snapping_line = new Tooltip_Line_Edit; snapping_label->setBuddy(snapping_line); snapping_label->setToolTip( @@ -944,6 +1017,10 @@ Main_GUI::create_layout() "Use this for fonts which don't contain glyphs" " of a (supported) script.")); + dehint_box = new QCheckBox(tr("&Dehint"), this); + dehint_box->setToolTip( + tr("If set, remove all hints from the font.")); + info_box = new QCheckBox(tr("Add ttf&autohint Info"), this); info_box->setToolTip( tr("If switched on, information about TTFautohint" @@ -953,7 +1030,7 @@ Main_GUI::create_layout() // // stem width and positioning // - QLabel* stem_label = new QLabel(tr("Strong Stem &Width and Positioning:")); + stem_label = new QLabel(tr("Strong Stem &Width and Positioning:")); stem_label->setToolTip( tr("TTFautohint provides two different hinting algorithms" " which can be selected for various hinting modes." @@ -1048,6 +1125,7 @@ Main_GUI::create_layout() gui_layout->addWidget(pre_box, row++, 1); gui_layout->addWidget(hint_box, row++, 1); gui_layout->addWidget(symbol_box, row++, 1); + gui_layout->addWidget(dehint_box, row++, 1); gui_layout->addWidget(info_box, row++, 1); gui_layout->setRowMinimumHeight(row, 20); // XXX urgh, pixels... @@ -1107,6 +1185,9 @@ Main_GUI::create_connections() connect(snapping_line, SIGNAL(textEdited(QString)), this, SLOT(clear_status_bar())); + connect(dehint_box, SIGNAL(clicked()), this, + SLOT(check_dehint())); + connect(run_button, SIGNAL(clicked()), this, SLOT(run())); } @@ -1181,6 +1262,8 @@ Main_GUI::set_defaults() hint_box->setChecked(true); if (symbol) symbol_box->setChecked(true); + if (dehint) + dehint_box->setChecked(true); if (!no_info) info_box->setChecked(true); @@ -1200,6 +1283,9 @@ Main_GUI::set_defaults() check_no_limit(); check_no_increase(); check_number_set(); + + // do this last since it disables almost everything + check_dehint(); } diff --git a/frontend/maingui.h b/frontend/maingui.h index cbb5222..6baad45 100644 --- a/frontend/maingui.h +++ b/frontend/maingui.h @@ -48,7 +48,8 @@ public: bool, bool, bool, int, const char*, bool, bool, bool, - bool, bool, int, bool); + bool, bool, int, bool, + bool); ~Main_GUI(); protected: @@ -61,6 +62,7 @@ private slots: void check_min(); void check_max(); void check_limit(); + void check_dehint(); void check_no_limit(); void check_no_increase(); void absolute_input(); @@ -87,6 +89,7 @@ private: int no_info; int latin_fallback; int symbol; + int dehint; void create_layout(); @@ -111,13 +114,17 @@ private: Drag_Drop_Line_Edit* output_line; QPushButton* output_button; + QLabel* min_label; QSpinBox* min_box; + QLabel* max_label; QSpinBox* max_box; + QLabel* stem_label; QCheckBox* gray_box; QCheckBox* gdi_box; QCheckBox* dw_box; + QLabel* fallback_label; QComboBox* fallback_box; QLabel* limit_label; @@ -128,12 +135,14 @@ private: QSpinBox* increase_box; QCheckBox* no_increase_box; + QLabel* snapping_label; Tooltip_Line_Edit* snapping_line; QCheckBox* wincomp_box; QCheckBox* pre_box; QCheckBox* hint_box; QCheckBox* symbol_box; + QCheckBox* dehint_box; QCheckBox* info_box; QPushButton* run_button; -- 2.11.4.GIT