Font-face src with local() is incompatible with Android devices

(I apologize for not discovering this earlier, but it seems that Chrome-Android also does not support the font I intended to use. The fallback-to-sys-default-font-trick used by Chrome-Android did fool me.)

I had planned to incorporate unicode-range to address this issue, but unfortunately, it presented a stumbling block.

@font-face functionality works seamlessly on Desktop platforms but encounters difficulties on Android devices.

Below is the code snippet:

HTML

    <p class="test">
        The Chinese ellipsis should be vertically centered, such as U+2026, the HORIZONTAL ELLIPSIS character<br>
        “中文省略号应该垂直居中……”<br>
    </p>

CSS

@font-face {
    font-family: "CJK Font";
    src: local("Noto Sans CJK SC");
}

.test {
    font-family: "CJK Font";
}

Demo:

I am using a Sony Xperia XZ1 (G8342) running Android 9 with Firefox Android version 96.3.1. The font Noto Sans CJK SC comes pre-installed on my phone. When @font-face functions correctly, the Chinese ellipsis aligns vertically center. However, in Firefox-Android, this alignment does not occur, and instead displays with the system default font, causing the ellipsis to match Roboto rather than Noto Sans CJK SC.

Screenshots captured on the phone and via Firefox remote debugger can be viewed below:

https://i.sstatic.net/rR6Lw.png

https://i.sstatic.net/dmtjK.png

The @font-face url src functions properly on Firefox-Android, while the @font-face local src encounters issues.

An interesting observation is that @font-face local src operates smoothly on Firefox for PC.

Shown below is a screenshot from Firefox for PC for reference:

https://i.sstatic.net/ncPDB.png

The same issue persists on Chrome-Android, which surprised me. When setting html lang="zh-cmn-Hans", Chrome-Android defaults to the sys-default-font, which happens to be Noto Sans CJK SC, giving the impression of functionality. However, changing the language to lang="en" causes it to malfunction.

https://i.sstatic.net/u0mwB.png

This raises the question - Could this be a bug specific to Firefox-Android? Or have I overlooked something else?

Answer №1

After dedicating an entire night to research, I have finally pinpointed the root of the issue.

The font causing trouble was Noto Sans CJK, a default Android font installed in ttc format.

https://i.sstatic.net/ihXLC.png

Upon testing other fonts in ttf format, the @font-face functionality started working as expected.

It seems that the @font-face src: url() method does not support ttc format by design. This discrepancy appears to be a fault on the part of Firefox-Android, whereas Chrome-Android is able to handle it properly.

Even though https://caniuse.com/?search=otf indicates that Firefox-Android should support otf format from version 96 onwards, local otf fonts still do not function correctly on this browser.

In conclusion: Firefox-Android is incapable of utilizing ttc or otf fonts with @font-face src: local(), even if they are installed locally on the system

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

Why is it proving difficult to eliminate margin and padding from the top of the page?

Struggling to remove padding or margin from the top, I attempted to adjust the main container settings: margin-top:0px !important; padding-top:0px !important; Unfortunately, this did not have the desired effect. The code is too lengthy to include in thi ...

Steps for creating a rubber compound with reduced elements

Sample Image Looking for a way to reduce the size of elements on a webpage without adapting them? I want the elements to shrink and align in a single column, and I will handle the adaptation myself. HTML: <!-- Trading --> <div class="main-co ...

Incorporating a YouTube video

Having trouble integrating a YouTube video that won't play automatically on your website? The video is visible, but just doesn't start playing on its own. What could be causing this issue? Appreciate any help you can provide! ...

Eliminate border around image

I've been trying to get rid of the image border using different methods img { border: 0px; } I even attempted to remove it from the browser console with this code border: none !important This is what my html code looks like <div id="startD ...

Eliminating the GWT Window Padding in LibGDX

Explanation: I am currently in the process of deploying a LibGDX GWT application to the browser. Challenge: In the image below, you can see the top left portion of my GWT application showcased by the large black rectangle. The issue here is the unwanted ...

