Skip to content

Commit

Permalink
Fix recent failure in drawPaveText
Browse files Browse the repository at this point in the history
  • Loading branch information
linev committed Sep 26, 2024
1 parent 4a15b89 commit 87b8ab9
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions modules/hist/TPavePainter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -485,17 +485,17 @@ class TPavePainter extends ObjectPainter {
if (!text_g) text_g = this.draw_g;

const fast = (nlines === 1) && pp._fast_drawing;
let num_default = 0, is_any_text = false, is_custom_text = false;
let num_txt = 0, num_custom = 0;

arr.forEach(entry => {
if ((entry._typename !== clTText) && (entry._typename !== clTLatex)) return;
if (!entry.fTitle || !entry.fTitle.trim()) return;
is_any_text = true;
num_txt++;
if (entry.fX || entry.fY || entry.fTextSize)
is_custom_text = true;
num_custom++;
});

const pr = is_any_text && !is_custom_text ? this.startTextDrawingAsync(this.textatt.font, 0.85*height/nlines, text_g, max_font_size) : Promise.resolve();
const pr = (num_txt > num_custom) ? this.startTextDrawingAsync(this.textatt.font, 0.85*height/nlines, text_g, max_font_size) : Promise.resolve();

return pr.then(() => {

Check warning on line 500 in modules/hist/TPavePainter.mjs

View workflow job for this annotation

GitHub Actions / build-macos (18.x)

Block must not be padded by blank lines

Check warning on line 500 in modules/hist/TPavePainter.mjs

View workflow job for this annotation

GitHub Actions / build-windows (18.x)

Block must not be padded by blank lines

Check warning on line 500 in modules/hist/TPavePainter.mjs

View workflow job for this annotation

GitHub Actions / build-ubuntu (18.x, g++-11)

Block must not be padded by blank lines

Check warning on line 500 in modules/hist/TPavePainter.mjs

View workflow job for this annotation

GitHub Actions / build-macos (20.x)

Block must not be padded by blank lines

Check warning on line 500 in modules/hist/TPavePainter.mjs

View workflow job for this annotation

GitHub Actions / build-windows (20.x)

Block must not be padded by blank lines

Check warning on line 500 in modules/hist/TPavePainter.mjs

View workflow job for this annotation

GitHub Actions / build-ubuntu (18.x, g++-12)

Block must not be padded by blank lines

Check warning on line 500 in modules/hist/TPavePainter.mjs

View workflow job for this annotation

GitHub Actions / build-ubuntu (18.x, g++-13)

Block must not be padded by blank lines

Check warning on line 500 in modules/hist/TPavePainter.mjs

View workflow job for this annotation

GitHub Actions / build-ubuntu (20.x, g++-11)

Block must not be padded by blank lines

Check warning on line 500 in modules/hist/TPavePainter.mjs

View workflow job for this annotation

GitHub Actions / build-ubuntu (20.x, g++-12)

Block must not be padded by blank lines

Check warning on line 500 in modules/hist/TPavePainter.mjs

View workflow job for this annotation

GitHub Actions / build-ubuntu (20.x, g++-13)

Block must not be padded by blank lines

Expand All @@ -509,7 +509,6 @@ class TPavePainter extends ObjectPainter {

let color = entry.fTextColor ? this.getColor(entry.fTextColor) : '';
if (!color) color = this.textatt.color;
is_any_text = true;
if (entry.fX || entry.fY || entry.fTextSize) {
// individual positioning
const align = entry.fTextAlign || this.textatt.align,
Expand All @@ -524,8 +523,6 @@ class TPavePainter extends ObjectPainter {
latex: (entry._typename === clTText) ? 0 : 1, draw_g, fast }))
.then(() => this.finishTextDrawing(draw_g)));
} else {
num_default++;

this.drawText({ x: margin_x, y: texty, width: width - 2*margin_x, height: stepy,
align: entry.fTextAlign || this.textatt.align,
draw_g: text_g, latex: (entry._typename === clTText) ? 0 : 1,
Expand Down Expand Up @@ -559,11 +556,11 @@ class TPavePainter extends ObjectPainter {
}
}

if (is_any_text && !is_custom_text)
promises.push(this.finishTextDrawing(text_g, num_default > 1));
if (num_txt > num_custom)
promises.push(this.finishTextDrawing(text_g, num_txt > num_custom + 1));

if (this.isTitle())
this.draw_g.style('display', !is_any_text ? 'none' : null);
this.draw_g.style('display', !num_txt ? 'none' : null);

if (draw_header) {
const x = Math.round(width*0.25),
Expand Down

0 comments on commit 87b8ab9

Please sign in to comment.