History log of /frameworks/base/graphics/java/android/graphics/Typeface.java
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ffae6c7f71e9da9f887002994d270b9dbf6d0673 27-May-2017 Seigo Nonaka <nona@google.com> Fix NPE and wrong behavior of Typeface.isSupportedAxes

The Typeface kept by Paint object can be null if nobody calls
setTypeface. The null typeface is equivalent to the Typeface.DEFAULT.
To check whether the passed axis is usable for Typeface.DEFAULT, we
need to pass Typeface.DEFAULT to isSupportedAxes if no typeface was set
on the Paint.

At the same time this CL fixes an issue in isSupportedAxes.
If the requested axis is listed in the first element of axes list,
isSupportedAxes returned false due to wrong handling of binarySearch
result.

Bug: 62146672
Bug: 62147012
Test: am instrument -w -e class android.graphics.cts.PaintTest
android.graphics.cts/android.support.test.runner.AndroidJUnitRunner

Change-Id: I7c154adfe8a19d6ed24ad645df7c10cee7880461
/frameworks/base/graphics/java/android/graphics/Typeface.java
373b15bda93c8b400c5e1271bc93cbef26af503f 02-May-2017 Seigo Nonaka <nona@google.com> Fix double bolding

resolveStyle increases minikinStyle's weight value based on Skia's style
value. Since we compute Skia's style based on given weight value, we
should not add extra bold weight to minikinStyle.

This CL also fixes misunderstanding of base weight.
The base weight is only used for computing weight relative to the
weighted alias. Thus, base weight should not be updated except for
createWeightAlias method.

To be clear, this CL changes the function names but keeps the same
semantics as before.

Test: adb shell /data/nativetest/hwui_unit_tests/hwui_unit_tests
Test: am instrument -w -e class android.graphics.cts.TypefaceTest\
android.graphics.cts/android.support.test.runner.AndroidJUnitRunner
Bug: 37880319
Merged-In: Ied73189b11792fb062da46f45afd2db664e6ecb4

Change-Id: I82350a1bfb99ce198b955f127949e21bccccb1cb
/frameworks/base/graphics/java/android/graphics/Typeface.java
a5fa9e8a63e5764244b709f37bc4a54d2bb96890 05-May-2017 Seigo Nonaka <nona@google.com> Resolve styles by font table if not specified.

android:fontStyle and android:fontWeight is an optional attribute.
If they are missing, we are using non-italic 400 weight, but this is
not good idea. We should resolve these style value from font metadata.

Bug: 37988154
Test: am instrument -w -e class android.content.res.cts.ResourcesTest
android.content.cts/android.support.test.runner.AndroidJUnitRunner

Change-Id: I80a436cd3632d8c58fa3d8bdaedac73b95f61a8c
/frameworks/base/graphics/java/android/graphics/Typeface.java
5e0aed49a874b32b135bbd8da620357764b69ad4 01-May-2017 Seigo Nonaka <nona@google.com> Fix NPE happens if no source was specified to font element.

This also fixes unexpected fallback to the old implemntation by calling
allowUnsupportedFont() which is only for backward compatibility.

This CL also remove getResourceId() method. Nobody uses this method.

Bug: 37865521
Bug: 37844248
Test: am instrument -w -e class android.content.res.cts.ResourcesTest\
android.content.cts/android.support.test.runner.AndroidJUnitRunner
Change-Id: I987448add728c53c916f24a2ea8f337be417248f
/frameworks/base/graphics/java/android/graphics/Typeface.java
0f07dd5b14e76695bbae758e948e00b86935232c 28-Apr-2017 Seigo Nonaka <nona@google.com> Remove FontVariationAxis.InvalidFormatException.

Use IllegalArgumentException instead.

Bug: 37769084
Bug: 37765945
Test: am instrument -w -e class android.widget.cts.TextViewTest
android.widget.cts/android.support.test.runner.AndroidJUnitRunner
Test: am instrument -w -e class android.graphics.cts.TypefaceTest
android.graphics.cts/android.support.test.runner.AndroidJUnitRunner
Test: am instrument -w -e class android.graphics.cts.PaintTest
android.graphics.cts/android.support.test.runner.AndroidJUnitRunner
Test: am instrument -w -e class android.graphics.cts.FontVariationAxisTest
android.graphics.cts/android.support.test.runner.AndroidJUnitRunner
Test: am instrument -w -e class android.text.VariationParserTest
com.android.frameworks.coretests/\
android.support.test.runner.AndroidJUnitRunner

Change-Id: I50b70e3e7e37585c937dcce2416a83353de62a5d
/frameworks/base/graphics/java/android/graphics/Typeface.java
080b054bddee55428943b821c99887543d1fd290 26-Apr-2017 Seigo Nonaka <nona@google.com> Font API clean up

- Move FontRequest from android.graphics.fonts to android.provider since
this is only used by android.provider.FontsContract and never draw
anything.
- FontRequest is no longer being Parcelable.
- Remove FontSpec.aidl which is not necessary.

Bug: 37326126
Test: am instrument -w -e class android.provider.FontsContractTest
com.android.frameworks.coretests/\
android.support.test.runner.AndroidJUnitRunner
Test: am instrument -w -e class android.provider.cts.FontProviderTest
android.provider.cts/android.support.test.runner.AndroidJUnitRunner
Test: am instrument -w -e class android.provider.cts.FontRequestTest
android.provider.cts/android.support.test.runner.AndroidJUnitRunner

Change-Id: I0eb501844247c2f07eaa1fc7a71f72e404888b5b
/frameworks/base/graphics/java/android/graphics/Typeface.java
d9de8be233d18ccc881cb647a5de2b32ff3e737c 26-Apr-2017 Seigo Nonaka <nona@google.com> Load font file from remote provider synchronously.

Since CancellationSignal is not guaranteed to be handled by remote
process, introduce threaded font loading mechanism.
At the same time, this fixes possible NPE issue in openFont.

