question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Applying custom font on label does not work

See original GitHub issue

Am I missing something? I’m trying to change the font family for my textfield labels.

Version

  • tcomb-form-native v0.6.4
  • react-native v0.41.2

Expected behaviour

Should be able to set custom fontFamily style on controlLabel

Actual behaviour

The font does not change for controlLabel. I can change it for textbox without problems.

Steps to reproduce

var t = require('tcomb-form-native')

// Label
t.form.Form.stylesheet.controlLabel.normal
  .color = 'red' // This does apply!
t.form.Form.stylesheet.controlLabel.normal
  .fontFamily = 'Oswald-Regular' // This does NOT apply!

// Textbox
t.form.Form.stylesheet.textbox.normal
  .fontFamily = 'Oswald-Regular' // This does apply!

My form look like this:

const t = require('tcomb-form-native')
let Form = t.form.Form

let LoginFormModel = t.struct({
  user: t.String
})

let LoginFormOptions = {
  fields: {
    user: {
      label: 'Email address'
    }
  }
}

renderForm() {
    return(
      <Form ref='loginForm'
        type={LoginFormModel}
        value={this.state.formValue}
        options={LoginFormOptions}
        onChange={(value) => this.onFormChange(value)}
      />
    )
  }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
pentarexcommented, Apr 20, 2018

In order to take the weight of the font itself. For example i am using Montserrat and this font have different types like Monteserrat-Regular or UltraLight, the way i managed it to make it work was to set the fontWeight to undefined

stylesheet.controlLabel.normal.fontWeight = undefined;
stylesheet.controlLabel.error.fontWeight = undefined;
0reactions
naywin-programmercommented, Nov 18, 2018

That is working for me. Firstly, you need to install custom font in your react native project.

const formStyles = { …Form.stylesheet, formGroup: { normal: { marginBottom: 10, }, }, controlLabel: { normal: { color: ‘#f88800’, fontSize: 18, marginBottom: 7, fontWeight: ‘600’, fontFamily: ‘Zawgyi-One’ }, // the style applied when a validation error occours error: { color: ‘red’, fontSize: 18, marginBottom: 7, fontWeight: ‘600’, fontFamily: ‘Zawgyi-One’ } } }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to set custom font for the UILabel in XCode
Unable to set custom font for the UILabel in XCode · Open "app-info.plist" under "Supporting Files" folder · Add new row in the...
Read more >
Custom Font not working - Microsoft Q&A
7 Answers · Go to Font Awesome website and download the font file . · Copy the file into shared project , notice...
Read more >
Custom fonts in launch screen | Apple Developer Forums
I've set a background image which is working fine and a label which I've set the text as an Attributed String. The problem...
Read more >
Custom Fonts Not Displaying On Front End - Elementor
Go to Elementor > Custom Fonts. If the URLs listed do not begin with https, click the DELETE button next to each, and...
Read more >
Common Mistakes With Adding Custom Fonts to Your iOS App
This should not be a problem but sometimes when you're having trouble getting your font face to show up, this can be a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found