dashman
dashman

Reputation: 3018

Specifying a Roboto font in Android

I'm trying to set a Roboto font variant in CSS - not working.

font-family: 'sans-serif-condensed'

I tried 'Roboto-Black' - not working also.

If I set the font-family to a font name that's in my /app/fonts folder - that works.

Upvotes: 0

Views: 1031

Answers (1)

Nick Iliev
Nick Iliev

Reputation: 9670

To apply font variant use either css properties like font-weight (bold, normal) and font-style (italic, normal) or provide the different font variants usually created by the authors of the fonts in separate font files. With Roboto you have 12 different made font variants like Roboto-Bold, Roboto-THin, Roboto-Medium and others. You can use them with the file name as you mentioned in your post. e.g. app.css

.rb-black {
    font-family: "Roboto-Black"
}

.rb-black-italic {
    font-family: "Roboto-BlackItalic"
}

.rb-bold {
    font-family: "Roboto-Bold"
}

.rb-medium {
    font-family: "Roboto-Medium"
}

Will produce the following results:

enter image description here

Sample project can be found here

font-family in NativeScript supports three generic families as follows:

serif (ex. Times New Roman)
sans-serif (ex. Helvetica)
monospace (ex. Courier New)

So using sans-serif-condensed won't produce the expected results.

Upvotes: 1

Related Questions