Apply custom font to RecyclerView items within a Fragment - android-fragments

How do I apply a font style to the items in a RecyclerView that are displayed within a Fragment?

If you wish to change the font of your TextViews in your Fragment, by default, starting from Android 4.1, Roboto fonts are used by default. You can change the type of that font by using:
android:fontFamily="sans-serif" // roboto regular
android:fontFamily="sans-serif-light" // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed
android:fontFamily="sans-serif-thin" // roboto thin (android 4.2)
android:fontFamily="sans-serif-medium" // roboto medium (android 5.0)
If you want to use your own font, which can be troublesome and can result in a memory leak, you can't specify that font in XML. Instead, you'll have to change it programmatically like so:
TextView text = (TextView) findViewById(R.id.textview03);
Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Molot.otf");
text.setTypeface(tf);
Remember: The fonts must be stored in your res/assets directory. You can create a subfolder and called it fonts within that directory. Make sure your font files are of supported formats like .otf and .ttf
If you want to change the font style, according to this page, you can use this:
<TextView android:textStyle="normal" /> // normal
<TextView android:textStyle="bold" /> // bold
<TextView android:textStyle="italic" /> // italic
Tell me how you go.

Related

Google fonts and font-display

We are currently loading a couple of fonts on our site from google fonts using the following link
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons%7CRoboto:300,300i,400,400i,500,700&display=block">
As you can see, at the end of the query string, we have display=block to stop the font from rendering before it's loaded (as it adds font-display: block). However, this adds block to all declarations of every font face. Is there a way to only add this to the material icons font without having to make 2 separate requests?

angular material typography - customisation

In customizing my angular material theme's typography. I understand that one can override the default font with their own font like so:
$custom-typography: mat-typography-config(
$font-family: 'Lato, monospace'
);
Although, I noticed that the source code shows two fonts , the default Roboto, and then Helvetica is also included in inverted commas:
$font-family: 'Roboto, "Helvetica Neue", sans-serif',
Is that a secondary font? I would like if I could choose a secondary font. If this is not a secondary font, what is it?
thanks
The font-family property can hold several font names as a "fallback" system. If the browser does not support the first font, it tries the next font.
Start with the font you want, and always end with a generic family, to let the browser pick a similar font in the generic family, if no other fonts are available.
Note: Separate each value with a comma.
Note: If a font name contains white-space, it must be quoted. Single quotes must be used when using the "style" attribute in HTML.
Copied from w3schools

JavaFX Italic Font w/CSS

I'm using a CSS style sheet with a style class like this:
.sublabel {
-fx-font-style: italic;
-fx-font-size: 12;
}
...which has been set as the Label's Style Class in Scene Builder. The font size changes as expected (smaller, since I have -fx-font-size: 14; under the .root class but this is the only font-related setting). Bold style works fine, but it refuses to use an italic font. I'm not using a custom font anywhere, so this should be using the default font JavaFX 8 uses on Win7. I've also tried setting it under Style independently.
What could cause the style request to be ignored?
The default font in JavaFX, "system", does not support italic. You can even choose italic in SceneBuilder, but it will only work for fonts that support it.
Try using a TrueType font, e.g. Verdana, then it should work without problems.
Either use the style version below, or the more direct: Font name="Verdana Italic"
<Button style="-fx-font-style: italic;" text="Button">
<font>
<Font name="Verdana"/>
</font>
</Button>

How do I set a monospace font for all new files in Xcode 4?

When editing .markdown files (presumably opened as plain text), Xcode 4.1 uses a non-monospace font. I'd like all files regardless of type to use a monospace font. I didn't see any options to change the default behavior.

embedding font in Flex CSS locally with a installed font works, but w/ url to refer to a ttf font file doesn't

I'm trying to embed a font in my project by using url("font.ttf") rather than local("Font Name"), but it doesn't seem to pick it up. The font in question is called "Gotham Bold". When i view the details of the font, the font weight is regular, however when i use local("Gotham Bold") in the css i have to specify fontWeight: bold or else it wont pick it up. But when I use url("folder\Gotham-Bold.ttf"), and specify fontWeight: bold, it says that font weight is not found for that TTF. If i remove the fontweight, there's no errors, but the font is not applied to the text. any ideas please?
Thanks
I use this code to embed a custom Font in my Flex App. I placed this code directly in mx:Application.
I have found two different file one for the normal weight and one for the bold.
<mx:Style>
/*S!_DCB__.TTF*/
#font-face{
src: url("S!_DC__.TTF");
fontFamily: DAX2;
font-weight:normal;
}
#font-face{
src: url("S!_DCB__.TTF");
fontFamily: DAX2;
font-weight:bold;
}
</mx:Style>
After that i just put the DAX2 font name in the component.
Claudio.
Fonts may not actually being embedded in your code. One more thing, You must embed distinct font for different styles. as per say, If you want to embed Arial with Normal and Bold style, you have to embed Arial twice with different class names given.
To embed font use
[Embed(source = "path of font file.ttf", fontName = "Gotham-Regular", mimeType="application/x-font-truetype")]
private var fontGothamRegular:Class; //Class name which would be used to register font
//To register font
Font.registerFont(fontGothamRegular);
//For embedding bold style of same font
[Embed(source = "path of font file.ttf", fontWeight="Bold", fontName = "Gotham-Bold", mimeType="application/x-font-truetype")]
private var fontGothamBold:Class;
Font.registerFont(fontGothamBold);

Resources