Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between fontFamily and typeFace in android?

Tags:

android

What is the difference between fontFamily and typeFace in android ? Of course, I read all the description in android developer site, but I'm not clear yet.

According to the general meaning of two words, it should be same meaning. But in the android xml properties(textview...), it has both properties. That makes me very confused.

As far as I know.... fontFamily and typeFace is a group of same-look of fonts.(Roboto, Arial) Font is a specific one of fontFamily.(Roboto-18pt-Bold, Arial-10pt-Italic)

What am I missing ?

like image 609
myoldgrandpa Avatar asked Aug 18 '15 14:08

myoldgrandpa


People also ask

What is difference between font and typeface?

A typeface is a particular set of glyphs or sorts (an alphabet and its corresponding accessories such as numerals and punctuation) that share a common design. For example, Helvetica is a well known typeface. A font is a particular set of glyphs within a typeface.

Which typeface is used in Android?

SANS_SERIF. The NORMAL style of the default sans serif typeface.

What a typeface means?

A typeface is the design of lettering that can include variations in size, weight (e.g. bold), slope (e.g. italic), width (e.g. condensed), and so on. Each of these variations of the typeface is a font.

What is another name for typeface?

You can think of typeface as another term for font (the two words are often used interchangeably), although it's more accurate to call a typeface a "font family," a group of fonts with similar designs. Typefaces have official names like Comic Sans, Garamond, and Helvetica.


Video Answer


1 Answers

To find the answer of your question you have to look into the source code of TextView, you will find its implementation here

https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/java/android/widget/TextView.java

Now from the implementation of method setTypefaceFromAttrs() it seems like, If you have set fontFamily attribute then typeface attribute will be ignored.

Also android:typeface attribute is added in api level 1 and using this you can set following fonts

- normal
- serif
- sans
- monospace

Whereas android:fontFamily attribute is added in api level 16 and this supports more fonts from roboto font family like -

- serif
- monospace
- sans-serif
- sans-serif-condensed
- serif-monospace
- sans-serif-smallcaps

For more information use below link

Valid values for android:fontFamily and what they map to?

like image 172
shivam Avatar answered Sep 28 '22 19:09

shivam