三星设备支持setTypeface(Typeface.Italic)? [英] Samsung devices supporting setTypeface(Typeface.Italic)?

查看:469
本文介绍了三星设备支持setTypeface(Typeface.Italic)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序,利用它通过画图drawas一些文字在屏幕上的自定义视图组件/帆布。

I have in application that makes use of a custom View component that drawas some text onto the screen via Paint/Canvas.

我使用下面的code(之前我叫canvas.drawText()),使我的文字斜体:

I am using the following code (before I call canvas.drawText()) to make my text Italic:

mPaintText.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC));

这适用于三星Galaxy Nexus的。但在三星4G的史诗(GALAXY S),三星史诗触摸(GALAXY SII)和三星变换超我的文字还是非斜体。

This works on Samsung Galaxy Nexus. But on Samsung Epic 4g (galaxy S), Samsung Epic Touch (Galaxy SII), and Samsung Transform ultra my text is still non-italic.

有谁知道为什么有些三星的设备不支持设置斜体字呀?我知道这些设备能够呈现的斜体字,因为如果我有一个TextView我可以使用任

Does anyone know why some of these samsung devices wouldn't support setting italic text that way? I know the devices are capable of rendering the italic text because if I have a TextView I can use either

tv.setText(Html.fromHtml("<i>sometext</i>");

在Java或

android:textStyle="italic"

在layout.xml和我的文字出现倾斜。

in layout.xml and my text appears italic.

有谁知道的另一种方式,我可以设置画布的drawText()方法来绘制文本斜体可能工作在这些设备上?

Does anyone know of another way that I can set the drawText() method of canvas to draw the text italicized that might work on these devices?

编辑:

下面是一些方法,我以后试图与他们的成果在评论列表。原来SERIF似乎是,它的工作原理上唯一的字体。

Here is a list of some ways I've tried it with their outcome in comments after. Turns out SERIF seems to be the only font that it works on.

mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.ITALIC) //Nothing
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT_BOLD, Typeface.ITALIC) //Nothing
mPaint.setTypeface(Typeface.create(Typeface.SERIF, Typeface.ITALIC) //omg it is italic...But serifs look gross.
mPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC) //Nothing
mPaint.setTypeface(Typeface.create(Typeface.MONOSPACE, Typeface.ITALIC) //Changes font, but still no italic.
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD_ITALIC) //Bold but no italic

再次编辑:要启用此功能,我结束了加入roboto字体的斜体版本,以我的资产文件夹和应用它作为一种字体。我仍然有兴趣,如果有谁找到一种方式来获得它的工作而无需添加这种方式。

EDIT AGAIN: To make this function I ended up adding the italic version of the roboto font to my assets folder and applied it as a font. I'd still be interested if anyone ever finds a way to get it working without adding it this way.

推荐答案

尝试直接传递值到 setTypeFace API,直到你找到合适的人。如果斜体正在通过其他方法则有可能是在不断定义的一些问题,在字体类(在这些版本)。

Try passing direct values to the setTypeFace api till you find the right one. If italicizing is working through other methods then there could be some problem in constant definitions in TypeFace class (in those builds).

mPaintText.setTypeface(Typeface.defaultFromStyle(0)); // then 1, 2, 3

这篇关于三星设备支持setTypeface(Typeface.Italic)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