Having problems with loading @font-face in Ionic Framework Android app build?

While working on an app in Ionic Framework, I encountered a peculiar issue.

https://i.stack.imgur.com/xk8uD.png

In my Ionic Framework application, I am importing @font-face and running the app on an Android device (Galaxy SIII). Strangely, the font (Montserrat) loads everywhere except underneath the image and on the initial screen. However, it loads perfectly in web preview and when using a system font like "Roboto". I suspect that the fonts may not be preloaded for immediate use, causing the DOM to render before loading the font for those specific elements.

I have set the background to red, which confirms that the content is being delivered; however, the text does not seem to be rendering. The text is in plain HTML format, and injecting it via an expression did not make a difference. Surprisingly, the imported font for the ionic-icons works flawlessly.

Interestingly, swiping the screen makes the text magically appear. This phenomenon does not occur elsewhere after the initial occurrence.

Below is the CSS code for the @font-face just in case something is missing...

  @font-face {
    font-family: 'montserratregular';
    src: url('montserrat-regular-webfont.eot#montserratregular');
    src: url('montserrat-regular-webfont.eot?#iefix') format('embedded-opentype'),
         url('montserrat-regular-webfont.woff2#montserratregular') format('woff2'),
         url('montserrat-regular-webfont.woff#montserratregular') format('woff'),
         url('montserrat-regular-webfont.ttf#montserratregular') format('truetype'),
         url('montserrat-regular-webfont.svg#montserratregular') format('svg');
    font-weight: normal;
    font-style: normal;
  }

* {
      font-family: 'montserratregular', 'Helvetica Neue', 'Arial', sans-serif!important;
      font-weight: normal !important;
  }

...and here is the corresponding HTML snippet:

<div ng-click="testTime()" class="fullwidth-container start-test begin" ng-if="reactionFrame === 0">
<img src="img/touch.svg" class="tap-icon">
<h1 class="test-prompt">Tap to begin</h1>
<h3>Please follow the instructions on the next screen as quickly as possible.</h3>
</div>

If anyone has insights on why this issue is occurring and how to resolve it, I would greatly appreciate your input.

Answer №1

Through numerous attempts, I eventually pinpointed the issue to be originating from the default Ionic stylesheet's CSS. Specifically, these styles were causing the problem (excluding this block resolved the issue - though it wasn't isolated to just one style):

.content {
  position: relative; }

    .scroll-content {
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      overflow: hidden;
      margin-top: -1px;
      padding-top: 1px;
      margin-bottom: -1px;
      width: auto;
      height: auto; }

    .menu .scroll-content.scroll-content-false {
      z-index: 11; }

    .scroll-view {
      position: relative;
      display: block;
      overflow: hidden;
      margin-top: -1px; }

It appears that the scroll behavior was causing a delay in loading the font. Instead of modifying the Ionic.css file, I disabled scrolling on <ion-content> and <ion-pane> by using

<ion-content scroll="false">
and <ion-pane scroll="false">, respectively. Now, the text loads smoothly as intended.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a MEAN Stack application by dividing the user interface and backend code onto separate servers

Looking to set up a MEAN stack application where the UI code runs on one server and the backend code runs on another server. Does anyone know of any Github repositories that demonstrate this type of MEAN project setup? The server with the UI code should no ...

My android app keeps crashing when I try to use .setText()

Despite trying numerous questions on this platform today, none of them have proven to be helpful. I seem to have the same syntax that works for others, but every time I hit send (to update my text fields), my app crashes. I have experimented with different ...

Connected with the functionalities of Umbraco Forms

Looking to develop a plugin similar to Umbraco Forms with identical functionality. Is it possible to incorporate custom fields from a database into the Umbraco backend's custom section and have them displayed on the frontend like Umbraco Forms? Seekin ...

Changing in height by utilizing javascript's style.height animation

When attempting to adjust the height property using JavaScript instead of jQuery, a challenge arises. The issue lies in the inability to reset the height back to zero after setting it to the scrollHeight of the element. The following is the JavaScript cod ...

Tips for customizing the appearance of an HTML dropdown menu

