compose-icons icon indicating copy to clipboard operation
compose-icons copied to clipboard

FontAwesome icons are too big

Open risalfajar opened this issue 3 years ago • 6 comments

Using FA icons: image

Using Jetpack Compose built-in Icons: image

I am just using IconButton and Icon normally. I think there is something wrong with FA icons vectors, looking at the code from any icons from FA, it have its own viewport width and height:

public val SolidGroup.Pen: ImageVector
    get() {
        if (_pen != null) {
            return _pen!!
        }
        _pen = Builder(name = "Pen", defaultWidth = 512.0.dp, defaultHeight = 512.0.dp,
                viewportWidth = 512.0f, viewportHeight = 512.0f).apply {
            path(fill = SolidColor(Color(0xFF000000)), stroke = null, strokeLineWidth = 0.0f,
                    strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f,
                    pathFillType = NonZero) {
                moveTo(290.74f, 93.24f)
                lineToRelative(128.02f, 128.02f)
                lineToRelative(-277.99f, 277.99f)
                lineToRelative(-114.14f, 12.6f)
                curveTo(11.35f, 513.54f, -1.56f, 500.62f, 0.14f, 485.34f)
                lineToRelative(12.7f, -114.22f)
                lineToRelative(277.9f, -277.88f)
                close()
                moveTo(497.94f, 74.18f)
                lineToRelative(-60.11f, -60.11f)
                curveToRelative(-18.75f, -18.75f, -49.16f, -18.75f, -67.91f, 0.0f)
                lineToRelative(-56.55f, 56.55f)
                lineToRelative(128.02f, 128.02f)
                lineToRelative(56.55f, -56.55f)
                curveToRelative(18.75f, -18.76f, 18.75f, -49.16f, 0.0f, -67.91f)
                close()
            }
        }
        .build()
        return _pen!!
    }

private var _pen: ImageVector? = null

risalfajar avatar Dec 05 '21 08:12 risalfajar

I think sizing with modifiers works just fine.

Icon(
 FontAwesomeIcons.Brands.Github,
 modifier = Modifier.size(24.dp)
)

BreimerR avatar Dec 13 '21 13:12 BreimerR

@BreimerR well that can be a temporary workaround. For long term it will add more boilerplate to our code, remembering icon size each time we use icons is a hassle too.

risalfajar avatar Dec 13 '21 13:12 risalfajar

The project when generating use the same svg size values when generating. You could easily create a custom Composable to sets your preferred font size and use it. This is actually the only way possible to do this. If I would be doing on Compose-Icons side, would be the same thing, a custom composable for that.

CompositionLocals is not an option in this case because the fonts code does not use @Composable.

DevSrSouza avatar Dec 18 '21 19:12 DevSrSouza

I will close this because this is not something that I would change to be honest. Unless everyone thinks that compose-icons should provide a custom Icon Composable with the size set by default.

DevSrSouza avatar Dec 18 '21 19:12 DevSrSouza

what about changing the value of defaultWidth, defaultHeight, viewportHeight, and viewportWidth to match the Compose standard? I found this in androidx.compose.material.icons image

risalfajar avatar Apr 19 '22 17:04 risalfajar