Idorasi Paul
Idorasi Paul

Reputation: 77

How do I change fonts dynamically in Angular?

I'm currently building an app that supports multiple languages using Angular 8 and @ngx-translate (version: 11.0.1).

The app supports a total of 25 languages (for now) but some of them look weird in the font that I'm using (lato). I want to choose the font based on the selected language.

This is how I select the language:

@Injectable()
export class LanguageService {

 constructor(private translateService: TranslateService) {
  }

public setLanguage(language: string): boolean {
    if (language && this.isSupportedLanguage(language)) {
      this.translateService.use(language);
      return true;

}

Does anyone know if I'm able to add something like setFont() based on the selected language? Thanks.

Upvotes: 0

Views: 696

Answers (1)

u can do it with adding class to body element and css like body.it { font-family: ***; }

Upvotes: -1

Related Questions