Bug: 37552479
Test: am instrument -w -e class android.provider.FontsContractE2ETest
com.android.frameworks.coretests/\
android.support.test.runner.AndroidJUnitRunner

Change-Id: Ie235c5a57bd172b0882da5aa27a990d7c6686ff2
/frameworks/base/graphics/java/android/graphics/Typeface.java
54084b64b1860b652b1c50ba942b4cfc7fb28805 24-Apr-2017 Seigo Nonaka <nona@google.com> Font provider cleaning ups.

- Remove Columns.STYLE
- Decouple Context from Typeface.
- Make FontsContract constructor private since it is essentially static.
- Removed unused constants.

Bug: 37281200
Bug: 37268410
Test: am instrument -w -e class android.provider.FontsContractE2ETest
com.android.frameworks.coretests/\
android.support.test.runner.AndroidJUnitRunner
Test: am instrument -w -e class android.provider.FontsContractTest
com.android.frameworks.coretests/\
android.support.test.runner.AndroidJUnitRunner
Test: am instrument -w -e class android.graphics.cts.TypefaceTest
android.graphics.cts/android.support.test.runner.AndroidJUnitRunner
Change-Id: Ic46c256141d27ca28f30023bcc40f4e1161d5338
/frameworks/base/graphics/java/android/graphics/Typeface.java
5a09c64345ba35783b5d24ed7c4ca0ea8afbcc0a 20-Apr-2017 Seigo Nonaka <nona@google.com> Remove Typeface.create

Test: Manually done
Bug: 37514611
Bug: 37463988
Bug: 37281200
Change-Id: Ida704af910e0ae195b96803de506fa1e1d66c9f5
/frameworks/base/graphics/java/android/graphics/Typeface.java
337be5a12fd6ef76f78da70cc1e83233788156dd 21-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Update Typeface callback docs about error codes" into oc-dev
5706a1b12dd891098fb7bf479623d42979171144 12-Apr-2017 Clara Bayarri <clarabayarri@google.com> Update Typeface callback docs about error codes

As requested by API council, mention that the provider may
return its own error codes within the positive int range.

Bug: 37084803
Test: none
Change-Id: Ia8ee99432cc5025a12d43049e327605095dd2b57
/frameworks/base/graphics/java/android/graphics/Typeface.java
f3157e1692349d85ed6e7a3908b350fbcaeb176c 19-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add comment to Typeface.Builder about file descriptor." into oc-dev
83ba4f9a04833409080d97480a665e029ee71365 14-Apr-2017 Seigo Nonaka <nona@google.com> Add comment to Typeface.Builder about file descriptor.

Add comment to Typeface.Builder about the responsibility of closing
file descriptor.

Bug: 37082657
Test: N/A
Change-Id: Id33b15895d75ad6693f3ad6231f1ba0c2cec9f79
/frameworks/base/graphics/java/android/graphics/Typeface.java
5f9fde884b479645cb0d977c3a8fd8dd06f25e72 15-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Fix boot loop issue on Android Wear." into oc-dev
bf629ed08077e59877158a30cc04711319bce977 14-Apr-2017 Seigo Nonaka <nona@google.com> Fix boot loop issue on Android Wear.

The boot loop was seen after I65e220aca823fd815a52437b11c8e6dc952de8e2
but only on Android Wear. On Android Wear, some font files are missing
but are listed in fonts.xml. Before that patch, we created a Typeface
object with an empty FontFamily even if there was no valid font entry
in font-family tag. However, after that patch, FontFamily stopped
creating native objects and holds a null pointer instead. As the
result, SIGSEGV happens.

The right fix is skipping Typeface creation if native code failed to
create the font family object.

Since Typeface.init cannot be called twice, this is hard to test
automatically.

Bug: 37328609
Bug: 37326002
Test: Boot succeeded even after removing CutiveMono.ttf from system.

Change-Id: I125de07343252784986d728c3bbaa46b24ace601
/frameworks/base/graphics/java/android/graphics/Typeface.java
d154829cb15d61f1469f939d608e691256e2a765 12-Apr-2017 Seigo Nonaka <nona@google.com> Use provided style for fallback font selection

If the developer gives some weight/italic to the Typeface.Builder
the fallback used the metadata in the font file. We should use
provided data instead.

This CL also adjusts upper and lower limits on weight, from 100..900 to
1..1000

Bug: 37257745
Bug: 37251569
Test: android.graphics.cts.TypefaceTest passes
Change-Id: I7cf390d96b49afcce359928373698b0c9a9babd8
/frameworks/base/graphics/java/android/graphics/Typeface.java
729a515e5ebcf38e3472bb8fee4e9400745c400c 13-Apr-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Introduce setFallbackTypeface" into oc-dev
5b6347a6af668ba47b3fab14cefbe03cc440c3a4 31-Mar-2017 Seigo Nonaka <nona@google.com> Introduce setFallbackTypeface

setFallbackTypeface is returned by Builder.build() method when the
provided font is not loaded due to some reasons.
The fallback family is resolved with width/italic passed to Builder.

Bug: 36794225
Test: android.graphics.cts.TypefaceTest passes
Change-Id: I65e220aca823fd815a52437b11c8e6dc952de8e2
/frameworks/base/graphics/java/android/graphics/Typeface.java
0b73a4287e8f630c45bf7ef0a7e0b2541d6b4067 12-Apr-2017 Seigo Nonaka <nona@google.com> Introduce FontsContract.requestFont and deprecate Typeface.create

Since background fetch should be synchronized with life cycle of
Activities, so should not create new background thread inside this
method. Not to break existing apps, mark as deprecated and will be
removed from public API untile next release.

New API accepts Handler so that the developer can pass their own thread
.

Test: TBD
Bug: 37253785
Change-Id: I87fdc6a354a829db679253824f42489f25698fa0
/frameworks/base/graphics/java/android/graphics/Typeface.java
69754bf66dae9d047d5a0ff2c71820aa35b9cc70 05-Apr-2017 Seigo Nonaka <nona@google.com> Introduce FontsContract.fetchFonts and expose URI for watching.

