freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype-demos][gsoc-2022-chariri-3] 2 commits: [ftinspec


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][gsoc-2022-chariri-3] 2 commits: [ftinspect] Fix the columns width in Comparator View.
Date: Sat, 06 Aug 2022 16:04:36 +0000

Charlie Jiang pushed to branch gsoc-2022-chariri-3 at FreeType / FreeType Demo Programs

Commits:

  • 5df43bdb
    by Charlie Jiang at 2022-08-06T23:50:28+08:00
    [ftinspect] Fix the columns width in Comparator View.
    
    In comparator view, we demand that all columns have exactly same size.
    However, when the parent width can't be equally divided, there will be
    slight different between columns' widths. This commit fixes this.
    
    * src/ftinspect/panels/comparator.cpp, src/ftinspect/panels/comparator.hpp:
      Add `forceEqualWidths` to force the same width.
    
  • e1d7f226
    by Charlie Jiang at 2022-08-07T00:02:56+08:00
    [ftinspect] Disable creation of autofit-debug checkboxes when inactive.
    
    Now the checkboxes are complete not created when autofit debug is not
    available or the panel is in comparator mode.
    
    * src/ftinspect/panels/settingpanel.cpp,
      src/ftinspect/panels/settingpanel.hpp:
      Add `debugMode_`, and disable creation when `debugMode_ == false`.
    

4 changed files:

Changes:

  • src/ftinspect/panels/comparator.cpp
    ... ... @@ -74,6 +74,7 @@ void
    74 74
     ComperatorTab::resizeEvent(QResizeEvent* event)
    
    75 75
     {
    
    76 76
       QWidget::resizeEvent(event);
    
    77
    +  forceEqualWidths();
    
    77 78
       repaintGlyph();
    
    78 79
     }
    
    79 80
     
    
    ... ... @@ -139,6 +140,8 @@ ComperatorTab::createLayout()
    139 140
       layout_->setRowStretch(1, 2);
    
    140 141
     
    
    141 142
       setLayout(layout_);
    
    143
    +
    
    144
    +  forceEqualWidths();
    
    142 145
     }
    
    143 146
     
    
    144 147
     
    
    ... ... @@ -181,6 +184,23 @@ ComperatorTab::setupCanvases()
    181 184
     }
    
    182 185
     
    
    183 186
     
    
    187
    +void
    
    188
    +ComperatorTab::forceEqualWidths()
    
    189
    +{
    
    190
    +  if (canvas_.empty())
    
    191
    +    return;
    
    192
    +
    
    193
    +  // We need to keep the columns strictly equally wide, so we need to compensate
    
    194
    +  // the remainders when the tab width can't be evenly divided.
    
    195
    +  // Since the canvases are contained within QFrames, we can safely set fixed
    
    196
    +  // widths to them without messying up with the QGridLayout layouting.
    
    197
    +  // Using the first canvas as the reference width.
    
    198
    +  auto w = canvas_[0]->size().width();
    
    199
    +  for (int i = 1; static_cast<unsigned>(i) < canvas_.size(); ++i)
    
    200
    +    canvas_[i]->setFixedWidth(w);
    
    201
    +}
    
    202
    +
    
    203
    +
    
    184 204
     void
    
    185 205
     ComperatorTab::reloadStringAndRepaint()
    
    186 206
     {
    

  • src/ftinspect/panels/comparator.hpp
    ... ... @@ -60,6 +60,7 @@ private:
    60 60
       void createLayout();
    
    61 61
       void createConnections();
    
    62 62
       void setupCanvases();
    
    63
    +  void forceEqualWidths();
    
    63 64
     
    
    64 65
       void reloadStringAndRepaint();
    
    65 66
       void reloadGlyphsAndRepaint();
    

  • src/ftinspect/panels/settingpanel.cpp
    ... ... @@ -6,6 +6,9 @@
    6 6
     
    
    7 7
     #include "../uihelper.hpp"
    
    8 8
     
    
    9
    +// for `FT_DEBUG_AUTOFIT`
    
    10
    +#include <freetype/config/ftoption.h>
    
    11
    +
    
    9 12
     SettingPanel::SettingPanel(QWidget* parent,
    
    10 13
                                Engine* engine,
    
    11 14
                                bool comparatorMode)
    
    ... ... @@ -13,6 +16,11 @@ SettingPanel::SettingPanel(QWidget* parent,
    13 16
       engine_(engine),
    
    14 17
       comparatorMode_(comparatorMode)
    
    15 18
     {
    
    19
    +#ifdef FT_DEBUG_AUTOFIT
    
    20
    +  debugMode_ = !comparatorMode_;
    
    21
    +#else
    
    22
    +  debugMode_ = false;
    
    23
    +#endif
    
    16 24
       createLayout();
    
    17 25
       setDefaults();
    
    18 26
       createConnections();
    
    ... ... @@ -83,10 +91,13 @@ SettingPanel::onFontChanged()
    83 91
         hintingModeComboBox_->setEnabled(false);
    
    84 92
     
    
    85 93
         autoHintingCheckBox_->setEnabled(false);
    
    86
    -    horizontalHintingCheckBox_->setEnabled(false);
    
    87
    -    verticalHintingCheckBox_->setEnabled(false);
    
    88
    -    blueZoneHintingCheckBox_->setEnabled(false);
    
    89
    -    segmentDrawingCheckBox_->setEnabled(false);
    
    94
    +    if (debugMode_)
    
    95
    +    {
    
    96
    +      horizontalHintingCheckBox_->setEnabled(false);
    
    97
    +      verticalHintingCheckBox_->setEnabled(false);
    
    98
    +      blueZoneHintingCheckBox_->setEnabled(false);
    
    99
    +      segmentDrawingCheckBox_->setEnabled(false);
    
    100
    +    }
    
    90 101
     
    
    91 102
         antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
    
    92 103
         if (antiAliasingComboBox_->currentIndex()
    
    ... ... @@ -188,10 +199,13 @@ SettingPanel::checkAutoHinting()
    188 199
         hintingModeLabel_->setEnabled(false);
    
    189 200
         hintingModeComboBox_->setEnabled(false);
    
    190 201
     
    
    191
    -    horizontalHintingCheckBox_->setEnabled(true);
    
    192
    -    verticalHintingCheckBox_->setEnabled(true);
    
    193
    -    blueZoneHintingCheckBox_->setEnabled(true);
    
    194
    -    segmentDrawingCheckBox_->setEnabled(true);
    
    202
    +    if (debugMode_)
    
    203
    +    {
    
    204
    +      horizontalHintingCheckBox_->setEnabled(true);
    
    205
    +      verticalHintingCheckBox_->setEnabled(true);
    
    206
    +      blueZoneHintingCheckBox_->setEnabled(true);
    
    207
    +      segmentDrawingCheckBox_->setEnabled(true);
    
    208
    +    }
    
    195 209
     
    
    196 210
         antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(true);
    
    197 211
       }
    
    ... ... @@ -204,10 +218,13 @@ SettingPanel::checkAutoHinting()
    204 218
           hintingModeComboBox_->setEnabled(true);
    
    205 219
         }
    
    206 220
     
    
    207
    -    horizontalHintingCheckBox_->setEnabled(false);
    
    208
    -    verticalHintingCheckBox_->setEnabled(false);
    
    209
    -    blueZoneHintingCheckBox_->setEnabled(false);
    
    210
    -    segmentDrawingCheckBox_->setEnabled(false);
    
    221
    +    if (debugMode_)
    
    222
    +    {
    
    223
    +      horizontalHintingCheckBox_->setEnabled(false);
    
    224
    +      verticalHintingCheckBox_->setEnabled(false);
    
    225
    +      blueZoneHintingCheckBox_->setEnabled(false);
    
    226
    +      segmentDrawingCheckBox_->setEnabled(false);
    
    227
    +    }
    
    211 228
     
    
    212 229
         antiAliasingComboBoxModel_->setLightAntiAliasingEnabled(false);
    
    213 230
     
    
    ... ... @@ -265,10 +282,14 @@ SettingPanel::syncSettings()
    265 282
         != AntiAliasingComboBoxModel::AntiAliasing_None);
    
    266 283
       engine_->setHinting(hintingCheckBox_->isChecked());
    
    267 284
       engine_->setAutoHinting(autoHintingCheckBox_->isChecked());
    
    268
    -  engine_->setHorizontalHinting(horizontalHintingCheckBox_->isChecked());
    
    269
    -  engine_->setVerticalHinting(verticalHintingCheckBox_->isChecked());
    
    270
    -  engine_->setBlueZoneHinting(blueZoneHintingCheckBox_->isChecked());
    
    271
    -  engine_->setShowSegments(segmentDrawingCheckBox_->isChecked());
    
    285
    +
    
    286
    +  if (debugMode_)
    
    287
    +  {
    
    288
    +    engine_->setHorizontalHinting(horizontalHintingCheckBox_->isChecked());
    
    289
    +    engine_->setVerticalHinting(verticalHintingCheckBox_->isChecked());
    
    290
    +    engine_->setBlueZoneHinting(blueZoneHintingCheckBox_->isChecked());
    
    291
    +    engine_->setShowSegments(segmentDrawingCheckBox_->isChecked());
    
    292
    +  }
    
    272 293
     
    
    273 294
       engine_->setGamma(gammaSlider_->value());
    
    274 295
     
    
    ... ... @@ -306,7 +327,7 @@ SettingPanel::createConnections()
    306 327
       connect(hintingCheckBox_, &QCheckBox::clicked,
    
    307 328
               this, &SettingPanel::repaintNeeded);
    
    308 329
     
    
    309
    -  if (!comparatorMode_)
    
    330
    +  if (debugMode_)
    
    310 331
       {
    
    311 332
         connect(horizontalHintingCheckBox_, &QCheckBox::clicked,
    
    312 333
               this, &SettingPanel::repaintNeeded);
    
    ... ... @@ -349,10 +370,15 @@ SettingPanel::createLayout()
    349 370
       hintingModeLabel_->setBuddy(hintingModeComboBox_);
    
    350 371
     
    
    351 372
       autoHintingCheckBox_ = new QCheckBox(tr("Auto-Hinting"), this);
    
    352
    -  horizontalHintingCheckBox_ = new QCheckBox(tr("Horizontal Hinting"), this);
    
    353
    -  verticalHintingCheckBox_ = new QCheckBox(tr("Vertical Hinting"), this);
    
    354
    -  blueZoneHintingCheckBox_ = new QCheckBox(tr("Blue-Zone Hinting"), this);
    
    355
    -  segmentDrawingCheckBox_ = new QCheckBox(tr("Segment Drawing"), this);
    
    373
    +
    
    374
    +  if (debugMode_)
    
    375
    +  {
    
    376
    +    horizontalHintingCheckBox_ = new QCheckBox(tr("Horizontal Hinting"), this);
    
    377
    +    verticalHintingCheckBox_ = new QCheckBox(tr("Vertical Hinting"), this);
    
    378
    +    blueZoneHintingCheckBox_ = new QCheckBox(tr("Blue-Zone Hinting"), this);
    
    379
    +    segmentDrawingCheckBox_ = new QCheckBox(tr("Segment Drawing"), this);
    
    380
    +  }
    
    381
    +  
    
    356 382
       embeddedBitmapCheckBox_ = new QCheckBox(tr("Enable Embedded Bitmap"), this);
    
    357 383
       colorLayerCheckBox_ = new QCheckBox(tr("Enable Color Layer"), this);
    
    358 384
     
    
    ... ... @@ -409,12 +435,15 @@ SettingPanel::createLayout()
    409 435
       gammaSlider_->setTickInterval(5);
    
    410 436
       gammaLabel_->setBuddy(gammaSlider_);
    
    411 437
     
    
    412
    -  debugLayout_ = new QVBoxLayout;
    
    413
    -  debugLayout_->setContentsMargins(20, 0, 0, 0);
    
    414
    -  debugLayout_->addWidget(horizontalHintingCheckBox_);
    
    415
    -  debugLayout_->addWidget(verticalHintingCheckBox_);
    
    416
    -  debugLayout_->addWidget(blueZoneHintingCheckBox_);
    
    417
    -  debugLayout_->addWidget(segmentDrawingCheckBox_);
    
    438
    +  if (debugMode_)
    
    439
    +  {
    
    440
    +    debugLayout_ = new QVBoxLayout;
    
    441
    +    debugLayout_->setContentsMargins(20, 0, 0, 0);
    
    442
    +    debugLayout_->addWidget(horizontalHintingCheckBox_);
    
    443
    +    debugLayout_->addWidget(verticalHintingCheckBox_);
    
    444
    +    debugLayout_->addWidget(blueZoneHintingCheckBox_);
    
    445
    +    debugLayout_->addWidget(segmentDrawingCheckBox_);
    
    446
    +  }
    
    418 447
     
    
    419 448
       gammaLayout_ = new QHBoxLayout;
    
    420 449
       gammaLayout_->addWidget(gammaLabel_);
    
    ... ... @@ -427,7 +456,7 @@ SettingPanel::createLayout()
    427 456
                               hintingModeLabel_, hintingModeComboBox_);
    
    428 457
       gridLayout2ColAddWidget(generalTabLayout_, autoHintingCheckBox_);
    
    429 458
     
    
    430
    -  if (!comparatorMode_)
    
    459
    +  if (debugMode_)
    
    431 460
         gridLayout2ColAddLayout(generalTabLayout_, debugLayout_);
    
    432 461
     
    
    433 462
       if (!comparatorMode_)
    
    ... ... @@ -514,10 +543,14 @@ SettingPanel::setDefaults()
    514 543
       lcdFilterComboBox_->setCurrentIndex(
    
    515 544
         LCDFilterComboBoxModel::LCDFilter_Light);
    
    516 545
     
    
    517
    -  horizontalHintingCheckBox_->setChecked(true);
    
    518
    -  verticalHintingCheckBox_->setChecked(true);
    
    519
    -  blueZoneHintingCheckBox_->setChecked(true);
    
    520
    -  embeddedBitmapCheckBox_->setChecked(false);
    
    546
    +  if (debugMode_)
    
    547
    +  {
    
    548
    +    horizontalHintingCheckBox_->setChecked(true);
    
    549
    +    verticalHintingCheckBox_->setChecked(true);
    
    550
    +    blueZoneHintingCheckBox_->setChecked(true);
    
    551
    +    embeddedBitmapCheckBox_->setChecked(false);
    
    552
    +  }
    
    553
    +  
    
    521 554
       colorLayerCheckBox_->setChecked(true);
    
    522 555
     
    
    523 556
       if (comparatorMode_)
    

  • src/ftinspect/panels/settingpanel.hpp
    ... ... @@ -67,6 +67,7 @@ private:
    67 67
        * view).
    
    68 68
        */
    
    69 69
       bool comparatorMode_ = false;
    
    70
    +  bool debugMode_ = false;
    
    70 71
     
    
    71 72
       QTabWidget* tab_;
    
    72 73
     
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]