Last active
          August 27, 2018 10:54 
        
      - 
      
- 
        Save benoitjadinon/f0d62c094689aa2e4c8824afb1690f62 to your computer and use it in GitHub Desktop. 
    DrawTextCenteredVertically
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /// <remarks>https://stackoverflow.com/questions/27631736/meaning-of-top-ascent-baseline-descent-bottom-and-leading-in-androids-font</remarks> | |
| public static void DrawTextCenteredVertically(this SKCanvas canvas, string text, SKPaint paint, SKPoint point) | |
| { | |
| var textY = point.Y + (((-paint.FontMetrics.Ascent + paint.FontMetrics.Descent) / 2) - (paint.FontMetrics.Descent /2)); // seems to work better with descent/2 | |
| canvas.DrawText(text, point.X, textY, paint); | |
| } | 
      
      
  Author
  
  
        
      
            benoitjadinon
  
      
      
      commented 
        Aug 16, 2018 
      
    
  
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            