FontsContract.fetchFonts provides a low level font access with fonts
provider.
This CL also includes:
- Introduce new class FontFamilyResult/Font as the inner static class
of FontsContract which are used to for result value of fetchFont..
- Introduce a functionality to FontsContract to be able to create
Typeface from an array of FontResult.
- Expose URI of each file entries to be able to register ContentObserver

Bug: 36494487
Bug: 36085028
Test: android.provider.FontsContract passes
Test: android.graphics.cts.TypefaceTest passes
Test: android.graphics.fonts.cts.FontResultTest passes

Change-Id: Id6f85039d0e86be063ef099d7ec6bfd97e4424c5
/frameworks/base/graphics/java/android/graphics/Typeface.java
5421e810233ecadf0ebc7d7760dc9ac07a141e6c 11-Apr-2017 Seigo Nonaka <nona@google.com> Update Typeface.Builder API to reflect API feedback.

- Stop pooling and remove reset method.
- Introduce overloaded constructors instead of setSource methods.
- Make italic parameter boolean and treat "not called" as
RESOLVE_BY_FONT_TABLE.
- Remove constants and move them to Typeface with private static
constant.
- Fix JavaDoc.

Bug: 37082657
Test: android.graphics.cts.TypefaceTest passed
Change-Id: I0c50cf3e2d50c0021f7e12bbb7ed7ae89fa1c2a1
/frameworks/base/graphics/java/android/graphics/Typeface.java
fe04aa840e0682e9813e1ac4958772f898eb02ca 02-Apr-2017 Seigo Nonaka <nona@google.com> Pass weight/italic pair instead of style.

Typeface.NORMAL/BOLD/ITALIC/ITALIC_BOLD is used for specifying relative
from current Typeface. For example

Typeface face = Typeface.create("serif");
Typeface thickerFace = Typeface.create(face, Typeface.BOLD);
Typeface moreThickerFace = Typeface.create(tickerFace, Typface.BOLD);

For the purpose of providing font information, we should use weight/italic
value instead of style in Typeface.
The Columns.STYLE field was kept for preventing runtime crash of demo
apps.

Test: Manually
Change-Id: I732e8ee04a66f61321fc0a98dbfb8fdc0a4dd7a4
/frameworks/base/graphics/java/android/graphics/Typeface.java
ff55115121a7a2753ba2265cb3201a3a14c0874d 29-Mar-2017 Seigo Nonaka <nona@google.com> Reorganize font enumeration API.

This CL cleans up APIs around font variation settings.
- Remove FontConfig and FontManager public API.
- Remove FontManagerService from system service.
- Extract inner class FontConfig.Axis as top-level class FontVariationAxis.
This is used by Typeface.Builder public API to create new Typeface.
- Introduce and expose FontVariationAxis utility functions from/to string.
- Throws if the invalid font variation settings is passed.

Test: android.text.cts.FontVariationAxisTest passes
Test: android.graphics.cts.TypefaceTest passes
Test: android.graphics.cts.PaintTest passes
Change-Id: I9ccafe7a53935960566243e2856e166878ca59ae
/frameworks/base/graphics/java/android/graphics/Typeface.java
c0cf4f09f4c520b2aaafbe8a0cb0feb530c2e021 28-Mar-2017 Seigo Nonaka <nona@google.com> Do not use many FDs in FontManagerService.

Currently there are over 170 font files are installed in system directory.
Opening 170+ files and keep them is not unacceptable. Pass URI instead.

At the same time, this CL hides full font path from FontConfig since
/system/fonts directory will be deprecated in future.

Bug: 36660849
Test: android.text.cts.FontManagerTest passed
Change-Id: I1d216dc9c6dec702a4ce3b946bfda6dcbe12b7fe
(cherry picked from commit 455f1bfc05bf972ee4fe8cd5fa135ed232126bb7)
/frameworks/base/graphics/java/android/graphics/Typeface.java
a4ab320e0a97f0ac8a336a1990248bfa33232611 23-Mar-2017 Seigo Nonaka <nona@google.com> Use variation settings for Typeface creation.

Bug: 35416390
Test: android.graphics.cts.TypefaceTest passed
Change-Id: Ieefa2cf095fb1031d3c7ac99fd59710311d7ede3
/frameworks/base/graphics/java/android/graphics/Typeface.java
c34f786677b08edf6813926d211d22351a7dfd4b 22-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Unhide Typeface construction APIs."
fb483cc90c27a9c0fcafa28343a8fd644f8384a4 21-Feb-2017 Clara Bayarri <clarabayarri@google.com> XML Support for non system font providers

The certs needed to identify non preinstalled providers
can now be declared in XML, using a resources array.

Test: runtest --path frameworks/base/core/tests/coretests/src/android/provider/FontsContractTest.java
runtest --path frameworks/base/core/tests/coretests/src/android/content/res/FontResourcesParserTest.java
Bug: 35025705
Change-Id: Ibf12ad409aa5a873ddb32b1383c147728e664c23
/frameworks/base/graphics/java/android/graphics/Typeface.java
b2c20d880dea55f5657be08859950fc8eea96708 22-Mar-2017 Seigo Nonaka <nona@google.com> Unhide Typeface construction APIs.

These APIs are necessary to construct Typeface from various combination
TTC index, variation settings, etc.

Bug: 33062398
Test: android.graphics.cts.TypefaceTest passes
Change-Id: Ie069700ed4f67efbec55331bef867f94d58e2a61
/frameworks/base/graphics/java/android/graphics/Typeface.java
20e5d91739fb88a02afb4888bf9f938308bc9b7b 18-Jan-2017 Seigo Nonaka <nona@google.com> Expose Typeface creation APIs with ttc and font variation.

Introduce Builder class for creating Typeface from various
sources with optional TTC index and font variation settings.

