Are Roboto and Roboto Bold guaranteed to be available on 4.0+? - android

In our application, we're using Roboto and Roboto Bold. However, in some versions of Android (seems to be 4.0 to 4.1) we have issues with text rendering when using the imported version of Roboto (i.e. using Typeface.createFromAsset()) that do not appear when simply using the built-in version of Roboto (i.e. Typeface.DEFAULT).
I know that Roboto and Roboto Bold were introduced in Android 4.0, but I can't seem to find anything that guarantees that these fonts are available regardless of manufacturer modification (e.g. Touchwiz, Sense). If they are guaranteed to exist, we can just use a version check to only use the custom import for devices lower than Android 4.0.

EDIT: With some experimentation, particularly with the Galaxy S3 that allows a user to change their font, this is what I've discovered:
Using Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL) will return that CUSTOM typeface, rather than the system default sans-serif font (i.e. Roboto)
Instead, use Typeface.create("sans-serif", Typeface.NORMAL) (or BOLD) and it will return Roboto regardless of the user's font customization. From the list below, you can actually use "helvetica", "tahoma", "verdana", or "arial" above instead of "sans-serif" with the same result.
I found a document called system_fonts.xml that seems to confirm that Roboto will be used for any reference to Typeface.SANS_SERIF in the SDK directory under:
platforms > android-14 > data > fonts
<!--
System Fonts
This file lists the font families that will be used by default for all supported glyphs.
Each entry consists of a family, various names that are supported by that family, and
up to four font files. The font files are listed in the order of the styles which they
support: regular, bold, italic and bold-italic. If less than four styles are listed, then
the styles with no associated font file will be supported by the other font files listed.
The first family is also the default font, which handles font request that have not specified
specific font names.
Any glyph that is not handled by the system fonts will cause a search of the fallback fonts.
The default fallback fonts are specified in the file /system/etc/fallback_fonts.xml, and there
is an optional file which may be supplied by vendors to specify other fallback fonts to use
in /vendor/etc/fallback_fonts.xml.
-->
<familyset>
<family>
<nameset>
<name>sans-serif</name>
<name>arial</name>
<name>helvetica</name>
<name>tahoma</name>
<name>verdana</name>
</nameset>
<fileset>
<file>Roboto-Regular.ttf</file>
<file>Roboto-Bold.ttf</file>
<file>Roboto-Italic.ttf</file>
<file>Roboto-BoldItalic.ttf</file>
</fileset>
</family>
Since the vendor fonts must be placed in fallback_fonts.xml and the system fonts will always be prioritized, and the first family listed is Roboto under the aliases of sans-serif, aria, helvetica, tahoma, or verdana, unless I find out otherwise I think it's safe to assume that Roboto will be the font returned for a call to Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL).
I'm still going to leave this open for now, hoping for a definitive answer, as I'm unsure whether an OEM is allowed to modify system_fonts.xml. If they are, then this isn't really helpful at all.

