2

The font Calibre have Light, Light Italic, Italic, Regular, Bold and Bold Italic versions.

Using the example: Font font = new Font("Calibre", type, 48);

To use Calibri Italic I have to use type = Font.ITALIC

To use Calibri Bold I have to use type = Font.BOLD

To use Calibri Regular I have to use type = Font.TRUETYPE_FONT

But how can I use Light, Light Italic and Bold Italic versions?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Forsaiken
  • 324
  • 3
  • 12

2 Answers2

3

You could I suppose just use the Calibri Light font:

Font font = new Font("Calibre Light", Font.ITALIC, 48);

Or you can load the font, the following will load the Calibri Light Italic:

Font font = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(
            new File("calibrili.ttf"))).deriveFont(Font.PLAIN, 48);

The above code line will of course need to be wrapped within a try/catch block since the exceptions FileNotFoundException, FontFormatException, and IOException could possibly be thrown.

Calibri is a Microsoft Font and it packages 6 font files which are:

calibri.ttf       The Standard Calibri font
calibrib.ttf      Calibri Bold
calibrii.ttf      Calibri Italic
calibril.ttf      Calibri Light
calibrili.ttf     Calibri Light Italic
calibriz.ttf      Calibri Bold Italic

You will note that using a font type of Font.ITALIC actually does nothing since Calibri Light Italic is an Italic font. However Font.BOLD will bold the italic text

DevilsHnd - 退職した
  • 8,739
  • 2
  • 19
  • 22
0

It is the custom font in android studio.Here is the similar question. It should work for youcode for custom font in android studio

Abhishek Borikar
  • 374
  • 1
  • 5
  • 15