Bug: 33062398
Test: Manually verified new Builder create Typeface.
Change-Id: Ia23ee6a73516707d854c7387fe75fbb22f80673d
/frameworks/base/graphics/java/android/graphics/Typeface.java
7d50ff11db4911788722f24646d1a8ce2e8b0a87 20-Mar-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Notify caller if none of settings are effective."
c4a6d29ac6d8e7652c599c495ea83844e118119f 16-Mar-2017 Clara Bayarri <clarabayarri@google.com> Merge "Provide ApplicationContext to Typeface for font requests"
0763650a13dd1968f45e8e64950a32c6b508ce28 10-Mar-2017 Seigo Nonaka <nona@google.com> Notify caller if none of settings are effective.

Now setFontVariationSettings returns false if the given settings is not
effective.

Bug:35764323
Test: ran TextViewTest and PaintTest in cts
Change-Id: Ic31d9e47ec006c8e7bb2c907ff0ea2936bd71d01
/frameworks/base/graphics/java/android/graphics/Typeface.java
ff221613ec1c328489a303491e1aa88850e4a273 15-Mar-2017 Clara Bayarri <clarabayarri@google.com> Provide ApplicationContext to Typeface for font requests

We were using a generic context that caused crashes for
the content providers.

Bug: 34657204
Test: manual, calling getCallingPackage() from the provider
doesn't crash anymore.

Change-Id: I2b61e6510d8c6647007987373d03ee5dc97c0889
/frameworks/base/graphics/java/android/graphics/Typeface.java
ac873c9f25d2a687c9195226b9d680f51c91fa30 08-Mar-2017 Seigo Nonaka <nona@google.com> Clean up public FontConfig APIs

This CL contains following clean up:

- Hide unnecessary constructors.
- Change List<XX> to XX[] since actually all fields are immutable.
- Change font's variant type from String to int.
- Decouple resource related members to FontResourcesParser.
- Add NonNull/Nullable to all fields.

Test: ran android.content.res.FontResourcesParserTest

Change-Id: If456266ffff86d41342572a19662cc8f3cd13181
/frameworks/base/graphics/java/android/graphics/Typeface.java
bacf2352ab892724551431551ae973ae3b68db35 10-Feb-2017 Clara Bayarri <clarabayarri@google.com> Allow Font providers to return status codes

This was requested by the current users, need to state
that a font is unavailable (needs downloading) or that
the query is unsupported.

Also add tests :)

Test: runtest --path frameworks/base/core/tests/coretests/src/android/provider/FontsContractTest.java
Also CTS attached to topic
Bug: 35097775
Change-Id: Ib15bf4c70185d81a4c20426722eb44c4210771c2
/frameworks/base/graphics/java/android/graphics/Typeface.java
3c4be77db95ea716889568bde853be082e764da9 07-Feb-2017 Clara Bayarri <clarabayarri@google.com> Support non-system Font Providers

To do this, the developer must specify the set of certificate
hashes that represent the authority's app. This allows us to
verify that the authority we find is indeed the one intended
by the developer.

Bug: 35025705
Test: runtest --path frameworks/base/core/tests/coretests/src/android/provider/FontsContractTest.java
runtest --path frameworks/base/core/tests/coretests/src/android/content/res/FontResourcesParserTest.java
CTS attached to topic
Change-Id: I605f9a93bbca8705936ead08efb4a5b4fdcc4882
/frameworks/base/graphics/java/android/graphics/Typeface.java
b44abf290190ceee037f24c47493a34de45fa3f4 16-Feb-2017 Clara Bayarri <clarabayarri@google.com> Use weight & style data for fonts from xml source

Bug: 34916944
Test: manual tests
Change-Id: I1d6e1c4c52859c5e9d7a8b0a247e4d0581935833
/frameworks/base/graphics/java/android/graphics/Typeface.java
4b5a4d221f377686a730182a3bffb8c6f190e313 27-Jan-2017 Clara Bayarri <clarabayarri@google.com> Declarative downloadable fonts

Implement support for downloadable font requests in xml. Given the
xml fonts feature in O, this adds support to not only declare
local font files as font resources, but also Downloadable fonts
from a fonts provider.

A provider returns a font family (of one or more files) given a
query, so the new attributes are added to the font-family tag.

Additionally, add support to pre-declare downloadable font resources
in the Android Manifest. These will then be fetched at app startup
time so they are available to use from the Typeface cache asap.

When retrieving downloadable fonts via resources, the cache is
checked to see if the font is already there and is used, otherwise
a request is sent to the provider and the default font is returned
as we need a result synchronously.

To do this, the developer declares an additional fonts xml resource
file with the list of fonts to preload and links it in the manifest
with a meta-data tag.

E.g.:

res/font/mydownloadedfont.xml

<font-family xmlns:android="http://schemas.android.com/apk/res/android"
android:fontProviderAuthority="com.example.test.fontprovider"
android:fontProviderQuery="myrequestedfont">
</font-family>

res/font/preloaded_fonts.xml

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font android:font="@font/mydownloadedfont" />
</font-family>

and in the AndroidManifest.xml

<meta-data android:name="preloaded_fonts"
android:resource="@font/preloaded_fonts" />

Bug: 34660500, 34658116
Test: WIP, need to add more
Change-Id: I1d92555e115e241bf23b59e6f5c6cca6c7361de7
/frameworks/base/graphics/java/android/graphics/Typeface.java
b12397e57e79c5dd9e8b2cb3839f5cd30b5d515f 27-Jan-2017 Clara Bayarri <clarabayarri@google.com> Cache Downloaded Fonts in Typeface

If the requested Typeface is already loaded into memory, return
from the cache.

Test: none, optimization
Change-Id: I32422c47c68502ba83b7d976f6e05f70dda5daed
/frameworks/base/graphics/java/android/graphics/Typeface.java
cf45c852977e5f68a0d67fca01f03b11c09e32ba 31-Jan-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Introduce set/getFontVariationSettings."
9ff994d98846d24bc488939af6e7dc440149a4bc 30-Nov-2016 Seigo Nonaka <nona@google.com> Introduce set/getFontVariationSettings.

