Commits

Lenard Lindstrom committed 02f253b

freetype: Tweak underline positioning to allow for line size.

  • Participants
  • Parent commits 271935c

Comments (0)

Files changed (2)

examples/freetype_misc.py

     screen = pygame.display.set_mode((800, 600))
     screen.fill (colors["grey_light"])
 
-    face.underline_adjustment = 0.25
+    face.underline_adjustment = 0.5
+    face.pad = True
     face.render((screen, 32, 32), "Hello World", colors["red"], colors['grey_dark'],
             ptsize=64, style=freetype.STYLE_UNDERLINE|freetype.STYLE_OBLIQUE)
+    face.pad = False
 
     face.render((screen, 32, 128), "abcdefghijklm", colors["grey_dark"], colors["green"],
             ptsize=64)
 
     face.vertical = True
-    face.render((screen, 32, 190), "Vertical?", colors["blue"], None, ptsize=32)
+    face.render((screen, 32, 200), "Vertical?", colors["blue"], None, ptsize=32)
     face.vertical = False
 
     face.render((screen, 64, 190), "Let's spin!", colors["red"], None,
     face.render((screen, 250, 220), "and BLEND", pygame.Color(255, 0, 0, 128), None,
             ptsize=64)
 
-    face.render((screen, 258, 237), "or BLAND!", pygame.Color(0, 0xCC, 28, 128), None,
+    face.render((screen, 265, 237), "or BLAND!", pygame.Color(0, 0xCC, 28, 128), None,
             ptsize=64)
 
     face.origin = True

src/freetype/ft_text.c

     FT_Pos      text_width;
     FT_Pos      text_height;
     FT_Pos      top = FX6_MIN;
+    FT_Fixed    y_scale;
 
     FT_Error    error = 0;
 
     /* load our sized face */
     face = _PGFT_GetFaceSized(ft, faceobj, mode->pt_size);
-
     if (!face) {
         PyErr_SetString(PyExc_SDLError, _PGFT_GetError(ft));
         return 0;
     }
+    y_scale = face->size->metrics.y_scale;
 
     /* cleanup the cache */
     _PGFT_Cache_Cleanup(&ftext->glyph_cache);
         if (max_y_underline > max_y) {
             max_y = max_y_underline;
         }
-        ftext->underline_pos = adjusted_pos;
+        ftext->underline_pos = max_y_underline - size;
         ftext->underline_size = size;
     }