w3c / w3c/csswg-drafts

[css-text] Glyph substitution

Open
#8,545 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-fonts-5 css-text-4
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

Recently ran into several similar issues:

  • A project where the branding/client liked the visual appearance of Æ, when the actual text content should have been ae.
  • A project where a single character from the brand name was omitted and a space was rendered : f o, when the actual text content should have been foo.

When solving this with actual character replacements we are creating problems for accessibility, SEO, how text breaks and wraps,...

Content editors also find it hard to consistently apply the "special" notation.

The alternative is to solve this in font files with glyph substitutions.
This works really well and avoids all the issues mentioned above.

But adding custom substitutions is technically complex and not always feasible depending on the font file formats. (or impossible with hosted fonts, like google fonts)
It is not something that can be easily and quickly done by a frontend/css developer.


This made me wonder if this could be solved with CSS?

  • Is this something that is useful for more people than just me?
  • Is this implementable?

Syntax might require an at rule to be able to set and reuse multiple properties.
I imagine this also makes it possible to optimize things in implementations when these substitutions are globally defined.

@glyph-substitution Æ_as_ligature_for_a_e {
  type: ligature;
  substitute: a e;
  by: Æ;
}

@font-face {
  font-family: 'Some Font';
  /* regular descriptors for some font face */
  
  glyph-substitution: Æ_as_ligature_for_a_e;
}

.foo {
  font-family: 'Some Font';
}

every name/keyword is made up, I haven't done enough reading on this to suggest meaningful naming here


Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the issue's OpenType GSUB reference and the surrounding CSS text and font specifications. No implementation files or tests are named. Done would require establishing whether CSS glyph substitutions are feasible and refining the proposed syntax into an agreed specification direction.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.