gpt4 book ai didi

Android Paint.setTypeface 不适用于斜体

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:56:00 26 4
gpt4 key购买 nike

Paint.setTypeface 不适用于斜体,或者我做错了事。我可以创建普通、粗体、等宽和衬线文本,但无法创建斜体文本。它总是看起来很正常(或者在粗斜体的情况下,它看起来很粗)。

    //This will appear monospace
paint.setTypeface(Typeface.MONOSPACE);
canvas.drawText("foo", 10, 10, paint);

//This will appear serif
paint.setTypeface(Typeface.SERIF);
canvas.drawText("foo", 10, 10, paint);

//This will appear bold
paint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
canvas.drawText("foo", 10, 10, paint);

//This will NOT appear italic <=== PROBLEM
paint.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC));
canvas.drawText("foo", 10, 10, paint);

// This isn't working either <=== PROBLEM
paint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC));

那么现在的问题是:是否有已知的解决方法?我的简单目标是用斜体风格绘制一些单词...

最佳答案

遇到同样的困难后,我在TextView源代码中摸索找到了解决办法。试试这个:

paint.setTextSkewX(-0.25f);

关于Android Paint.setTypeface 不适用于斜体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6124440/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com