Menu

#2341 STYLE_CALLTIP impacts line height calculation

Bug
closed-fixed
nobody
5
2022-08-27
2022-07-21
No

The style for the calltip participates in calculating the line height in ViewStyle::Refresh(). Hence, choosing a taller font for the calltip results in an unnecessary increased line height.

I've modified ViewStyle::Refresh() to skip creating the font for the calltip style before determining the line height, but create it afterwards. Please see the attached file ViewStyle.cxx.

1 Attachments

Discussion

  • Neil Hodgson

    Neil Hodgson - 2022-07-21

    This would be simpler and clearer inserted into FindMaxAscentDescent by changing its loop into looping over the indices of styles and ignoring StyleCallTip.

     
    • Markus Nißl

      Markus Nißl - 2022-07-22

      So, you'd prefer this approach?

      void ViewStyle::FindMaxAscentDescent() noexcept {
        for (int i = 0; i < styles.size(); i++) {
          if (i == StyleCallTip)
            continue;
      
          const auto &font = Find(styles[i]);
      
          if (maxAscent < font->measurements.ascent)
            maxAscent = font->measurements.ascent;
          if (maxDescent < font->measurements.descent)
            maxDescent = font->measurements.descent;
        }
      }
      

      IMHO, it has the drawback of both having to look up the font in the FontMap and the same font will be found multiple times for styles using the same font.

       

      Last edit: Markus Nißl 2022-07-22
      • Neil Hodgson

        Neil Hodgson - 2022-07-22
        class Style : public FontSpecification, public FontMeasurements
        

        Styles are also FontMeasurements so use the ascent and descent from the Style.

         
        • Markus Nißl

          Markus Nißl - 2022-07-22

          This should be it then 😁

          void ViewStyle::FindMaxAscentDescent() noexcept {
            for (int i = 0; i < styles.size(); i++) {
              if (i == StyleCallTip)
                continue;
          
              const auto &style = styles[i];
          
              if (maxAscent < style.ascent)
                maxAscent = style.ascent;
              if (maxDescent < style.descent)
                maxDescent = style.descent;
            }
          }
          
           
  • Neil Hodgson

    Neil Hodgson - 2022-07-22
    • labels: --> scintilla, font, style
    • status: open --> open-fixed
     
  • Neil Hodgson

    Neil Hodgson - 2022-07-22

    Committed as [f7eeee] with change to size_t to avoid warning.

     

    Related

    Commit: [f7eeee]

    • Markus Nißl

      Markus Nißl - 2022-07-22

      Thank you very much 👍🏻

       
  • Neil Hodgson

    Neil Hodgson - 2022-08-27
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB