Loading ...
Sorry, an error occurred while loading the content.

[PATCH] A few MMAtsuiTextView rendering fixes

Expand Messages
  • Jjgod Jiang
    1. Fix AtsuiTextView italic angle problem. 2. Add underline/undercurl support for text drawing. 3. Use default background color to fill the inset area. ...
    Message 1 of 8 , Jul 26, 2008
    • 0 Attachment
      1. Fix AtsuiTextView italic angle problem.
      2. Add underline/undercurl support for text drawing.
      3. Use default background color to fill the inset area.
      ---
      src/MacVim/MMAtsuiTextView.m | 54 ++++++++++++++++++++++++++++++++++++++----
      1 files changed, 49 insertions(+), 5 deletions(-)

      diff --git a/src/MacVim/MMAtsuiTextView.m b/src/MacVim/MMAtsuiTextView.m
      index cf0a52f..8f5b5a9 100644
      --- a/src/MacVim/MMAtsuiTextView.m
      +++ b/src/MacVim/MMAtsuiTextView.m
      @@ -40,6 +40,12 @@
      #define DRAW_ITALIC 0x10 /* draw italic text */
      #define DRAW_CURSOR 0x20

      +#define kUnderlineOffset (-2)
      +#define kUnderlineHeight 1
      +#define kUndercurlHeight 2
      +#define kUndercurlOffset (-2)
      +#define kUndercurlDotWidth 2
      +#define kUndercurlDotDistance 2

      static char MMKeypadEnter[2] = { 'K', 'A' };
      static NSString *MMKeypadEnterString = @"KA";
      @@ -482,6 +488,9 @@ enum {
      dstRect.origin.x += insetSize.width;
      dstRect.origin.y += insetSize.height;

      + [defaultBackgroundColor set];
      + NSRectFill(rect);
      +
      [contentImage drawInRect: dstRect
      fromRect: srcRect
      operation: NSCompositeCopy
      @@ -946,6 +955,7 @@ enum {

      #define atsu_style_set_bool(s, t, b) \
      ATSUSetAttributes(s, 1, &t, &(sizeof(Boolean)), &&b);
      +#define FILL_Y(y) (y * cellSize.height)

      - (void)drawString:(UniChar *)string length:(UniCharCount)length
      atRow:(int)row column:(int)col cells:(int)cells
      @@ -960,18 +970,24 @@ enum {

      // Font selection and rendering options for ATSUI
      ATSUAttributeTag attribTags[3] = { kATSUQDBoldfaceTag,
      - kATSUQDItalicTag,
      + kATSUFontMatrixTag,
      kATSUStyleRenderingOptionsTag };
      +
      ByteCount attribSizes[] = { sizeof(Boolean),
      - sizeof(Boolean),
      + sizeof(CGAffineTransform),
      sizeof(UInt32) };
      - Boolean useBold, useItalic;
      + Boolean useBold;
      + CGAffineTransform theTransform = CGAffineTransformMakeScale(1.0, -1.0);
      UInt32 useAntialias;
      - ATSUAttributeValuePtr attribValues[3] = { &useBold, &useItalic,
      +
      + ATSUAttributeValuePtr attribValues[3] = { &useBold, &theTransform,
      &useAntialias };

      useBold = (flags & DRAW_BOLD) ? true : false;
      - useItalic = (flags & DRAW_ITALIC) ? true : false;
      +
      + if (flags & DRAW_ITALIC)
      + theTransform.c = Fix2X(kATSItalicQDSkew);
      +
      useAntialias = antialias ? kATSStyleApplyAntiAliasing
      : kATSStyleNoAntiAliasing;

      @@ -1012,6 +1028,34 @@ enum {
      X2Fix(rect.origin.x),
      X2Fix(rect.origin.y + [font ascender]));
      ATSUDisposeTextLayout(layout);
      +
      + if (flags & DRAW_UNDERL)
      + {
      + [fg set];
      + NSRectFill(NSMakeRect(rect.origin.x,
      + (row + 1) * cellSize.height + kUnderlineOffset,
      + rect.size.width, kUnderlineHeight));
      + }
      +
      + if (flags & DRAW_UNDERC)
      + {
      + [sp set];
      +
      + float line_end_x = rect.origin.x + rect.size.width;
      + int i = 0;
      + NSRect line_rect = NSMakeRect(rect.origin.x,
      + (row + 1) * cellSize.height + kUndercurlOffset,
      + kUndercurlDotWidth, kUndercurlHeight);
      +
      + while (line_rect.origin.x < line_end_x)
      + {
      + if (i % 2)
      + NSRectFill(line_rect);
      +
      + line_rect.origin.x += kUndercurlDotDistance;
      + i++;
      + }
      + }
      }

      - (void)scrollRect:(NSRect)rect lineCount:(int)count
      --
      1.5.4.3


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • björn
      ... Thanks for the patches Jiang. I ll review them and merge soon. Björn --~--~---------~--~----~------------~-------~--~----~ You received this message from
      Message 2 of 8 , Jul 27, 2008
      • 0 Attachment
        2008/7/27 Jjgod Jiang <gzjjgod@...>:
        >
        > 1. Fix AtsuiTextView italic angle problem.
        > 2. Add underline/undercurl support for text drawing.
        > 3. Use default background color to fill the inset area.
        > ---

        Thanks for the patches Jiang. I'll review them and merge soon.

        Björn

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_mac" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • björn
        ... I ve pushed this patch now. Thanks once again. During testing I noticed there are still some rendering artifacts (not related to your patch though). For
        Message 3 of 8 , Jul 29, 2008
        • 0 Attachment
          2008/7/27 björn <bjorn.winckler@...>:
          > 2008/7/27 Jjgod Jiang <gzjjgod@...>:
          >>
          >> 1. Fix AtsuiTextView italic angle problem.
          >> 2. Add underline/undercurl support for text drawing.
          >> 3. Use default background color to fill the inset area.
          >> ---
          >
          > Thanks for the patches Jiang. I'll review them and merge soon.

          I've pushed this patch now. Thanks once again.

          During testing I noticed there are still some rendering artifacts (not
          related to your patch though). For example, if I enter this text

          gggggggggg

          and then hit "Esc" then "I" (capital i) and enter a couple of "a", the
          a's look like they have a dotted underline because the bottom of the
          g's don't get erased properly. I've seen similar artifacts with
          italics on the right-hand side of a slanted glyph when it overlaps the
          glyph to its right. Have you noticed these things as well Jiang?

          Björn

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_mac" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Jjgod Jiang
          Hi,On Wed, Jul 30, 2008 at 4:01 AM, björn wrote: During testing I noticed there are still some rendering artifacts (not
          Message 4 of 8 , Jul 29, 2008
          • 0 Attachment
            Hi,

            On Wed, Jul 30, 2008 at 4:01 AM, björn <bjorn.winckler@...> wrote:
            > During testing I noticed there are still some rendering artifacts (not
            > related to your patch though). For example, if I enter this text
            >
            > gggggggggg
            >
            > and then hit "Esc" then "I" (capital i) and enter a couple of "a", the
            > a's look like they have a dotted underline because the bottom of the
            > g's don't get erased properly. I've seen similar artifacts with
            > italics on the right-hand side of a slanted glyph when it overlaps the
            > glyph to its right. Have you noticed these things as well Jiang?

            I'm sure I've seen it before, however I failed to reproduce the exact
            behavior you described with the above instruction. Could you please
            send me a screenshot off the list?

            - Jiang

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_mac" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Nico Weber
            ... Doesn t this fix always use computational slanting, even if the font includes a real italic variant? (
            Message 5 of 8 , Jul 30, 2008
            • 0 Attachment
              > 1. Fix AtsuiTextView italic angle problem.

              Doesn't this fix always use computational slanting, even if the font
              includes a "real" italic variant? ( http://www.marksimonson.com/article/128/fake-vs-true-italics
              )

              Nico

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_mac" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            Your message has been successfully submitted and would be delivered to recipients shortly.