Skip to content

Commit

Permalink
Fix Android raster scales
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Würthner committed Nov 12, 2024
1 parent 2a002b6 commit 57120ab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Semaphore
import kotlinx.coroutines.withContext
import java.io.File
import java.io.IOException
import java.io.OutputStream
import java.lang.Math.random
import javax.imageio.ImageIO
Expand Down Expand Up @@ -227,9 +228,12 @@ class FigmaApi(
if (format == Webp) {
debug(tag = tag, message = " Inline converting PNG => WEBP: $tmpFile")
val png = ImageIO.read(tmpFile)
ImageIO.write(png, "webp", out)
if(!ImageIO.write(png, "webp", out)) {
throw IOException("Writing of WEBP $id failed")
}
}
} finally {
out.close()
requestCount.update { it - 1 }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ data class FigExConfig(
) : Export() {
companion object {
val androidScales = listOf(
Scale(1f, "mdip/"),
Scale(1.5f, "hdip/"),
Scale(2f, "xhdip/"),
Scale(3f, "xxhdip/"),
Scale(4f, "xxxhdip/"),
Scale(1f, "drawable-mdpi/"),
Scale(1.5f, "drawable-hdpi/"),
Scale(2f, "drawable-xhdpi/"),
Scale(3f, "drawable-xxhdpi/"),
Scale(4f, "drawable-xxxhdpi/"),
)
}

Expand Down
11 changes: 10 additions & 1 deletion samples/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,17 @@
"format": "androidxml",
"filter": "{% if full_name|startsWith('content', true) %} true {% else %} false {% endif %}",
"fileNames" : "{{ full_name|replaceSpecialChars('_')|lowercase }}",
"destinationPath": "../sample_output/icons/drawable",
"clearDestination": false
},
{
"type": "icons",
"format": "png",
"filter": "{% if full_name|startsWith('content', true) %} true {% else %} false {% endif %}",
"fileNames": "{{ full_name|replaceSpecialChars('_')|lowercase }}",
"destinationPath": "../sample_output/icons",
"clearDestination": true
"clearDestination": false,
"useAndroidRasterScales": false
}
]
}

0 comments on commit 57120ab

Please sign in to comment.