我正在我的应用程序中实现自定义标签字段。它适用于小字体,当我增加字体大小时,它不会正确显示。在这里你可以在这张图片中看到它。

您可以在图像中看到它只显示了一半的文本。我该如何克服这一点。
在这里,我给出了自定义 LabelField 的代码。请告诉我我做错了什么。
public class CustomLabelField extends Field  
{  
    private String label;  
    private int fontSize;
    private int foregroundColor;  
    private int backgroundColor;  
    public CustomLabelField(String label, int fontSize, int foregroundColor,  
                     int backgroundColor,long style)  
    {  
        super(style);  
        this.label = label;  
        this.foregroundColor = foregroundColor;  
        this.backgroundColor = backgroundColor;  
        this.fontSize = fontSize;
    }  
   protected void layout(int width, int height) {  
       setExtent(width, getFont().getHeight());  
   }  
    protected void paint(Graphics graphics) {  
       graphics.setBackgroundColor(backgroundColor);  
       graphics.clear();  
       graphics.setFont(setMyFont());  
       graphics.setColor(foregroundColor);  
       graphics.drawText(label, 0, 0, (int)(getStyle()& DrawStyle.ELLIPSIS | DrawStyle.HALIGN_MASK),getWidth() - 6);  
   }  
   // Get font for the label field  
   public Font setMyFont()  
   {  
     try {  
         FontFamily alphaSansFamily = FontFamily.forName("BBAlpha Serif");  
         Font appFont = alphaSansFamily.getFont(Font.PLAIN, fontSize, Ui.UNITS_pt);  
         return appFont;  
    } catch (ClassNotFoundException e) {  
        // TODO Auto-generated catch block  
        e.printStackTrace();  
    }  
    return null;  
  }  
}