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

Add additional functionality to $resource by extending it with custom methods for individual instances of $resource

In order to implement a $saveOrUpdate function that accepts a success callback and use it on an instance of the $resource service without extending the service itself, there is a specific approach: If you wish to extend the service, you can do so as shown ...

Display of Navigation Bar in Angular is Not Proper

Currently diving into the world of Angular, I've encountered an issue with a material menu that isn't displaying correctly. The expected outcome based on my code should resemble this image: https://i.stack.imgur.com/z70Aq.png This snippet showc ...

Trouble with AngularJS Smart Table when dealing with live data streams

Currently, I am facing a scenario where I am utilizing angularJs smart table for filtering. Here is the HTML code: <section class="main" ng-init="listAllWorkOrderData()"> <table st-table="listWorkOrderResponse"> <thead> ...

React's connect method is causing issues with my test case

Attempting to create a test case for my jsx file... Took a sample test case from another jsx file... The other file does not have the connect method... But this new file contains the connect method... Believe this is causing issues with my test case... Any ...

Issue with smart table sorting functionality

I've been working on a table with just one column that is populated from a string array. However, I'm struggling to get the sorting functionality to work properly. Can anyone pinpoint what mistake I might be making here? Steps taken so far: 1) ...

Uploading CSV or text files in Node.js

I am looking to develop a function that can upload CSV or txt files into MongoDB using the MEAN stack. The function should work by allowing me to upload a file, then it will verify if it is in text/csv format before uploading it to MongoDB. I have attemp ...

Send user inputs between routes in AngularJS and retrieve them successfully

I am currently working on building a Single Page Application (SPA) using AngularJS's routeProvider: <script> var app = angular.module("myApp", ["ngRoute"]); app.config(function($routeProvider) { $routePro ...

Display <span> next to <select>

Currently, I have a <span> and a <select>. However, in the following code, the <span> is displayed above the <select>. My goal is to arrange it so that the <span> is shown first, followed by the <select>. .requiredSta ...

Avoid floating right elements all the way up if there are already elements floating left

I am struggling to position block 5 next to block 3 on larger screens, while maintaining the desired arrangement on smaller viewports. The blocks do not have fixed heights in my setup. You can see my codepen for a better understanding of what I'm try ...

Is there a way to update the color of a button once the correct answer is clicked? I'm specifically looking to implement this feature in PHP using CodeIgniter

Within my interface, I have multiple rows containing unique buttons. Upon clicking a button, the system verifies if it corresponds to the correct answer in that specific row. The functionality of validating the responses is already functional. However, I a ...

Using AngularJS to dynamically assign classes with values derived from an ng-repeat loop

I'm attempting to assign a class to a table row using ng-class based on the value of ng-repeat. I have searched online and found examples that involve calling a function. Is it possible to simply set ng-class with a value instead of using a function? ...

Showing content in a single line causes it to drop down to the next

Check out my code snippet here: http://jsfiddle.net/spadez/aeR7y/23/ I'm curious about how I can make my header list align on the same line as the header, without dropping down. Here's the CSS code I have for the list: #header li { display: ...

`The PHP MySQL query consistently yields a false result`

Despite confirming that the data exists in the table, I always receive a false result when using the code below. Is there an error in my PHP code? <?php $con = mysqli_connect(".....", "....", ".....", "Pi"); $username = $_POST["username"]; ...

The sendKeys() method in Protractor is failing due to the element being hidden/not

Hi there! I am currently new to automated testing with protractorJS for an angularJS homepage. While the code I've written so far has been successful, I'm facing an issue where I'm unable to input keys into the search field. After running th ...

Is the AngularJS Date property model sending an incorrect value to the server?

There are some puzzling things I am trying to figure out. When using datetimepicker, the Date and time selected appear correctly on the screenshot. The value in the textbox is accurate The model's value in console is correct (but hold on a second... ...

What is the best way to access and process data from an $http request in a controller using a service

I am encountering an issue where the return value of the $http service in my controller is coming back as "undefined." Within my controller, I make a call to a service that utilizes $http: //this returns undefined vm.user_instruments = instruments.getIns ...

jQuery's draggable and resizable functionality with containment provisions is designed to

I'm struggling to create a resizable and draggable div using jQuery, but it's proving to be quite buggy in its implementation. Despite finding similar questions, I haven't come across a solution yet. How can I fix the containment bug when ...

What is the best way to eliminate borders on a span element so they collapse seamlessly?

When using the tryit editor on this html and narrowing the result window (to around 200px), the border ends up inside the span as it spans across multiple lines. Is there a way to make the border "collapse" so that it forms a single irregular border around ...

utilizing an arrow function in the same manner as a traditional function

I am a fan of the new arrow ()=>{} syntax and would love to use it wherever possible. I understand that arrow functions point to the outer this context. Is there a way to modify an arrow function so that "this" points to its inner scope? For example, h ...

AngularJS bidirectional binding with numerous select choices

I am faced with a unique challenge - I have a list of non-exclusive fields that users want to see presented in a select box allowing multiple selections, rather than individual checkboxes bound to Boolean values in the model. While I know how to create t ...