This is 2nd attempt of I249d464f8cdaa56017a987588b94ed685aadeb58.
The original CL was reverted due to conflicting with another CL submitted
before.
Nothing has changed except for following class name changes.

Here is the original commit message of reverted change.

This CL enables developers to specify axis values to the underlying
font collection. The specification of the font variation settings is
the same as the CSS font-variation-settings attribute in CSS working
draft as of 2016-11-30.

Code example: Here is an example to set width 100 and weight 1.5.

TextView tv = (TextView) findViewById(R.id.textView);
tv.setFontVariationSettings("'wdth' 100, 'wght' 1.5");

Bug: 33062398
Test: Manually done. Ran FrameworksGraphicsTests, CtsGraphicsTestCases
and CtsWidgetTestCases

Change-Id: I9cdfbdecc87c995d805096883ef2652768c6c21e
/frameworks/base/graphics/java/android/graphics/Typeface.java
fe98ad919bebaf41191b7fdf0a1d841198d4f46a 30-Jan-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Implement .xml font resource support"
ed00bfdfae5d5cbc9e13f4e8affdece48f4c5b7f 20-Jan-2017 Clara Bayarri <clarabayarri@google.com> Implement .xml font resource support

This change implements the loading and parsing
of xml type font resources, and makes sure it is
used properly by TextView styles.

Test: run cts -m CtsContentTestCases -t android.content.res.cts.ResourcesTest
run cts -m CtsWidgetTestCases -t android.widget.cts.TextViewTest#testFontResources*

Change-Id: I5a2930b3ba7dad67d9607e9036a5dde6bab0c5a4
/frameworks/base/graphics/java/android/graphics/Typeface.java
c65ea181da71fab4d911da010c7413492104df4d 25-Jan-2017 Seigo Nonaka <nona@google.com> Fix crash with FontProvider

Need to freeze the FontFamily otherwise the FontFamily is not created.

Test: manually done
Change-Id: I81a6f0d295f13bbeb059deafb4283654f97c0090
/frameworks/base/graphics/java/android/graphics/Typeface.java
68eb1ac342f30b77b6fdba98e67559c4858e3f74 25-Jan-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Follow minikin::FontFamily constructor signature change."
b0812a30499376e09e2deb5995e998c629f24985 20-Oct-2016 Clara Bayarri <clarabayarri@google.com> Introduce Fonts Content Provider

This change exposes to developers the ability to request fonts
from a provider via Typeface.

Until further security is implemented, only system apps can
provide fonts.

Test: See topic for CTS change
Change-Id: Ic7d5e2648340ee561f4d4c2d73a673748d2af076
/frameworks/base/graphics/java/android/graphics/Typeface.java
8b48e624457e438fcc2b6b9363329036ef2f7743 07-Jan-2017 Seigo Nonaka <nona@google.com> Follow minikin::FontFamily constructor signature change.

This is 2nd attempt of Id10ca97f6f6f5bbe4999c1ad2736423a204d6e87.
The root caus of crash is due touching null pointer in nUnrefFamily.
After above change, native object may not be created on error case.
In that case, nUnrefFamily can not be called. In addition to this issue
there is also memory leak on error case. This fixes it by introducing
abortCreation method.

Also this contains fix of layout lib breakage done by jgaillard@.
Originally submitted by Ic8872a43993bcb0a157c5e3f0ce423af9b47f606

Here is original commit message of reverted change.

minikin::FontFamily no longer has addFont function, instead it accept
vector of Fonts in its constructor. To follow this signature change,
holding minikin::Font instance in native and build minikin::FontFamily
instance in FontFamily.freeze() method.

Bug: 34042446
Bug: 28119474
Bug: 34378805
Test: hwui test has passed
Test: m layoutlib layoutlib-tests
Change-Id: Ic34ebaa8191273d4c9f49c43124f15a1da5f7b78
/frameworks/base/graphics/java/android/graphics/Typeface.java
4a65687b853a92268f4f0eb52f22e092b16f8ed3 23-Jan-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Expose fonts.xml via public API with a service"
04d72abde1efc963ebb2f145f859552e83b92d13 10-Jan-2017 Clara Bayarri <clarabayarri@google.com> Expose fonts.xml via public API with a service

This change creates a new FontManagerService, in charge of providing
font management data. It exposes a public API to retrieve the
information in fonts.xml without accessing it directly. To do this,
it also refactors FontListParser's internal classes into a new public
FontConfig class holding all the font data.

getSystemFonts() returns all the available information in fonts.xml
as well as file descriptors for all the fonts. This allows us to
share the memory consumed by these files between all clients.

Bug: 34190490
Test: See attached CTS change in topic
Change-Id: I0e922f8bcc9a197a1988d04071eb485328d66fb7
/frameworks/base/graphics/java/android/graphics/Typeface.java
18e9f9f3778318918c44d944489cb50daaf45d1c 19-Dec-2016 Clara Bayarri <clarabayarri@google.com> Expose Resources.getFont

Based on the work already done in aapt2, load a Font from a
resource id.

Test: WIP
Change-Id: Idc06bfbfd16452a328bfcc6ea9dcfb723b633f0c
/frameworks/base/graphics/java/android/graphics/Typeface.java
c0d685b87aa544bc23c1ed1c01e88f6c04855f72 20-Jan-2017 Siyamed Sinir <siyamed@google.com> Revert "Follow minikin::FontFamily constructor signature change."

This reverts commit a0a4828614edfd633ab86f04408e7f4e55b491dd.

Bug: 34378805
Change-Id: Icbdbfbde2efe8eaebbe4334a679e3b3247057388
/frameworks/base/graphics/java/android/graphics/Typeface.java
a3b9f2e3c66ec485f3b712560d52e31632a9cbe8 20-Jan-2017 Siyamed Sinir <siyamed@google.com> Revert "Introduce set/getFontVariationSettings."

This reverts commit ba3028c1fc9fca2d45acc841557da2c9a83923bf.

Bug: 34378805
Change-Id: I8250c87af5d65fb45789632580be4ae1b8711372
/frameworks/base/graphics/java/android/graphics/Typeface.java
ba3028c1fc9fca2d45acc841557da2c9a83923bf 30-Nov-2016 Seigo Nonaka <nona@google.com> Introduce set/getFontVariationSettings.

This CL enables developers to specify axis values to the underlying
font collection. The specification of the font variation settings is
the same as the CSS font-variation-settings attribute in CSS working
draft as of 2016-11-30.

Code example: Here is an example to set width 100 and weight 1.5.

TextView tv = (TextView) findViewById(R.id.textView);
tv.setFontVariationSettings("'wdth' 100, 'wght' 1.5");

Bug: 33062398
Test: Manually done. Ran FrameworksGraphicsTests, CtsGraphicsTestCases
and CtsWidgetTestCases
Change-Id: I249d464f8cdaa56017a987588b94ed685aadeb58
/frameworks/base/graphics/java/android/graphics/Typeface.java
a0a4828614edfd633ab86f04408e7f4e55b491dd 07-Jan-2017 Seigo Nonaka <nona@google.com> Follow minikin::FontFamily constructor signature change.

minikin::FontFamily no longer has addFont function, instead it accept
vector of Fonts in its constructor. To follow this signature change,
holding minikin::Font instance in native and build minikin::FontFamily
instance in FontFamily.freeze() method.

Test: hwui test passed
Change-Id: Id10ca97f6f6f5bbe4999c1ad2736423a204d6e87
/frameworks/base/graphics/java/android/graphics/Typeface.java
5849500a193ac1327242e01d7f6912d0a384ffc9 08-Apr-2016 Siyamed Sinir <siyamed@google.com> Cache Typeface.createFromAsset objects.

Caches Typeface objects returned from Typeface.createFromAsset function,
Objects are cached in an LruCache with a max size of 16.

Bug: 27251075
Change-Id: I6baae4211a0d0d26422945bf1557b364cfe84b2b
/frameworks/base/graphics/java/android/graphics/Typeface.java
fb95699364e555148b437cfa1e5c69384f843845 28-Jan-2016 Ben Wagner <bungeman@google.com> Deduplicate font file mappings.

With ttc and gx variation fonts, it is now possible and common that a
number of fonts will use the same font file for data but with different
parameters. In the current code each font will map the font file data,
taking up an unecessary amount of virtual address space and is
inefficient with respect to memory management (like the tlb). This CL
deduplicates these file mappings so that a given font file will only be
mapped into memory once.

DO NOT MERGE
Change-Id: I5ca69f963a434c72ec4028402ecbf9e0f0ee7148
(cherry picked from commit fffcf0a31fd4c9a4ec8aa7de70b1eda0d48fb337)
/frameworks/base/graphics/java/android/graphics/Typeface.java
a87b07d7fafd59ae26073a80cd742b17ea427ecd 06-Nov-2015 Ben Wagner <bungeman@google.com> Add support for gx font variation axes.

This adds an 'axis' child element to the 'font' element. The 'axis'
element has attributes 'tag' (a four byte identifier) and 'stylevalue'
(a float value) to the parser. This also modifies reading the font file
name in a backwards compatible fashion by using only the direct #text
children of the 'font' element. (Both the Minikin and Skia parsers now
allow the font file name on a separate line in the fonts.xml file).

This information is then passed through to Skia in order to select the
desired variation. The Skia parser already parses this way and has for
some time, so Chrome and WebView can already read this format.

Change-Id: I15623fe864fa92b2bf0705af5e389daedfb77e5c
(cherry picked from commit b8e367fb7428076ff2e4aa2a97adaed1ef806e92)
/frameworks/base/graphics/java/android/graphics/Typeface.java
3fa667e22401bf3ba96957fe31167bf05d164c55 10-Dec-2015 Seigo Nonaka <nona@google.com> Introduce ttcIndex attribute into system font configuration.

ttcIndex is used for specifying index of the TrueType Collection.
No user visible change is expected with this CL.

BUG: 10861108
Change-Id: I76a1c890164bb55a7ece7b9c7db2ce2bac3f8b89
/frameworks/base/graphics/java/android/graphics/Typeface.java
ffa84e008c712ceffa09d6b89a49882c88b3cca5 12-Nov-2014 Hans Boehm <hboehm@google.com> Reduce risk of memory corruption due to finalization.

Many classes in graphics/java and elsewhere deallocate native memory
in a finalizer on the assumption that instance methods can no longer
be called once the finalizer has been called. This is incorrect if
the object can be used, possibly indirectly, from another finalizer,
possibly one in the application.

This is the initial installment of a patch to cause such post-finalization
uses to at least see a null pointer rather than causing memory corruption
by accessing deallocated native memory. This should make it possible to
identify and fix such finalization ordering issues.

There are more graphics classes that need this treatment, and probably
many more in other subsystems.

This solution is < 100% effective if finalizers can be invoked
concurrently. We currently promise that they aren't.

(In my opinion, the real cause here is a language spec bug. But that ship
has sailed.)

Bug: 18178237
Change-Id: I844cf1e0fbb190407389c4f8e8f072752cca6198
/frameworks/base/graphics/java/android/graphics/Typeface.java
117cbebe810613d4a6de034f02652cdbbfef4cde 25-Aug-2014 Raph Levien <raph@google.com> New weight-aware font config

Parse new fonts.xml config file, and resolve weight selection based on
the base weight of the font (as defined by a weight alias specified in
the config file) and the requested bold flag. This change improves the
appearance of bold spans for alternate weights of Roboto.

In addition, this patch enables weight selection for fallback fonts.
For example, if an additional font with a weight of 100 is added to the
Hebrew font family in the fallback list, then requesting
"sans-serif-thin" would select that font for Hebrew text.

Bug: 14538154
Change-Id: I99a04fad4f7bf01c75726e760d42735dd9003496
/frameworks/base/graphics/java/android/graphics/Typeface.java
bf8d5620f7f3be72ec217f4bcc14a417d4e1dee6 20-Aug-2014 Behdad Esfahbod <behdad@google.com> Throw exception on nonexistent font

