Open magnusvs opened 2 years ago
@magnusvs thanks for reporting! I tried to reproduce your issue with the current codebase and wasn't able to. Here's what I did:
paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/font/cashmarket_medium.xml
, I removed all references to android:font
paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/layout/textviews.xml
, I replaced android:fontFamily
with app:fontFamily
and changed all references@font/cashmarket_medium
to @font/cashmarket_medium_normal
./gradlew clean :paparazzi-gradle-plugin:check
and the test in question -- customFontsInXml
worked (just had a small change on the image diff due to the font change I believe)Could you try the same on our local and post your results? Also, if that is not the right way to simulate your issue could you provide some test cases?
Thanks!
Hi,
Sorry for the late response @fcduarte . I'm trying it out locally today but I'm just hitting errors compiling and can't manage to run tests at the moment. First couldn't sync project with VERSION_NAME=1.2.0-SNAPSHOT
, after downgrading to VERSION_NAME=1.1.0
I could sync but then fails with
Cannot perform signing task ':paparazzi-agent:signMavenPublication' because it has no configured signatory
Not too familiar with this maven publishing plugin so haven't gotten around it yet.
Back to the issue, if I remember everything correctly, I think on your step 2 is where it's different from my own project setup.
"and changed all references@font/cashmarket_medium
to @font/cashmarket_medium_normal
" I believe shouldn't be done. We adjust cashmarket_medium
in step 1, to not have android:font
prefixes but should still be able to use it, I believe that's why you didn't hit any errors.
Just to expand on the initial report:
Paparazzi does registerFontLookupInterceptionIfResourceCompatDetected
which seems to intercept requests to androidx.core.content.res.ResourcesCompat.getFont
(which should handle app:fontFamily
I guess)
and replaces it with android.content.res.Resources.getFont
(which only handles android:fontFamily
).
Now this registerFontLookupInterceptionIfResourceCompatDetected
was added as a workaround to a bug that should be fixed now according to it's comment.
Tried removing the method interceptor and the test still breaks due to the original issue. See comment here: https://issuetracker.google.com/issues/156065472#comment3
Solution is to use ASM to apply a transform similar to the one used by Android Studio: https://issuetracker.google.com/issues/156065472#comment4. Any volunteers?
Hey @jrodbx 👋🏼
I would like to give this issue a try.
Solution is to use ASM to apply a transform similar to the one used by Android Studio
Can you elaborate on this approach?
@aaalaniz, @tevjef created a PR: #679
Picking this up
Description It seems like
ResourcesInterceptor
overrides to use the platform Resources.getFont instead of the AndroidXResourcesCompat
. This causes a problem when using a font-family that only specifiesapp:
attributes, instead ofandroid:
attributes.Steps to Reproduce Use an AppTheme that sets
textAppearance
with a font-family like:By adding
android:
prefix the tests can inflate everything again.Expected behavior It seems like the behaviour was added because of this bug https://issuetracker.google.com/issues/156065472 which now is supposed to be fixed. Could the Interception be removed?
Additional information:
Screenshots