Support the different Roboto styles styles #46

Closed
iBelieve opened this Issue Dec 15, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@iBelieve
Member

iBelieve commented Dec 15, 2014

Upstream bug in Qt: https://bugreports.qt-project.org/browse/QTBUG-30851

We use the default Android font in our embedded application:
http://developer.android.com/design/style/typography.html

We want to use different flavors of this font (Regular, Light, Bold, Medium) in our app.

However, from QML, the font can only be specified by "font.family". All of these .ttf files contain the same font family name (which makes sense).

Setting font.bold to true on the Roboto Regular font produces a different end result than using the Roboto-bold.ttf file.
Likewise, playing around with font.weight does not yield any decent result. Both of these seem to process the existing font instead of looking for the different flavors of the font (like native applications do).
We need a way of accessing the different flavors of a font from QML.

For now, we have worked around this issue by editing the Roboto font and changing the "Family name" field and saving them as totally different fonts.

It looks like we'll have to work around this by renaming the various Roboto variants.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@iBelieve iBelieve added the bug label Dec 15, 2014

@iBelieve iBelieve modified the milestone: Version 0.1 Dec 15, 2014

@iBelieve iBelieve added the upstream label Dec 15, 2014

@marianofino

This comment has been minimized.

Show comment
Hide comment
@marianofino

marianofino Feb 28, 2015

Hi @ibeliever

If I understand correctly, first it is needed to change every Font "Family name" to every font syle (e.g. Roboto-bold.ttf renamed from "Roboto" to "Roboto Bold"), and then modify the code. However, there are different ways to approach this. Something like this could be ok?

For example, from Label.qml line 96, change from this

font.family: "Roboto"
font.weight: {
    var weight = fontInfo.font
    if (weight == "medium") {
        return Font.DemiBold
    } else if (weight == "regular") {
        return Font.Normal
    } else if (weight == "light") {
        return Font.Light
    }
}

to this

font.family: {
    var weight = fontInfo.font
    if (weight == "medium") {
        return "Roboto-medium"
    } else if (weight == "regular") {
        return "Roboto-regular"
    } else if (weight == "light") {
        return "Roboto-light"
    }
}

Please confirm me if it is ok, or you were thinking of something else.. I can help on it..

Hi @ibeliever

If I understand correctly, first it is needed to change every Font "Family name" to every font syle (e.g. Roboto-bold.ttf renamed from "Roboto" to "Roboto Bold"), and then modify the code. However, there are different ways to approach this. Something like this could be ok?

For example, from Label.qml line 96, change from this

font.family: "Roboto"
font.weight: {
    var weight = fontInfo.font
    if (weight == "medium") {
        return Font.DemiBold
    } else if (weight == "regular") {
        return Font.Normal
    } else if (weight == "light") {
        return Font.Light
    }
}

to this

font.family: {
    var weight = fontInfo.font
    if (weight == "medium") {
        return "Roboto-medium"
    } else if (weight == "regular") {
        return "Roboto-regular"
    } else if (weight == "light") {
        return "Roboto-light"
    }
}

Please confirm me if it is ok, or you were thinking of something else.. I can help on it..

@iBelieve

This comment has been minimized.

Show comment
Hide comment
@iBelieve

iBelieve Apr 17, 2015

Member

This is now working correctly and the different styles and font weights are shown in the demo.

Member

iBelieve commented Apr 17, 2015

This is now working correctly and the different styles and font weights are shown in the demo.

@iBelieve iBelieve closed this Apr 17, 2015

@iBelieve iBelieve added the 3 - Done label Apr 17, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment