Skip to content

Commit

Permalink
Make italic fonts smaller to fit in cells
Browse files Browse the repository at this point in the history
  • Loading branch information
sedwards2009 committed Jun 1, 2024
1 parent 8a0f819 commit 4a79868
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,14 @@ export abstract class FontAtlasBase<CG extends CachedGlyph> {
font.setWeight(style & STYLE_MASK_BOLD ? QFontWeight.Bold : QFontWeight.Normal);
font.setItalic((style & STYLE_MASK_ITALIC) !== 0);

if ((style & STYLE_MASK_ITALIC) !== 0) {
// Make the font slightly smaller when it is italic.
// This helps keep the glyphs within the cell.
this.#qfont.setPixelSize(Math.floor(this._metrics.fontSizePx * 0.8));
} else {
this.#qfont.setPixelSize(this._metrics.fontSizePx);
}

painter.setFont(font);

let metrics = this._metrics;
Expand Down

0 comments on commit 4a79868

Please sign in to comment.