Is it possible to extract a div from a third-party domain and showcase it on my website?

Trying to integrate content from my Veetle.com channel onto my personal website has proven to be quite the challenge. Initially, I attempted to modify an iframe with CSS to display only the schedule information, but encountered limitations due to using 3rd ...

Using CSS transform to enhance Flash content

I am currently working on a web application that is contained within an iframe. The iframe has been scaled using -webkit-transform:scale(0.8), which is functioning well. However, I am encountering an issue with the flash audio recorder within the iframe no ...

Ways to define a variable based on a CSS class attribute?

I need help figuring out how to create a variable in my script that is defined by the width attribute of a CSS class. The snippet I have currently doesn't seem to work as expected. var dist = $('.nav').css(width()); The goal of my script i ...

How can I ensure text remains confined within the parent div when working with Bootstrap?

I'm having trouble keeping the text and links within their parent div. Even though I set the outer boundary as col-sm-8, the text and links are overflowing. I'm not sure what I'm doing wrong, but the code I am using is shown below. I have a ...

Issue with MUI Grid item not functioning properly when using overflowY: "auto"

I am encountering an issue while using MUI with React. I have a <Paper> element wrapping a <Grid> with 3 children elements. The problem arises when I set the overflowY property of the bottom grid item to "auto" - instead of showing the scroll b ...

Using a personalized font in your RShiny application

I'm interested in integrating a unique custom font into my Rshiny App. I have a feeling that the necessary code should be placed within tags$style, but I am unsure of the exact syntax needed for this integration. Below is an example code snippet: ui ...

Tips for aligning divs side by side with smaller divs stacked below them

I have a collection of dynamically generated divs that act as panels for selecting different options. These divs can be categorized into two types: regular and short. The height of the regular divs is determined using JavaScript to match the height of the ...

Overlay text on top of image with fading transparency when hovering over it

Is there a way to make the transparent layer that appears when hovering over an image on a card only cover the image itself and not extend onto the footer of the card? Currently, the image on the card covers most of it, and I want the hover overlay to beh ...

How can I eliminate the error message "WARNING: no homepage content found in homepage.md"?

Starting my journey with KSS utilizing Keith Grant's CSS in Depth as a guide. In section 10.1.4, the author suggests: To begin, create a new markdown file named homepage.md inside the css directory. This file will serve as an introduction to the patt ...

Deleting an item from a Vue.js list

I'm currently working on a project to develop a basic webpage that allows users to add or remove textboxes using vue.js. new Vue({ el: "#app", data() { return { list: [] }; }, methods: { deleteFromList(index) { this ...

Ways to move the scroll to the bottom of the div by clicking

Can anyone help with why my scroll code isn't working? I'm trying to make the scroll go to the bottom when I click on $('#openDiv'). For example, when you enter a chat room on stackoverflow, the scroll is automatically at the bottom, a ...

What is the best way to horizontally align an image beneath a navigation menu that is built using <ul> tags?

Seeking a way to center an arrow graphic under the selected item in a simple CSS drop-down menu? Considering using the :after selector, but currently being used for drawing dividing lines between menu options: HTML: <ul> <li>Option Zero&l ...

Button triggering an onclick event

Can you design a feature where clicking on each button reveals specific images with text and heading? The initial image is hidden and when another button is clicked, the previous image disappears and new one appears in its place. We would like to achieve t ...

Struggling with my Transform Origin in CSS for SVG

I have two classes (firstCircle & spin) on the first circle on the left, and I'm attempting to make it rotate in place. After removing them from the css so you can see the circle, I am having trouble with transform-origin. My code seems wrong as i ...

I'm struggling to understand how to interpret this. The v-tab function seems to be generating a button with various properties, but I'm unsure which specific property is related to

The V-tab below generates the button known as the right one on the v-app-bar: https://i.stack.imgur.com/DzNmq.png <v-tab :to="'/demo'" active-class="text--primary" class=&quo ...