Elyas
Elyas

Reputation: 25

Changing font in webview

I use this code for my web view

@font-face {
  font-family: IRANSans;
  src: url("\file:///android_asset/fonts/IRANSansWeb.ttf\")
}

body {
  text-align: justify;
  direction: rtl;
  font-family: IRANSans;
}

img {
  max-width: 100%;
  height: auto;
}

figure {
  max-width: 100%;
  height: auto;
}

iframe {
  width: 100%;
}

everything work for me with this code except font family.

I mean text is justify and rtl very well, but my font is not what I want I put my ttf file in assets > fonts

Upvotes: 0

Views: 184

Answers (2)

Steven
Steven

Reputation: 1414

You don't need to set the linking to the font like that. How do you load the css in your html? Not like : file:///android_asset/css/someCSSFile.css

I think you linked like this: css/someCSSFile.css.

So will you try to link to the font use this: fonts/IRANSansWeb.ttf

@font-face {
font-family: IRANSans;
  src: url("fonts/IRANSansWeb.ttf")
}

if that doesn't worked can show a screenshot of structure of your maps?

Upvotes: 1

Ami Trambadia
Ami Trambadia

Reputation: 101

Make sure you have put your font file in right path i.e. app/src/main/assets/fonts

Upvotes: 0

Related Questions