폰트 기능 설정

font-feature-settings

OpenType 기능 태그를 이름 붙은 CSS 속성 없이 문자열로 직접 켜고 끄는 저수준 속성. 스타일리스틱 세트·문자변형처럼 전용 속성이 없는 기능에 씁니다.

다른 이름: 저수준 OpenType 속성
···
html
<div class="stage">
  <div class="tagrow" id="tagrow"></div>
  <div class="readout" id="readout">측정 중…</div>
</div>
css
.stage{display:grid;gap:12px;justify-items:center;width:min(94%,480px)}
.tagrow{display:flex;gap:6px;flex-wrap:wrap;justify-content:center}
.tag{font:11px ui-monospace,Menlo,monospace;padding:4px 8px;border-radius:6px;border:1px solid var(--line);color:var(--muted)}
.tag.on{border-color:var(--accent);color:var(--accent)}
.tag.off{border-color:var(--line);color:var(--muted);opacity:.5}
.readout{font:10px ui-monospace,Menlo,monospace;color:var(--muted);text-align:center}
js
const probe = document.createElement('span');
probe.style.cssText = 'position:absolute;visibility:hidden;white-space:nowrap;font:20px -apple-system,system-ui,sans-serif';
probe.textContent = '0 1/2 1st';
document.body.appendChild(probe);
function widthWith(setting){
  probe.style.fontFeatureSettings = setting;
  return probe.getBoundingClientRect().width;
}
const base = widthWith('normal');
const tests = [
  { tag: 'zero', setting: '"zero" 1' },
  { tag: 'frac', setting: '"frac" 1' },
  { tag: 'ordn', setting: '"ordn" 1' },
];
const tagrow = document.getElementById('tagrow');
const readout = document.getElementById('readout');
let onCount = 0;
tests.forEach(function(t){
  const w = widthWith(t.setting);
  const active = Math.abs(w - base) > 0.4;
  if (active) onCount++;
  const el = document.createElement('span');
  el.className = 'tag ' + (active ? 'on' : 'off');
  el.textContent = '"' + t.tag + '" 1' + (active ? ' ✓' : ' —');
  tagrow.appendChild(el);
});
readout.textContent = onCount + '/' + tests.length + '개 태그에서 폭 변화 실측됨 (0=off 기준 비교, 폰트마다 다름)';

`font-feature-settings`의 값은 `"태그" 정수`를 쉼표로 나열합니다(예: `"liga" 1, "case" 1`). 대부분의 태그는 켬·끔을 뜻하는 0·1이지만, `cv01`처럼 여러 대안 중 하나를 고르는 문자변형 태그는 2, 3 같은 더 큰 정수도 받습니다.

스펙은 `font-variant-ligatures`·`font-variant-numeric`·`font-variant-caps`처럼 이름 붙은 고수준 속성이 있는 기능이면 그쪽을 우선 쓰라고 권합니다 — 브라우저가 그 값을 다른 스타일 규칙과 함께 더 예측 가능하게 다루기 때문입니다. `font-feature-settings`는 이름 붙은 속성이 아예 없는 기능에만 쓰는 탈출구입니다.

같은 요소에 둘을 함께 쓰면 이름 붙은 `font-variant-*` 쪽이 우선합니다 — `font-feature-settings`로 끈 기능도 `font-variant-ligatures: common-ligatures`가 있으면 다시 켜집니다. 데모는 이 저수준 속성으로 흔치 않은 태그 몇 개(`zero`, `frac`, `ordn`)를 켜보고, 시스템 폰트에서 실제로 폭이 달라지는 것만 실측해서 보여줍니다.

언제 쓰나

이름 붙은 CSS 속성이 없는 기능(스타일리스틱 세트, 문자변형, 폰트 고유 태그)에만 쓰세요. 커닝·리거처·숫자 스타일처럼 이름 붙은 속성이 있으면 그쪽이 더 안전합니다.