Android文本大纲对于较大的字体大小有很大的差距,但仅在我的一台设备上

Android文本大纲对于较大的字体大小有很大的差距,但仅在我的一台设备上,android,drawtext,Android,Drawtext,多年来,我一直在使用下面的方法(以各种形式)在Android画布上呈现带有轮廓的文本,直到最近我在三星Galaxy标签上测试了一个应用程序,它才给我带来任何问题。当使用较大的文本时,很明显,轮廓和填充文本之间存在较大的间隙 public static void renderMessage(Canvas offScreenCanvas, String value, float inputXPos, float inputYPos, float textSize,

多年来,我一直在使用下面的方法(以各种形式)在Android画布上呈现带有轮廓的文本,直到最近我在三星Galaxy标签上测试了一个应用程序,它才给我带来任何问题。当使用较大的文本时,很明显,轮廓和填充文本之间存在较大的间隙

public static void renderMessage(Canvas offScreenCanvas, String value, float inputXPos, float inputYPos, float textSize,
                                 boolean bold, boolean centreTextAroundLocation, int inputTextColour, int actualTextOutlineColour,
                                 float textOutlineStrokeWidth, final float standardStrokeWidth, Display display) {

    Paint paint = new Paint(){
        {
            setAntiAlias(true);
            setFilterBitmap(true);
            setStrokeWidth(standardStrokeWidth);
            setStyle(Paint.Style.FILL);
        }
    };

    if (bold) {
        paint.setTypeface(Typeface.DEFAULT_BOLD);
    }

    if (centreTextAroundLocation) {
        paint.setTextAlign(Paint.Align.CENTER);
    }

    paint.setTextSize(textSize);
    Rect bounds = new Rect();
    paint.getTextBounds(value, 0, value.length(), bounds);
    float actualHeight = (float)bounds.height();
    float actualWidth = (float)bounds.width();
    float xPos = inputXPos;
    float yPos = inputYPos;
    if (centreTextAroundLocation) {
        yPos = inputYPos - (paint.descent() + paint.ascent()) / 2.0f;
    }
    else {
        if (inputXPos == -1.0f) {
            xPos = (float)display.getWidth() / 2.0f - actualWidth / 2.0f;
        }

        if (inputYPos == -1.0f) {
            yPos = (float)display.getHeight() / 2.0f - actualHeight / 2.0f;
        }
    }

    if (actualTextOutlineColour != 0) {
        paint.setColor(actualTextOutlineColour);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(textOutlineStrokeWidth);
        offScreenCanvas.drawText(value, xPos, yPos, paint);
        paint.setStrokeWidth(standardStrokeWidth);
        paint.setStyle(Paint.Style.FILL);
    }

    paint.setColor(inputTextColour);
    offScreenCanvas.drawText(value, xPos, yPos, paint);
}
实际上,我所有的其他测试设备都很好,即使字体大小非常夸张。只有三星Galaxy标签看起来像下图。我已经尝试了我能想到的每一种方法,我被难倒了。我不知道这个差距是从哪里来的


您尝试过自定义字体吗?