Note that there are some explanatory texts on larger screens.

plurals
  1. POSamsung devices supporting setTypeface(Typeface.Italic)?
    primarykey
    data
    text
    <p>I have in application that makes use of a custom View component that drawas some text onto the screen via Paint/Canvas.</p> <p>I am using the following code (before I call canvas.drawText()) to make my text Italic:</p> <pre><code>mPaintText.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC)); </code></pre> <p>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. </p> <p>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</p> <pre><code>tv.setText(Html.fromHtml("&lt;i&gt;sometext&lt;/i&gt;"); </code></pre> <p>in java or</p> <pre><code>android:textStyle="italic" </code></pre> <p>in layout.xml and my text appears italic.</p> <p>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?</p> <p><strong>EDIT:</strong> </p> <p>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.</p> <pre><code>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 </code></pre> <p><strong>EDIT AGAIN:</strong> 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. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload