Can I use alternate glyphs in HTML code?
Asked Answered
D

1

5

I have chosen a font in Photoshop which has many alternate glyphs for each letter

(see attached image)

is there a way to display different glyphs when coding this in HTML/CSS by using the GID and Unicode references?

Image of different glyphs

Demilitarize answered 23/2, 2017 at 14:30 Comment(0)
M
7

It's not possible to specify the glyph directly in HTML as far as i know, but you can use stylistic sets and other OpenType features in CSS via font-feature-settings and font-variant. Browser support is surprisingly good.

Example:

<p>A quick brown fox jumps over the lazy dog.</p>
<p>A quick brown fox jumps over the lazy do<span class="ss01">g</span>.</p>
<style>
@import url('https://fonts.googleapis.com/css?family=Roboto+Slab:100');

body {
  font-size: 48px;
  text-align: center;
  font-family: "Roboto Slab";
  font-weight: 100;
  font-style: normal;
}

.ss01 {
  font-feature-settings: "ss01" 1;
}
</style>
Mousseline answered 23/2, 2017 at 15:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.