In K, this used to throw RuntimeException. Before this patch, NULL
was returned and no exceptions thrown. With this patch,
FileNotFoundException is thrown. This might be considered API
change and be undesirable as callers need to either catch it or
declare it to be thrown.

Bug: 16180181
Change-Id: If83d76857f640c6293a3d5d08fb89ceddbaf41bc
/frameworks/base/graphics/java/android/graphics/Typeface.java
ff86bcd08827d1050a8cfd99b521c21848b3f364 11-Aug-2014 Raph Levien <raph@google.com> Resolve invalid Typeface style to default

Setting a textAppearance that specified a fontFamily but not a textStyle
results in a styleIndex of -1 being passed to the Typeface.create()
call. This patch resolves such invalid style indices to the default.

Fix for bug 16880318 "Applying TextAppearance To TextView with custom
font family incorrectly adds italics style on LMP"

Change-Id: I05c9cfc4d76161be21b58abdb4037c51a23cae37
/frameworks/base/graphics/java/android/graphics/Typeface.java
3660789f06c5fbcb81e6c7c79612048bff8f0f66 26-Jun-2014 Raph Levien <raph@google.com> Switch all text layout to Minikin

This patch switches all text layout operations to use Minikin, removes
the USE_MINIKIN #ifdef, and deletes some of the code that was only used
in the old TextLayout path (although some more refactoring remains).

Change-Id: I51b5c4e2bb46cfd9d204c12b9f16f135c769f5b5
/frameworks/base/graphics/java/android/graphics/Typeface.java
d573794d83a049fe59e289944f0cd77406dd776a 02-Jun-2014 Raph Levien <raph@google.com> Support fallbacks for custom typefaces (Minikin)

This patch adds the fallback font list to custom typefaces created from
files and assets, as well as those created by name. This is a fix for
the deskclock half of bug 15139067 "Centered text isn't working".

Change-Id: I0cc60951953dfb73817a98ddfee5713f0387ee90
/frameworks/base/graphics/java/android/graphics/Typeface.java
f9e3d311275c37fe5f2562993687a1627780a6d0 28-May-2014 Raph Levien <raph@google.com> Language and variant selection for Minikin

This is the frameworks/base side of what's needed to support language
selection (especially Han unification, but also compact/elegant
selection for scripts that require more vertical space).

This is part of the fix for bug 15179652 "Japanese font isn't shown on
LMP".

Change-Id: I8f0f3aa9a1915659f8d0b590cf1c56529356049a
/frameworks/base/graphics/java/android/graphics/Typeface.java
baef8c1ffe5c900fb0da9512654bf249b5fc9269 20-May-2014 Deepanshu Gupta <deepanshu@google.com> Layoutlib fixes for L [DO NOT MERGE]

This adds the new delegates that were missing. This starts the work on
changes related to Minikin Fonts.

There are some changes related to TypedArray that still need to be
fixed.

Change-Id: Ic2397b64aa3f1f48926e849b14689c47d9ee7f8c
(cherry picked from commit 7ca3612094270183243938e79337c84effea7ad0)
/frameworks/base/graphics/java/android/graphics/Typeface.java
363e21b4518d7059638df2821b8a0947f74eaf2c 09-May-2014 Raph Levien <raph@google.com> Add fallback fonts to system fonts (Minikin)

This patch explicitly keeps the list of fallback fonts, and creates
all system fonts including the fallback list as well. At present,
fonts created from assets or directly from files do not have the
fallback list present, so that remains to be done.

This patch affects only builds with USE_MINIKIN defined; otherwise
the fallback font processing in Skia will apply.

Change-Id: I6148e06a45a11f53a6bb2f04c8813df4968ea8c8
/frameworks/base/graphics/java/android/graphics/Typeface.java
9a5b61ccc83303ceeec2059f58c1977af9faa9e3 30-Apr-2014 Raph Levien <raph@google.com> Parsing of XML font configuration files for Minikin

This patch improves Minikin-based font handling, to deal with error
conditions (missing fonts and so on), and also moves the parsing of
fallback_fonts.xml and system_fonts.xml into Java code.

Change-Id: Ib0debdbd56ad3b0196be6d2a35668d711c98f1e5
/frameworks/base/graphics/java/android/graphics/Typeface.java
1a73f732f91e97c9c66b808c245ddda36a10e987 31-Jan-2014 Raph Levien <raph@google.com> Start of Minikin integration

This is the current state of the Minikin integration. All changes are
hidden behind USE_MINIKIN #ifdef, so it should be safe to apply. To
play with the Minikin branch, set this in your BoardConfig.mk .

This change also merges in 64-bit changes that were happenening in
parallel.

Change-Id: Idd94553bcbe324c5875d0ff06495c966c3e95b7f
/frameworks/base/graphics/java/android/graphics/Typeface.java
36bef0bf30d6bae48cf3837df351075ca4fce654 20-Jan-2014 Ashok Bhat <ashok.bhat@arm.com> AArch64: Make graphics classes 64-bit compatible

This a merger of two commits submitted to AOSP by
the following authors:

ashok.bhat@arm.com, david.butcher@arm.coma
craig.barber@arm.com, kevin.petit@arm.com and
marcus.oakland@arm.com

Due to the very large number of internal conflicts, I
have chosen to cherry-pick this change instead
of letting it merge through AOSP because the merge
conflict resolution would be very hard to review.

Commit messages below:

================================================
AArch64: Make graphics classes 64-bit compatible

Changes in this patch include

[x] Long is used to store native pointers as they can
be 64-bit.

[x] Some minor changes have been done to conform with
standard JNI practice (e.g. use of jint instead of int
in JNI function prototypes)

[x] AssetAtlasManager is not completely 64-bit compatible
yet. Specifically mAtlasMap member has to be converted
to hold native pointer using long. Added a TODO to
AssetAtlasManager.java to indicate the change required.

Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Craig Barber <craig.barber@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

==================================================================