In Section 3.8.5 of the Android 4.0 Compatibility Documentation it says:
3.8.5. Themes Android provides "themes" as a mechanism for applications to apply styles across an entire Activity or application.
Android 3.0 introduced a new "Holo" or "holographic" theme as a set of
defined styles for application developers to use if they want to match
the Holo theme look and feel as defined by the Android SDK [Resources,
24]. Device implementations MUST NOT alter any of the Holo theme
attributes exposed to applications [Resources, 25]. Android 4.0
introduces a new "Device Default" theme as a set of defined styles for
application developers to use if they want to match the look and feel
of the device theme as defined by the device implementer. Device
implementations MAY modify the DeviceDefault theme attributes exposed
to applications [Resources, 25].
AFAIK, the Roboto font set is part of the holo theme, and therefore is required to be present on any Android 4.0 and above device that has been certified by Google (i.e. runs Google Play).
The same requirement is also present in the 4.1 and 4.2 documents
(Search for Holo in the PDFs to find the section quickly. There's only 4 mentions of it)

Related

Fontconfig-like searching system font files on Android(native)

Is there any fontconfig-like way to search system font files on Android?
My game UI library provides a ttf font rendering. Someone just specify at least "human-readable" name, italic flag and font weight. The only way I found is just hardcode paths to system fonts in code, but it does not reliable and can't consider weight and italic parameters.
Maybe there is a file, which I can parse and get system font names from it?
On Linux I use fontconfig, I can use it on Android too, but I don't want to have completely useless megabytes in APK.
You can now query Google Fonts API, with the latest Support Library. It's not exactly what you're looking for, but maybe you'd like to consider this approach.

UI from Livecode is not the Same as on Android

I created a livecode project. I designed my UI by changing colors and fonts.
After creating that app, I deploy it to an android installer file (.apk file). When I launch the application to my android device, the UI from android device is not exactly the same as in the livecode. The text from the labels and buttons are getting too close which is annoying.
If you're not including a font in your APK file, chances are that Android chooses a font different from the font chosen by iOS. Either set the textFont of the field to a font that is available on both platforms or include your own font. If you include a font with the standalone and make sure that it is located next to the engine file, the font will be available. You can check that a font is available by using the fontNames:
put ("Font Name" is among the lines of the fontNames) into myFontAvailable
The default textFont of a field is empty, which means that it is inherited from the stack. If the textFont of a stack is empty, the system font is used. On Windows, the system font is Segoe UI, on Mac OS X it is a different font. On Android and iOS, the system font is different again. If you want the font to be the same on all platforms, you have to set the textFont of the stack (or field) to a font name that is available on all platforms or include your own font.

Custom fonts in Android API below 16?

Im working on my first Android application bigger than one activity.
I've read this:
Android 4.1 adds several more variants of the Roboto font style for a
total of 10 variants, and they're all usable by apps. Your apps now
have access to the full set of both light and condensed variants.
(here: link)
I also read somewhere, that I can use custom TTF font.
Does it mean, that Android API below 4.1 (API 16) cannot support custom fonts?
Do I have to work on API 16 or above? I have 4.0.4 phone for now, I don't want to throw it away yet...
Don't throw away your phone! You certainly can use custom fonts below API level 16.
First add your font (ttf file) to your /assets folder, then do something like:
Typeface typeface = Typeface.createFromAsset(getAssets(), "myfont.ttf");
myTextView.setTypeface(typeface);
http://developer.android.com/reference/android/widget/TextView.html#setTypeface(android.graphics.Typeface)
It has been around since API level 1.
The fonts in your question can be used without having to include any font file - they are not "custom" but built into the platform and available for all to use.

Android sans-serif font

I realised recently that the Android Browser doesn't have any of the fonts I have in my font stack as a Times Replacement with the help from http://www.codestyle.org/css/font-family/index.shtml.
"Times New Roman",Times,FreeSerif,"DejaVu Serif",serif
I'm not angry about it, because it looks nice. But I want to know what is the font's name so that I can include it into my font stack.
You don’t need to add a name, since the Android browser checks your current list, notices that none of the specific names matches, and uses serif, which is mapped to the browser’s serif font. Similarly for the Android sans-serif font (which is what your heading refers to...), use just the generic name sans-serif.
Oddly enough, the often-advertised name Droid Serif does not work. It is just yet another unrecognized name to the Android browser. See e.g. the question Using CSS font-family to select Droid fonts not working on Android (the question is more useful than the comments and answers).
The original Android font was "Droid" (Serif version is "Droid Serif"): http://en.wikipedia.org/wiki/Droid_(font)
The font in the newer devices is "Roboto", though I'm not sure if it has a serif version.

How does the Apple color emoji font work, and is there an Android version?

I saw that on iPhone there is a truetype font called Apple Color Emoji. It contains the emoticons that exist on iPhones which can be used in any application.
I wonder:
How is this font displayed in multicolor?! Truetype fonts can only include black and white glyphs.
Can this font, or one like it, be used on Android phones?
Apple is using a proprietary extension to the OpenType standard. Basically, they just store pre-rasterized color PNGs in a proprietary extension "block" within the TTF file (reference, corroboration).
The only reason this works is because they also provide the full stack between that font extension and the screen (font rasterization, system graphics library, text rendering widgets). There's no standardized way to accomplish this across all platforms/libraries.
The font uses embedded PNGs and they are stored in a sbix table.
Apple Color Emoji cannot be used in Android, but a Google CBLC/CBDT formatted font can.
There are four methods for implementing color in Open Type fonts right now:
Apple's SBIX - Embedded PNGs
Google's CBLC+CBDT - Embedded PNGs
Microsoft's COLR+CPAL - Colored glyphs
Adobe/Mozilla/W3C's SVG+CPAL - SVG in OpenType
The complete list of OpenType tables.
You can disassemble/reassemble the font using ttx from FontTools(pypi, github) for more details.

Categories

Resources