Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using string resource as typeface #15

Closed
Jake-Piatkowski opened this issue Mar 5, 2015 · 4 comments
Closed

Using string resource as typeface #15

Jake-Piatkowski opened this issue Mar 5, 2015 · 4 comments
Assignees

Comments

@Jake-Piatkowski
Copy link

Is it possible to use a string resource as the typeface?

For example instead of this:

pixlui:typeface="GillSansStd BoldCondensed.otf"

I'd prefer to do this:

pixlui:typeface="@string/font1"

and somewhere else in my XML value resource files:

<string name="font1">GillSansStd BoldCondensed.otf</string>

Currently it seems that if I try to do this, the typeface doesn't get set at all - I get the following message: Could not get typeface: native typeface cannot be made with name: @string/font1.

Is there any chance of me achieving the effect I need?

@odemolliens
Copy link
Contributor

I will include style / string in the next release !

Nothing ready in /dev/ branch for the moment

@odemolliens odemolliens self-assigned this Mar 5, 2015
@odemolliens
Copy link
Contributor

The only current way to do that is to override in each custom components this methods

private void setCustomFont(Context ctx, AttributeSet attrs) {
String typefaceName = attrs.getAttributeValue(
PixlUIContants.SCHEMA_URL, EDITTEXT_ATTRIBUTE_FONT_NAME);
if (typefaceName != null) {
setPaintFlags(this.getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG
| Paint.LINEAR_TEXT_FLAG);
setCustomFont(ctx, typefaceName);
}
}

the var "attrs" contains your "@string/font1"

@Jake-Piatkowski
Copy link
Author

Thanks :)

@odemolliens
Copy link
Contributor

On last version available on master

You can use:

style="@style/AppTheme.TextOswaldRegular"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants