Skip to content

Automatic optical size font selectionΒ #5626

Open
@lonkaars

Description

Description

Optical sizes can (since #3315) be selected by manually adding the size to the font name. LaTeX automatically selects the correct optical size (if available), or uses scaling as a fallback option, while Typst appears to only scale fonts.

Minimal working example (Typst):

#set page(
  width: auto,
  height: auto,
  margin: 5mm,
)
#set text(font: "Latin Modern Roman")

#let demo(size) = {
  box(height: 2cm)[
    #scale(2cm / size * 100%, reflow: true)[
      #text(size)[Aa]
    ]
  ]
}

#demo(8pt) #demo(10pt) #demo(20pt)

Output (unwanted, all pairs look identical):
output

Minimal working example (LaTeX):

\documentclass[border=5mm]{standalone}

\usepackage{adjustbox}

\begin{document}

\def\demo#1{%
  \strut\adjustbox{height=2cm}{%
    \fontsize{#1}{0}\selectfont Aa%
  }%
}

\demo{8} \demo{10} \demo{20}

\end{document}

Output (note differences in stroke contrast between pairs):

output

Use Case

I'm the author of typst-metalogo, and the 'A' in the LaTeX logo has different metrics and stroke width when compiled with Typst instead of LaTeX. This results in the logos looking 'unbalanced' in Typst due to the differences in stroke width between the regular and scaled glyphs.

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requesttextText layout, shaping, internationalization, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions