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] 4 commits: [ftinspec


From: Charlie Jiang (@cqjjjzr)
Subject: [Git][freetype/freetype-demos][gsoc-2022-chariri-3] 4 commits: [ftinspect] Support custom bg/fg color.
Date: Mon, 08 Aug 2022 13:11:54 +0000

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

Commits:

  • 2f96901b
    by Charlie Jiang at 2022-08-08T20:06:42+08:00
    [ftinspect] Support custom bg/fg color.
    
    No more fear for dark mode. Not supported for LCD rendering yet.
    
    * src/ftinspect/engine/engine.cpp, src/ftinspect/engine/engine.hpp:
      Add properties for background and foreground colors and use them to
      generate the color tables and render bitmaps.
    
    * src/ftinspect/panels/settingpanel.cpp,
      src/ftinspect/panels/settingpanel.hpp:
      Add buttons to set background and foreground color, and sync them to the
      engine.
    
    * src/ftinspect/panels/singular.cpp,
      src/ftinspect/rendering/glyphcontinuous.cpp: Add background filling.
    
  • 2fd3ff0f
    by Charlie Jiang at 2022-08-08T20:53:28+08:00
    [ftinspect] Support gamma for non-LCD rendering.
    
    * src/ftinspect/engine/engine.cpp, src/ftinspect/engine/engine.hpp:
      Add `calculateForegroundTable` function to calculate the blended color
      values with gamma correction considered. Gamma and color change will call
      this function.
    
    * src/ftinspect/panels/settingpanel.cpp,
      src/ftinspect/panels/settingpanel.hpp:
      Add proper updating and displaying of current gamma values.
    
    * src/ftinspect/panels/singular.cpp: Since we're generating solid pixels
      for bitmaps, we need to place the bitmap under the grid so the grid won't
      be covered.
    
    * src/ftinspect/rendering/graphicsdefault.cpp,
      src/ftinspect/rendering/graphicsdefault.hpp:
      Make the grid line semi-transparent so it looks better covering on the
      bitmap. Remove default color tables since we're generating them in the
      engine.
    
  • 683575bf
    by Charlie Jiang at 2022-08-08T21:04:00+08:00
    * src/ftinspect/panels/glyphdetails.cpp: Refactor layout.
    
    Use renderutils.
    
  • c3e1047c
    by Charlie Jiang at 2022-08-08T21:10:59+08:00
    * src/ftinspect/rendering/glyphbitmap.cpp: Fix border in glyph details pane.
    

10 changed files:

Changes:

  • src/ftinspect/engine/engine.cpp
    ... ... @@ -160,6 +160,9 @@ Engine::Engine()
    160 160
       }
    
    161 161
       
    
    162 162
       queryEngine();
    
    163
    +
    
    164
    +  setForeground(QColor(Qt::black).rgba());
    
    165
    +  setBackground(QColor(Qt::white).rgba());
    
    163 166
     }
    
    164 167
     
    
    165 168
     
    
    ... ... @@ -628,6 +631,17 @@ Engine::setSizeByPoint(double pointSize)
    628 631
     }
    
    629 632
     
    
    630 633
     
    
    634
    +void
    
    635
    +Engine::setGamma(double gamma)
    
    636
    +{
    
    637
    +  if (gamma_ != gamma)
    
    638
    +  {
    
    639
    +    gamma_ = gamma;
    
    640
    +    calculateForegroundTable();
    
    641
    +  }
    
    642
    +}
    
    643
    +
    
    644
    +
    
    631 645
     void
    
    632 646
     Engine::setLcdFilter(FT_LcdFilter filter)
    
    633 647
     {
    
    ... ... @@ -667,6 +681,28 @@ Engine::setTTInterpreterVersion(int version)
    667 681
     }
    
    668 682
     
    
    669 683
     
    
    684
    +void
    
    685
    +Engine::setForeground(QRgb foreground)
    
    686
    +{
    
    687
    +  if (foregroundTable_.size() != 256 || foreground != foregroundColor_)
    
    688
    +  {
    
    689
    +    foregroundColor_ = foreground;
    
    690
    +    calculateForegroundTable();
    
    691
    +  }
    
    692
    +}
    
    693
    +
    
    694
    +
    
    695
    +void
    
    696
    +Engine::setBackground(QRgb background)
    
    697
    +{
    
    698
    +  if (foregroundTable_.size() != 256 || background != backgroundColor_)
    
    699
    +  {
    
    700
    +    backgroundColor_ = background;
    
    701
    +    calculateForegroundTable();
    
    702
    +  }
    
    703
    +}
    
    704
    +
    
    705
    +
    
    670 706
     void
    
    671 707
     Engine::update()
    
    672 708
     {
    
    ... ... @@ -833,6 +869,44 @@ Engine::loadPaletteInfos()
    833 869
     }
    
    834 870
     
    
    835 871
     
    
    872
    +void
    
    873
    +Engine::calculateForegroundTable()
    
    874
    +{
    
    875
    +  foregroundTable_.resize(256);
    
    876
    +
    
    877
    +  // Yes I know this is horribly slow, but we're only calculating the table once
    
    878
    +  // and can use it for all rendering if the color and gamma isn't changing.
    
    879
    +
    
    880
    +  double br = pow(qRed(backgroundColor_) / 255.0, gamma_);
    
    881
    +  double bg = pow(qGreen(backgroundColor_) / 255.0, gamma_);
    
    882
    +  double bb = pow(qBlue(backgroundColor_) / 255.0, gamma_);
    
    883
    +  double invGamma = 1 / gamma_;
    
    884
    +
    
    885
    +  for (int i = 0; i <= 0xFF; i++)
    
    886
    +  {
    
    887
    +    double foreAlpha = i * qAlpha(foregroundColor_) / 255.0 / 255.0;
    
    888
    +    double backAlpha = 1 - foreAlpha;
    
    889
    +    double r = pow(qRed(foregroundColor_) / 255.0, gamma_);
    
    890
    +    double g = pow(qGreen(foregroundColor_) / 255.0, gamma_);
    
    891
    +    double b = pow(qBlue(foregroundColor_) / 255.0, gamma_);
    
    892
    +
    
    893
    +    r = br * backAlpha + r * foreAlpha;
    
    894
    +    g = bg * backAlpha + g * foreAlpha;
    
    895
    +    b = bb * backAlpha + b * foreAlpha;
    
    896
    +
    
    897
    +    r = pow(r, invGamma);
    
    898
    +    g = pow(g, invGamma);
    
    899
    +    b = pow(b, invGamma);
    
    900
    +
    
    901
    +    foregroundTable_[i]
    
    902
    +        = qRgba(static_cast<int>(r * 255), 
    
    903
    +                static_cast<int>(g * 255),
    
    904
    +                static_cast<int>(b * 255), 
    
    905
    +                255);
    
    906
    +  }
    
    907
    +}
    
    908
    +
    
    909
    +
    
    836 910
     void
    
    837 911
     convertLCDToARGB(FT_Bitmap& bitmap,
    
    838 912
                      QImage& image,
    
    ... ... @@ -912,9 +986,13 @@ Engine::convertBitmapToQImage(FT_Bitmap* src)
    912 986
                        bmap.pitch, 
    
    913 987
                        format);
    
    914 988
           if (bmap.pixel_mode == FT_PIXEL_MODE_GRAY)
    
    915
    -        image.setColorTable(GraphicsDefault::deafultInstance()->grayColorTable);
    
    989
    +        image.setColorTable(foregroundTable_);
    
    916 990
           else if (bmap.pixel_mode == FT_PIXEL_MODE_MONO)
    
    917
    -        image.setColorTable(GraphicsDefault::deafultInstance()->monoColorTable);
    
    991
    +      {
    
    992
    +        image.setColorCount(2);
    
    993
    +        image.setColor(0, static_cast<QRgb>(0)); // transparent
    
    994
    +        image.setColor(1, foregroundTable_[0xFF]);
    
    995
    +      }
    
    918 996
           result = new QImage(image.copy());
    
    919 997
           // Don't directly use `image` since we're destroying the image
    
    920 998
         }
    

  • src/ftinspect/engine/engine.hpp
    ... ... @@ -156,6 +156,9 @@ public:
    156 156
       bool embeddedBitmapEnabled() { return embeddedBitmap_; }
    
    157 157
       bool lcdUsingSubPixelPositioning() { return lcdSubPixelPositioning_; }
    
    158 158
     
    
    159
    +  QRgb foreground() { return foregroundColor_; }
    
    160
    +  QRgb background() { return backgroundColor_; }
    
    161
    +
    
    159 162
       //////// Setters (direct or indirect)
    
    160 163
     
    
    161 164
       void setDPI(int d) { dpi_ = d; }
    
    ... ... @@ -176,7 +179,7 @@ public:
    176 179
         doBlueZoneHinting_ = blueZoneHinting;
    
    177 180
       }
    
    178 181
       void setShowSegments(bool showSegments) { showSegments_ = showSegments; }
    
    179
    -  void setGamma(double gamma) { gamma_ = gamma; }
    
    182
    +  void setGamma(double gamma);
    
    180 183
       void setAntiAliasingTarget(int target) { antiAliasingTarget_ = target; }
    
    181 184
       void setRenderMode(int mode) { renderMode_ = mode; }
    
    182 185
       void setAntiAliasingEnabled(bool enabled) { antiAliasingEnabled_ = enabled; }
    
    ... ... @@ -192,6 +195,9 @@ public:
    192 195
       void setCFFHintingMode(int mode);
    
    193 196
       void setTTInterpreterVersion(int version);
    
    194 197
     
    
    198
    +  void setForeground(QRgb foreground);
    
    199
    +  void setBackground(QRgb background);
    
    200
    +
    
    195 201
       //////// Misc
    
    196 202
     
    
    197 203
       friend FT_Error faceRequester(FTC_FaceID,
    
    ... ... @@ -251,8 +257,14 @@ private:
    251 257
       double gamma_;
    
    252 258
       unsigned long loadFlags_;
    
    253 259
     
    
    260
    +  QRgb backgroundColor_;
    
    261
    +  QRgb foregroundColor_;
    
    262
    +  QRgb foregroundColorBlended_;
    
    263
    +  QVector<QRgb> foregroundTable_;
    
    264
    +
    
    254 265
       void queryEngine();
    
    255 266
       void loadPaletteInfos();
    
    267
    +  void calculateForegroundTable();
    
    256 268
     
    
    257 269
       // Safe to put the impl to the cpp.
    
    258 270
       template <class Func>
    

  • src/ftinspect/panels/glyphdetails.cpp
    ... ... @@ -130,42 +130,30 @@ GlyphDetails::createLayout()
    130 130
       unitLayout_->addWidget(pixelButton_);
    
    131 131
     
    
    132 132
       layout_ = new QGridLayout;
    
    133
    -  layout_->addLayout(unitLayout_, 0, 0, 1, 2);
    
    134
    -  layout_->addItem(new QSpacerItem(0, 18), 1, 0, 1, 2);
    
    133
    +  gridLayout2ColAddLayout(layout_, unitLayout_);
    
    134
    +  gridLayout2ColAddItem(layout_, new QSpacerItem(0, 18));
    
    135 135
     
    
    136
    -  layout_->addWidget(glyphIndexPromptLabel_, 2, 0);
    
    137
    -  layout_->addWidget(charCodePromptLabel_,   3, 0);
    
    138
    -  layout_->addWidget(glyphNamePromptLabel_,  4, 0);
    
    139
    -  layout_->addItem(new QSpacerItem(0, 18), 5, 0, 1, 2);
    
    136
    +  gridLayout2ColAddWidget(layout_, glyphIndexPromptLabel_, glyphIndexLabel_);
    
    137
    +  gridLayout2ColAddWidget(layout_, charCodePromptLabel_  , charCodeLabel_  );
    
    138
    +  gridLayout2ColAddWidget(layout_, glyphNamePromptLabel_ , glyphNameLabel_ );
    
    139
    +  gridLayout2ColAddItem(layout_, new QSpacerItem(0, 18));
    
    140 140
     
    
    141
    -  layout_->addWidget(bboxSizePromptLabel_,    6, 0);
    
    142
    -  layout_->addWidget(horiBearingPromptLabel_, 7, 0);
    
    143
    -  layout_->addWidget(horiAdvancePromptLabel_, 8, 0);
    
    144
    -  layout_->addWidget(vertBearingPromptLabel_, 9, 0);
    
    145
    -  layout_->addWidget(vertAdvancePromptLabel_, 10, 0);
    
    146
    -  layout_->addItem(new QSpacerItem(0, 18), 11, 0, 1, 2);
    
    141
    +  gridLayout2ColAddWidget(layout_, bboxSizePromptLabel_,    bboxSizeLabel_  );
    
    142
    +  gridLayout2ColAddWidget(layout_, horiBearingPromptLabel_, horiBearingLabel_);
    
    143
    +  gridLayout2ColAddWidget(layout_, horiAdvancePromptLabel_, horiAdvanceLabel_);
    
    144
    +  gridLayout2ColAddWidget(layout_, vertBearingPromptLabel_, vertBearingLabel_);
    
    145
    +  gridLayout2ColAddWidget(layout_, vertAdvancePromptLabel_, vertAdvanceLabel_);
    
    146
    +  gridLayout2ColAddItem(layout_, new QSpacerItem(0, 18));
    
    147 147
     
    
    148
    -  layout_->addWidget(inkSizePromptLabel_,      12, 0);
    
    149
    -  layout_->addWidget(bitmapOffsetPromptLabel_, 13, 0);
    
    148
    +  gridLayout2ColAddWidget(layout_, inkSizePromptLabel_, inkSizeLabel_);
    
    149
    +  gridLayout2ColAddWidget(layout_, bitmapOffsetPromptLabel_, 
    
    150
    +                                   bitmapOffsetLabel_);
    
    151
    +  gridLayout2ColAddItem(layout_, new QSpacerItem(0, 18));
    
    150 152
     
    
    151
    -  layout_->addWidget(glyphIndexLabel_, 2, 1);
    
    152
    -  layout_->addWidget(charCodeLabel_,   3, 1);
    
    153
    -  layout_->addWidget(glyphNameLabel_,  4, 1);
    
    154
    -
    
    155
    -  layout_->addWidget(bboxSizeLabel_,    6, 1);
    
    156
    -  layout_->addWidget(horiBearingLabel_, 7, 1);
    
    157
    -  layout_->addWidget(horiAdvanceLabel_, 8, 1);
    
    158
    -  layout_->addWidget(vertBearingLabel_, 9, 1);
    
    159
    -  layout_->addWidget(vertAdvanceLabel_, 10, 1);
    
    160
    -
    
    161
    -  layout_->addWidget(inkSizeLabel_,      12, 1);
    
    162
    -  layout_->addWidget(bitmapOffsetLabel_, 13, 1);
    
    163
    -  layout_->addItem(new QSpacerItem(0, 18), 14, 0, 1, 2);
    
    164
    -
    
    165
    -  layout_->addWidget(bitmapWidget_, 15, 0, 1, 2);
    
    153
    +  gridLayout2ColAddWidget(layout_, bitmapWidget_);
    
    166 154
     
    
    167 155
       layout_->setColumnStretch(1, 1);
    
    168
    -  layout_->setRowStretch(15, 1);
    
    156
    +  layout_->setRowStretch(layout_->rowCount() - 1, 1);
    
    169 157
     
    
    170 158
       setLayout(layout_);
    
    171 159
       setContentsMargins(12, 12, 12, 12);
    

  • src/ftinspect/panels/settingpanel.cpp
    ... ... @@ -154,6 +154,45 @@ SettingPanel::populatePalettes()
    154 154
     }
    
    155 155
     
    
    156 156
     
    
    157
    +void
    
    158
    +SettingPanel::openBackgroundPicker()
    
    159
    +{
    
    160
    +  auto result = QColorDialog::getColor(backgroundColor_, 
    
    161
    +                                       this,
    
    162
    +                                       tr("Background Color"));
    
    163
    +  if (result.isValid())
    
    164
    +  {
    
    165
    +    backgroundColor_ = result;
    
    166
    +    emit repaintNeeded();
    
    167
    +  }
    
    168
    +}
    
    169
    +
    
    170
    +
    
    171
    +void
    
    172
    +SettingPanel::openForegroundPicker()
    
    173
    +{
    
    174
    +  auto result = QColorDialog::getColor(foregroundColor_, 
    
    175
    +                                       this,
    
    176
    +                                       tr("Foreground Color"),
    
    177
    +                                       QColorDialog::ShowAlphaChannel);
    
    178
    +  if (result.isValid())
    
    179
    +  {
    
    180
    +    foregroundColor_ = result;
    
    181
    +    emit repaintNeeded();
    
    182
    +  }
    
    183
    +}
    
    184
    +
    
    185
    +
    
    186
    +void
    
    187
    +SettingPanel::updateGamma()
    
    188
    +{
    
    189
    +  gammaValueLabel_->setText(QString::number(gammaSlider_->value() / 10.0,
    
    190
    +                           'f',
    
    191
    +                           1));
    
    192
    +  emit repaintNeeded();
    
    193
    +}
    
    194
    +
    
    195
    +
    
    157 196
     void
    
    158 197
     SettingPanel::checkHintingMode()
    
    159 198
     {
    
    ... ... @@ -291,7 +330,7 @@ SettingPanel::syncSettings()
    291 330
         engine_->setShowSegments(segmentDrawingCheckBox_->isChecked());
    
    292 331
       }
    
    293 332
     
    
    294
    -  engine_->setGamma(gammaSlider_->value());
    
    333
    +  engine_->setGamma(gammaSlider_->value() / 10.0);
    
    295 334
     
    
    296 335
       engine_->setEmbeddedBitmap(embeddedBitmapCheckBox_->isChecked());
    
    297 336
       engine_->setPaletteIndex(paletteComboBox_->currentIndex());
    
    ... ... @@ -301,6 +340,9 @@ SettingPanel::syncSettings()
    301 340
       engine_->setLCDSubPixelPositioning(
    
    302 341
         antiAliasingComboBox_->currentIndex()
    
    303 342
           == AntiAliasingComboBoxModel::AntiAliasing_Light_SubPixel);
    
    343
    +
    
    344
    +  engine_->setForeground(foregroundColor_.rgba());
    
    345
    +  engine_->setBackground(backgroundColor_.rgba());
    
    304 346
     }
    
    305 347
     
    
    306 348
     
    
    ... ... @@ -322,7 +364,7 @@ SettingPanel::createConnections()
    322 364
               this, &SettingPanel::repaintNeeded);
    
    323 365
     
    
    324 366
       connect(gammaSlider_, &QSlider::valueChanged,
    
    325
    -          this, &SettingPanel::repaintNeeded);
    
    367
    +          this, &SettingPanel::updateGamma);
    
    326 368
       
    
    327 369
       connect(hintingCheckBox_, &QCheckBox::clicked,
    
    328 370
               this, &SettingPanel::repaintNeeded);
    
    ... ... @@ -353,6 +395,14 @@ SettingPanel::createConnections()
    353 395
         connect(lsbRsbDeltaCheckBox_, &QCheckBox::clicked,
    
    354 396
                 this, &SettingPanel::repaintNeeded);
    
    355 397
       }
    
    398
    +
    
    399
    +  if (!comparatorMode_)
    
    400
    +  {
    
    401
    +    connect(backgroundButton_, &QPushButton::clicked,
    
    402
    +            this, &SettingPanel::openBackgroundPicker);
    
    403
    +    connect(foregroundButton_, &QPushButton::clicked,
    
    404
    +            this, &SettingPanel::openForegroundPicker);
    
    405
    +  }
    
    356 406
     }
    
    357 407
     
    
    358 408
     
    
    ... ... @@ -434,6 +484,13 @@ SettingPanel::createLayout()
    434 484
       gammaSlider_->setTickPosition(QSlider::TicksBelow);
    
    435 485
       gammaSlider_->setTickInterval(5);
    
    436 486
       gammaLabel_->setBuddy(gammaSlider_);
    
    487
    +  gammaValueLabel_ = new QLabel(this);
    
    488
    +
    
    489
    +  if (!comparatorMode_)
    
    490
    +  {
    
    491
    +    backgroundButton_ = new QPushButton(tr("Background"), this);
    
    492
    +    foregroundButton_ = new QPushButton(tr("Foreground"), this);
    
    493
    +  }
    
    437 494
     
    
    438 495
       if (debugMode_)
    
    439 496
       {
    
    ... ... @@ -448,6 +505,7 @@ SettingPanel::createLayout()
    448 505
       gammaLayout_ = new QHBoxLayout;
    
    449 506
       gammaLayout_->addWidget(gammaLabel_);
    
    450 507
       gammaLayout_->addWidget(gammaSlider_);
    
    508
    +  gammaLayout_->addWidget(gammaValueLabel_);
    
    451 509
     
    
    452 510
       generalTabLayout_ = new QGridLayout;
    
    453 511
     
    
    ... ... @@ -474,6 +532,16 @@ SettingPanel::createLayout()
    474 532
                               new QSpacerItem(0, 20, QSizePolicy::Minimum,
    
    475 533
                                               QSizePolicy::MinimumExpanding));
    
    476 534
     
    
    535
    +  if (!comparatorMode_)
    
    536
    +  {
    
    537
    +    colorPickerLayout_ = new QHBoxLayout;
    
    538
    +    colorPickerLayout_->addWidget(backgroundButton_, 1);
    
    539
    +    colorPickerLayout_->addWidget(foregroundButton_, 1);
    
    540
    +    generalTabLayout_->addLayout(colorPickerLayout_,
    
    541
    +                                 generalTabLayout_->rowCount(), 
    
    542
    +                                 0, 1, 2);
    
    543
    +  }
    
    544
    +
    
    477 545
       gridLayout2ColAddLayout(generalTabLayout_, gammaLayout_);
    
    478 546
       gridLayout2ColAddWidget(generalTabLayout_, embeddedBitmapCheckBox_);
    
    479 547
       gridLayout2ColAddWidget(generalTabLayout_, colorLayerCheckBox_);
    
    ... ... @@ -559,7 +627,12 @@ SettingPanel::setDefaults()
    559 627
         lsbRsbDeltaCheckBox_->setChecked(true);
    
    560 628
       }
    
    561 629
     
    
    630
    +  // These need to be set even in Comperator mode.
    
    631
    +  backgroundColor_ = Qt::white;
    
    632
    +  foregroundColor_ = Qt::black;
    
    633
    +
    
    562 634
       gammaSlider_->setValue(18); // 1.8
    
    635
    +  updateGamma();
    
    563 636
     }
    
    564 637
     
    
    565 638
     
    

  • src/ftinspect/panels/settingpanel.hpp
    ... ... @@ -14,6 +14,8 @@
    14 14
     #include <QCheckBox>
    
    15 15
     #include <QGridLayout>
    
    16 16
     #include <QBoxLayout>
    
    17
    +#include <QPushButton>
    
    18
    +#include <QColorDialog>
    
    17 19
     
    
    18 20
     class SettingPanel
    
    19 21
     : public QWidget
    
    ... ... @@ -75,6 +77,7 @@ private:
    75 77
       QWidget* mmgxTab_;
    
    76 78
     
    
    77 79
       QLabel* gammaLabel_;
    
    80
    +  QLabel* gammaValueLabel_;
    
    78 81
       QLabel* antiAliasingLabel_;
    
    79 82
       QLabel* hintingModeLabel_;
    
    80 83
       QLabel* lcdFilterLabel_;
    
    ... ... @@ -102,10 +105,17 @@ private:
    102 105
     
    
    103 106
       QSlider* gammaSlider_;
    
    104 107
     
    
    108
    +  QPushButton* backgroundButton_;
    
    109
    +  QPushButton* foregroundButton_;
    
    110
    +
    
    105 111
       QVBoxLayout* mainLayout_;
    
    106 112
       QGridLayout* generalTabLayout_;
    
    107 113
       QVBoxLayout* debugLayout_;
    
    108 114
       QHBoxLayout* gammaLayout_;
    
    115
    +  QHBoxLayout* colorPickerLayout_;
    
    116
    +
    
    117
    +  QColor backgroundColor_;
    
    118
    +  QColor foregroundColor_;
    
    109 119
     
    
    110 120
       //////// Initializing funcs
    
    111 121
     
    
    ... ... @@ -114,6 +124,10 @@ private:
    114 124
       void setDefaults();
    
    115 125
     
    
    116 126
       void populatePalettes();
    
    127
    +
    
    128
    +  void openBackgroundPicker();
    
    129
    +  void openForegroundPicker();
    
    130
    +  void updateGamma();
    
    117 131
     };
    
    118 132
     
    
    119 133
     
    

  • src/ftinspect/panels/singular.cpp
    ... ... @@ -87,6 +87,8 @@ SingularTab::drawGlyph()
    87 87
         currentGlyphPointNumbersItem_ = NULL;
    
    88 88
       }
    
    89 89
     
    
    90
    +  glyphView_->setBackgroundBrush(QColor(engine_->background()));
    
    91
    +
    
    90 92
       syncSettings();
    
    91 93
       FT_Glyph glyph = engine_->loadGlyph(currentGlyphIndex_);
    
    92 94
       if (glyph)
    
    ... ... @@ -97,6 +99,7 @@ SingularTab::drawGlyph()
    97 99
             = new GlyphBitmap(currentGlyphIndex_, 
    
    98 100
                               glyph,
    
    99 101
                               engine_);
    
    102
    +      currentGlyphBitmapItem_->setZValue(-1);
    
    100 103
           glyphScene_->addItem(currentGlyphBitmapItem_);
    
    101 104
         }
    
    102 105
     
    
    ... ... @@ -104,6 +107,7 @@ SingularTab::drawGlyph()
    104 107
         {
    
    105 108
           currentGlyphOutlineItem_ = new GlyphOutline(graphicsDefault_->outlinePen, 
    
    106 109
                                                       glyph);
    
    110
    +      currentGlyphOutlineItem_->setZValue(1);
    
    107 111
           glyphScene_->addItem(currentGlyphOutlineItem_);
    
    108 112
         }
    
    109 113
     
    
    ... ... @@ -112,6 +116,7 @@ SingularTab::drawGlyph()
    112 116
           currentGlyphPointsItem_ = new GlyphPoints(graphicsDefault_->onPen,
    
    113 117
                                                     graphicsDefault_->offPen,
    
    114 118
                                                     glyph);
    
    119
    +      currentGlyphPointsItem_->setZValue(1);
    
    115 120
           glyphScene_->addItem(currentGlyphPointsItem_);
    
    116 121
     
    
    117 122
           if (showPointNumbersCheckBox_->isChecked())
    
    ... ... @@ -120,6 +125,7 @@ SingularTab::drawGlyph()
    120 125
               = new GlyphPointNumbers(graphicsDefault_->onPen,
    
    121 126
                                       graphicsDefault_->offPen,
    
    122 127
                                       glyph);
    
    128
    +        currentGlyphPointNumbersItem_->setZValue(1);
    
    123 129
             glyphScene_->addItem(currentGlyphPointNumbersItem_);
    
    124 130
           }
    
    125 131
         }
    
    ... ... @@ -254,7 +260,8 @@ SingularTab::createLayout()
    254 260
       glyphView_->setScene(glyphScene_);
    
    255 261
       glyphView_->setBackgroundBrush(Qt::white);
    
    256 262
     
    
    257
    -  gridItem_ = new Grid(glyphView_, graphicsDefault_->gridPen, 
    
    263
    +  gridItem_ = new Grid(glyphView_, 
    
    264
    +                       graphicsDefault_->gridPen, 
    
    258 265
                            graphicsDefault_->axisPen);
    
    259 266
       glyphScene_->addItem(gridItem_);
    
    260 267
     
    

  • src/ftinspect/rendering/glyphbitmap.cpp
    ... ... @@ -142,14 +142,17 @@ GlyphBitmapWidget::paintEvent(QPaintEvent* event)
    142 142
     
    
    143 143
       QPainter painter(this);
    
    144 144
       painter.fillRect(rect(), Qt::white);
    
    145
    -  painter.setPen(QPen(Qt::black, 4));
    
    146
    -  painter.drawRect(rect());
    
    147
    -
    
    148 145
       painter.scale(scale, scale);
    
    149 146
     
    
    150 147
       QStyleOptionGraphicsItem ogi;
    
    151 148
       ogi.exposedRect = br;
    
    152 149
       bitmapItem_->paint(&painter, &ogi, this);
    
    150
    +
    
    151
    +  double scaledLineWidth = 4 / scale;
    
    152
    +  painter.setPen(QPen(Qt::black, scaledLineWidth));
    
    153
    +  scaledLineWidth /= 2;
    
    154
    +  painter.drawRect(br.adjusted(scaledLineWidth, scaledLineWidth,
    
    155
    +                               -scaledLineWidth, -scaledLineWidth));
    
    153 156
     }
    
    154 157
     
    
    155 158
     
    

  • src/ftinspect/rendering/glyphcontinuous.cpp
    ... ... @@ -109,7 +109,7 @@ void
    109 109
     GlyphContinuous::paintEvent(QPaintEvent* event)
    
    110 110
     {
    
    111 111
       QPainter painter(this);
    
    112
    -  painter.fillRect(rect(), Qt::white);
    
    112
    +  painter.fillRect(rect(), engine_->background());
    
    113 113
     
    
    114 114
       if (glyphCache_.empty())
    
    115 115
         fillCache();
    

  • src/ftinspect/rendering/graphicsdefault.cpp
    ... ... @@ -8,21 +8,14 @@ GraphicsDefault* GraphicsDefault::instance_ = NULL;
    8 8
     
    
    9 9
     GraphicsDefault::GraphicsDefault()
    
    10 10
     {
    
    11
    -  // color tables (with suitable opacity values) for converting
    
    12
    -  // FreeType's pixmaps to something Qt understands
    
    13
    -  monoColorTable.append(QColor(Qt::transparent).rgba());
    
    14
    -  monoColorTable.append(QColor(Qt::black).rgba());
    
    15
    -
    
    16
    -  for (int i = 0xFF; i >= 0; i--)
    
    17
    -    grayColorTable.append(qRgba(i, i, i, 0xFF - i));
    
    18
    -
    
    19 11
       // XXX make this user-configurable
    
    20 12
     
    
    21 13
       axisPen.setColor(Qt::black);
    
    22 14
       axisPen.setWidth(0);
    
    23 15
       blueZonePen.setColor(QColor(64, 64, 255, 64)); // light blue
    
    24 16
       blueZonePen.setWidth(0);
    
    25
    -  gridPen.setColor(Qt::lightGray);
    
    17
    +  // Don't make this solid
    
    18
    +  gridPen.setColor(QColor(0, 0, 0, 255 - QColor(Qt::lightGray).red()));
    
    26 19
       gridPen.setWidth(0);
    
    27 20
       offPen.setColor(Qt::darkGreen);
    
    28 21
       offPen.setWidth(3);
    

  • src/ftinspect/rendering/graphicsdefault.hpp
    ... ... @@ -11,9 +11,6 @@
    11 11
     // This is default graphics objects fed into render functions.
    
    12 12
     struct GraphicsDefault
    
    13 13
     {
    
    14
    -  QVector<QRgb> grayColorTable;
    
    15
    -  QVector<QRgb> monoColorTable;
    
    16
    -
    
    17 14
       QPen axisPen;
    
    18 15
       QPen blueZonePen;
    
    19 16
       QPen gridPen;
    


  • reply via email to

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