Here is the code snippet: <select name="xyz" id="abc"> <option value="x">10/Page</option> <option value="y">20/Page</option> <option value="z">30/Pa ...

Eliminating the Controller from the Previous Route Upon Reaching the Next Route

One challenge I'm facing with my Angular application is that when switching from one controller view to another, asynchronous functions initiated in the first view might continue executing even after navigating away. This can lead to unexpected behavi ...

Make changes to external CSS using HTML and JavaScript

Is it possible to dynamically change the value of a background in an external CSS file using JavaScript? Currently, all my pages are connected to a CSS file that controls the background for each page. I am attempting to modify the background by clicking a ...

Attempting to enlarge logo or image when cursor hovers over it

Seeking to enhance logo/image size when cursor hovers over it, but facing an issue where it enlarges even on areas outside of the image itself - View Example. I followed a tutorial to achieve this effect, and specified the width as 1024x1024 for the logo/i ...

Modifying text size using JavaScript string manipulation

I'm currently experimenting with a countdown script, but I'm struggling to change the size of the numbers displayed. Can anyone help me find where I can adjust the font and font size in this script? var eventdate = new Date("February 20, 2014 11 ...

Steps to display an angled bracket to indicate a line break

I have a div that is editable, allowing me to display the entered text. To indicate each new line, I would like to show a ">" symbol at the beginning of the line. HTML <body> <div> <span> &gt; </span> ...

Issues with custom logo and menu/sidebar toggle on Wordpress

Hello everyone, I am currently facing some difficulties with my new WordPress blog that utilizes the Skilt-Theme. Specifically, I'm having trouble with the custom-logo and sidebar-toggle features. When there is no logo present, you can see the layout ...

Convert JavaScript back into an HTML attribute

Is there a way to include a JavaScript code in an HTML attribute like shown below? <div class="xx" animation="yy" animate-duration="<script>Code goes here<script>" ...> </div> I'm struggling to figure it out, is there a solut ...

"Move a div towards the mouse's location by animating it with JavaScript when

I've been working on making the ball element move and shrink towards the goals upon mouse click. I successfully created a function that captures the mouse click coordinates in the goals, but I'm facing challenges with the ball animation. I consi ...

Changes are reflected in the service variable, but they are not updating in the component

I am facing an issue with a variable that is supposed to track the progress of image uploads. The variable seems to be working fine, but it remains undefined in my component. Upload Service method uploadProfilePic(url:string, user_id:string, image:any) { ...

Is it possible to modify the CSS of a single class when hovering over a child class of a different and unrelated class?

I am struggling with CSS combinators, especially when dealing with nested div, ul, and li elements. My issue involves changing the CSS of a div with the class "H" when hovering over li elements with the class "G". Since all of this is contained within a s ...

What is the best way to modify the size of the letter background?

I'm facing an issue with a word that has a background color. While using the CSS property background-color: blue, allows me to give the word a background color and display: inline-block helps in sizing it exactly to the word, the problem arises when I ...

When the width of the screen is less than 992 pixels, my div will be hidden

I have been working with the bootstrap4 layout, and I noticed that when the screen width is less than 992px, the yellow-div is overlapping the brown-div. Can someone explain why this is happening and suggest a solution? Below is the code snippet: .head ...

Modify a variable for a specific ng-repeat item in AngularJS

I want to expand the text when a user clicks on a read more button: <md-content class="md-padding" layout-xs="column" layout="row" layout-wrap> <div flex-xs flex-gt-xs="50" layout="column" ng-repeat="paquete in paquetes"> <md-card> ...

Styles and CSS have been successfully loaded, however, the content is not appearing

After attempting to import a web HTML CSS template into my self-made MVC, I encountered an issue. While the template works properly on its own, it fails to connect to the CSS files and display proper styles when accessed through my controller. Instead, onl ...

Adaptable Bootstrap navigation bar

In the process of creating a responsive menu, I have designed a navbar for desktop that includes 3 text links and 3 small pictures that are also links. However, when transitioning to a smaller screen size, my goal is to keep the 3 small pictures as they a ...