AArch64: Use long for pointers in graphics/Camera

For storing pointers, long is used in
android/graphics/Camera class, as native
pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use of
jint instead of int in JNI function prototypes)

Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

===================================================================

Change-Id: Id5793fa0ebc17ee8b1eecf4b3f327977fdccff71
/frameworks/base/graphics/java/android/graphics/Typeface.java
7023df08f14ec5dee76ac54c03e870f84e297636 27-Jan-2014 Narayan Kamath <narayan@google.com> Revert "AArch64: Make graphics classes 64-bit compatible"

This reverts commit 18b4cbeedef21c1fa666a110a157bab66edff976.

Change-Id: I0c52983a3ab1ace3ff743de546a43eca28e5cb0e
/frameworks/base/graphics/java/android/graphics/Typeface.java
18b4cbeedef21c1fa666a110a157bab66edff976 20-Jan-2014 Ashok Bhat <ashok.bhat@arm.com> AArch64: Make graphics classes 64-bit compatible

This a merger of two commits submitted to AOSP by
the following authors:

ashok.bhat@arm.com, david.butcher@arm.coma
craig.barber@arm.com, kevin.petit@arm.com and
marcus.oakland@arm.com

Due to the very large number of internal conflicts, I
have chosen to cherry-pick this change instead
of letting it merge through AOSP because the merge
conflict resolution would be very hard to review.

Commit messages below:

================================================
AArch64: Make graphics classes 64-bit compatible

Changes in this patch include

[x] Long is used to store native pointers as they can
be 64-bit.

[x] Some minor changes have been done to conform with
standard JNI practice (e.g. use of jint instead of int
in JNI function prototypes)

[x] AssetAtlasManager is not completely 64-bit compatible
yet. Specifically mAtlasMap member has to be converted
to hold native pointer using long. Added a TODO to
AssetAtlasManager.java to indicate the change required.

Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Craig Barber <craig.barber@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

==================================================================

AArch64: Use long for pointers in graphics/Camera

For storing pointers, long is used in
android/graphics/Camera class, as native
pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use of
jint instead of int in JNI function prototypes)

Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>

===================================================================

Change-Id: Ib3eab85ed97ea3e3c227617c20f8d213f17d4ba0
/frameworks/base/graphics/java/android/graphics/Typeface.java
a033630e805c407080221e20b236b6054f324670 23-May-2013 Raph Levien <raph@google.com> Initial integration of Minikin to framework

With this patch, framework does at least some of its text rendering
using Minikin instead of TextLayoutCache. There's a lot of stuff broken
and not yet implemented, but the phone will boot.

Changes are hidden behind USE_MINIKIN, which should be set in
BoardConfig.mk for the brave. Without that, there are changes to
signatures in JNI methods and so on, but shouldn't be any visible
changes.

This commit also introduces a new abstraction for Typeface:

The new TypefaceImpl abstraction represents the functionality that
corresponds to a Java Typeface object. Currently it is backed by
SkTypeface, but in the migration to Minikin it is a FontCollection
combined with a FontStyle. This patch introduces a USE_MINIKIN
preprocessor switch, so there is no substantial change to existing
Skia-based code, but which lets us start replacing the implementation
with the Minikin version.

Change-Id: I532c4c2d32d4f4c1f349dc1db37caa112af587ea
/frameworks/base/graphics/java/android/graphics/Typeface.java
ca79cf69d09efa0c327e9b1237d86a119aea5da7 14-Aug-2012 Derek Sollenberger <djsollen@google.com> Update framework to support r5967 of Skia.

bug: 6906025
Change-Id: Iefdb830ec3aa2ab3472c1c142484a7aa21788a15
/frameworks/base/graphics/java/android/graphics/Typeface.java
46926698996d3857a650ed535024a88dbeaff1e1 12-Mar-2012 Romain Guy <romainguy@google.com> Don't allocate new typefaces when not needed.

The Typeface.create(Typeface, int) API can be used to create a new
typeface derived from an existing typeface. The implementation would
however create a new Typeface instance on every call, creating
unnecessary garbage in text-heavy applications. This changelist
adds a small cache of derived typefaces to avoid allocations whenever
possible.

Change-Id: Ib7290b3183e372aae12cf66033690e15cd4d0691
/frameworks/base/graphics/java/android/graphics/Typeface.java
7f9f99ea11051614a7727dfb9f9578b518e76e3c 11-Aug-2011 Xavier Ducrohet <xav@android.com> Make some methods/fields package private so that layoutlib can access them.

Change-Id: I4aeadfbaf8a4f6a459fa19937c21ac23d9e5fb64
/frameworks/base/graphics/java/android/graphics/Typeface.java
31a69fdbe1edd8d686043e8ca7d278289f65808e 14-Dec-2009 Mike Reed <reed@google.com> throw if we have a null typeface native instance (so we don't crash in native code)
we may still have to native-destroy a Typeface with a null ref, so check for that
/frameworks/base/graphics/java/android/graphics/Typeface.java
bbed0d68c815446400193bdc8b16fbf73e1ee664 01-Oct-2009 Mike Reed <reed@google.com> hide setGammaForText, which is only used for calibrating new devices
/frameworks/base/graphics/java/android/graphics/Typeface.java
dbade9d6a075b1d5b8ebe10ee8961a5de296c93b 25-Aug-2009 Mike Reed <reed@google.com> expose runtime changes to gamma
/frameworks/base/graphics/java/android/graphics/Typeface.java
a87a132ebf1c2dd733cf52feff6e44525257c961 12-May-2009 Romain Guy <romainguy@android.com> Fixes #1847219. Add a new API to load fonts from arbitrary files: Typeface.createFromFile(String/File).
/frameworks/base/graphics/java/android/graphics/Typeface.java
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/graphics/java/android/graphics/Typeface.java
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
/frameworks/base/graphics/java/android/graphics/Typeface.java
54b6cfa9a9e5b861a9930af873580d6dc20f773c 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution
/frameworks/base/graphics/java/android/graphics/Typeface.java