bugGNU Octave - Bugs: bug #57352, text height for blank line should...

 
 

bug #57352: text height for blank line should approximate that of ordinary character

Submitter:  Rik <rik5>
Submitted:  Tue 03 Dec 2019 10:26:21 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  2 - Minor
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 13 Feb 2023 08:01:23 PM UTC, comment #6: 

The following change in ft_text_renderer::update_line_bbox implements what I proposed in comment #1:


diff -r 6bf833d96cbe libinterp/corefcn/ft-text-renderer.cc
--- a/libinterp/corefcn/ft-text-renderer.cc     Sat Feb 11 09:57:47 2023 -0800
+++ b/libinterp/corefcn/ft-text-renderer.cc     Mon Feb 13 20:55:59 2023 +0100
@@ -775,6 +775,11 @@
       // Add one pixel to the bbox height to avoid occasional text clipping.
       // See bug #55328.
       bb(3) = (m_ymax + 1) - m_ymin;
+
+      // Fix a minimum line height of 0.5 fontsize, see bug #57352.
+      if (bb(3) < 0.5 * m_font.get_size ())
+        bb(3) = 0.5 * m_font.get_size ();
+


But it doesn't actually make a visual difference. Changing to 1 fontsize makes it better but still not enough.

Pantxo Diribarne <pantxo>
Group Member
Sat 11 Feb 2023 07:27:29 PM UTC, comment #5: 

@Pantxo: This is ancient, but is there a way to have a blank or space character create a vertical spacing equivalent to an ordinary character?  I took a look in gl_render.cc and I couldn't quite follow the logic and gave up.

Rik <rik5>
Group administrator
Thu 12 Dec 2019 05:09:02 PM UTC, comment #4: 

@Pantxo: I think this will be quick.  Do you know where in the code to stick a statement so that there is a minimum vertical spacing that scales with "FontSize"?

Rik <rik5>
Group administrator
Mon 09 Dec 2019 10:24:12 PM UTC, comment #3: 

I think experimentation is required for the exact value, but requiring a minimum which is some fraction of "FontSize" seems like a reasonable approach.

Rik <rik5>
Group administrator
Wed 04 Dec 2019 07:20:00 PM UTC, comment #2: 

Okay, I didn' realize that Matlab also produced lines with varying vertical spacing.  I tried this


clf;
text (.5, .5, {"a", "b^C_D", "e", "f", "", "g"})
text (.6, .5, {"a", "bCD", "e", "f", "", "g"})


and got the results attached in file vspace_example.png.

I don't think there is anything we need to do for Octave in that regard.

I think it would be nice to have a blank line produce a vertical space that was closer to what an ordinary character would make.  Re-titling bug report for that issue.



Rik <rik5>
Group administrator
Wed 04 Dec 2019 02:20:12 PM UTC, comment #1: 


>> When there are multiple lines in a text() command, Matlab uses the same vertical spacing for every line.


I tried the following example in ML:


text (.5, .5, {"a", "b^C_D", "e", "f", "", "g"})


So to be exact, ML seems to put a fixed distance between bottom of line N and top of line N+1. You can see in the attached figures that the distance between all baselines is not the same ((1->2)>(3->4)).

As for small characters (".", " ", "-", "" ...), we could probably obtain the same effect by fixing a minimal height, e.g 0.5fontsize.





Pantxo Diribarne <pantxo>
Group Member
Tue 03 Dec 2019 10:26:21 PM UTC, original submission:  

When there are multiple lines in a text() command, Matlab uses the same vertical spacing for every line.  Octave seems to inspect each line and use a different vertical spacing based on the characters present (characters with descenders or CAPITAL letters will have different heights).

Sample code is attached


## '[]' should create a newline with same height as regular line
clf;
text (.3, .8, {"Hello", 'world', [], 123}, 'fontsize', 20)
text (.5, .8, {"Hello", 'world', 1, 123}, 'fontsize', 20)


The resulting plot is attached as well.

Rik <rik5>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #47998:  vspace_example.png added by rik5 (2KiB - image/png)
file #47992:  ML_text.png added by pantxo (1KiB - image/png)
file #47993:  Octave_text.png added by pantxo (941B - image/png)
file #47986:  tst_text_rowheight.m added by rik5 (187B - text/x-matlab)
file #47987:  rowheight.png added by rik5 (23KiB - image/png)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Updated the item)
  • -email is unavailable- added by rik5 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-12-04 rik5 Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
    2019-12-04 rik5 Attached File- Added vspace_example.png, #47998
        Summarytext height for blank line is not the same as for a line with text text height for blank line should approximate that of ordinary character
    2019-12-04 pantxo Attached File- Added ML_text.png, #47992
        Attached File- Added Octave_text.png, #47993
        CategoryPlotting Plotting with OpenGL
    2019-12-03 rik5 Attached File- Added tst_text_rowheight.m, #47986
        Attached File- Added rowheight.png, #47987

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code