Skip to content

Conversation

@peng1999
Copy link
Contributor

Chinese and Japanese do not use spaces in normal texts. So currently you always need to use function instead of markups for emphasis, which is annoying. This PR fixes that.

Related: #635 (comment)

Copy link
Member

@laurmaedje laurmaedje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need two large bold fonts in the repo for testing or would one suffice? I assume this is to test different scripts?

@peng1999
Copy link
Contributor Author

peng1999 commented Nov 13, 2023

Do we really need two large bold fonts in the repo for testing or would one suffice?

Actually in the test I added in this PR, only the sc-bold variant font is needed. But the irrelevant test lang-with-region.typ will not look right after I added the font:

lang-with-region

The outlines should be bold, but previously it is not I nobody noticed that because there is no bold CJK font at all.

So, in summary:

  • emphasis.typ: needs one sc-bold font to look right.
  • lang-with-region.typ
    • needs both of sc-bold and tc-bold to really be right.
    • ... or get rid of both to pretend to be right.
    • ... or leave one bold font, to be obviously looks wrong.

So what do you prefer? Are you willing to accept the trade-off of having a test with broken font in order to save disk sapce?

@laurmaedje
Copy link
Member

I guess we can keep both fonts.

@laurmaedje laurmaedje merged commit f4a8109 into typst:main Nov 15, 2023
@laurmaedje
Copy link
Member

Thank you, I think this will really help CJK users!

@jiaojiaodubai
Copy link

jiaojiaodubai commented Nov 16, 2023

Do we really need two large bold fonts in the repo for testing or would one suffice?

The outlines should be bold, but previously it is not I nobody noticed that because there is no bold CJK font at all.

I would like to talk something I know about it.

Traditionally, there is no concept of "bold" in Chinese publishing technology. When emphasizing, we usually replace a font type, such as regular script or imitation Song script. Therefore, Chinese font files often do not contain multiple font weights.
image

However, the emergence of Microsoft Word allows people to use 'Fake Bold' to bold any character for emphasis, and many people have become accustomed to using bolder characters for emphasis. In this trend, some new fonts (such as Source Han) have also begun to release multiple font weights.

It should be noted that emphasizing in bold is still not a common practice in official publications and is usually only done in (informal) electronic documents.

In the Chinese macro set of LaTeX, the default behavior of the \emph{} command is consistent with the practice of traditional publications, where emphasis is expressed in regular script instead of bold. I think we also need to distinguish between "emphasis" and "bold" in the Chinese context.

@laurmaedje
Copy link
Member

We already have a distinction between normal emphasis (emph and _), strong emphasis (strong and *), italic (text(style: "italic")), and bold (text(weight: "bold")).

This means we could change the default behaviour of emph/strong based on the current text language. And users can of course also do it themselves with a show rule.

@GES233
Copy link

GES233 commented Nov 28, 2023

There's may something wrong in emphasis.typ. It's 斜体(Italic) not 楷体(Kai Font).

@laurmaedje
Copy link
Member

This PR only ensured that emphasis is parsable in CJK text. Special handling for Kai font instead of italics is not yet implemented.

jgm added a commit to jgm/typst-hs that referenced this pull request May 20, 2024
Typst documentation says that `*` strong emphasis
"only works at word boundaries." However, in typst/typst#2648
this was changed for CJK.

Closes #49.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jan 30, 2025
## 0.6.1

  * Fix precedence for functions (#55).
    `1(x)` and `!(x)` should not be parsed as functions.
    Note that we still don't match typst's behavior for `f_"!"(x)`.
    For us this works just like `f_!(x)`, but for typst we get
    a function in the subscript for the former but not the latter.
    Fixing this would require some changes in the types.

  * Define sys.version and sys.inputs.typst-hs-version (#56).
    The former is set to the version of typst we are trying to
    implement. The latter is a stringified version number from typst-hs.
    This will allow typst programs to tell when they're running
    on typst-hs (or pandoc), and react accordingly.

  * Rename stBeforeSpace -> stSpaceBefore to avoid confusion.

  * Fix precedence issues in math parsing (#54).
    Increased precedence of ! (factorial).
    `_` or `^` should eagerly gobble a grouped argument (`c_(a)`).

  * Minimal support for `context` (#53). Parse `context` keyword.
    New Context constructor in Expr [API change].
    Evaluate this by just evaluating the expression, for now.
    Note that we don't support the features (like location or
    numbering) that context is used to affect anyway, so this change
    probably won't be enough for meaningful support. But it might
    prevent some documents from issuing errors.

  * Arguments at method.

  * Array windows, reduce, to-dict methods.

  * Allow parentheses in import.

  * Make standard module available under std (typst 0.12).

  * Add over/underparen, over/undershell in math module.

  * Add stretch function.

  * Add skew.

  * Depend on typst-symbols 0.1.7 and start to target typst 0.12.

  * Reset indentation requirements inside `[]` content block. e.g.
    ```
    / B: #block[
    - a
    ]
    ```
    We don't need indentation inside the block content.


## 0.6

  * Recognize figure.caption function (#52).

  * Allow defined identifiers to override math defaults (#51).
    Previously we evaluated all math in a special environment that
    shadowed any user-defined functions with the same-named functions
    from the math or sym modules. This change gives user-defined identifiers
    priority over the math defaults, allowing things like `bb` to be
    overridden.

  * Typst.Types: EvalState now has two new fields, `evalMathIdentifiers` and
    `evalStandardIdentifiers`. `evalIdentifiers` is now just for user-defined
    identifiers. [API change]

  * Don't implicitly load sys module for math.

## 0.5.0.5

  * Allow numbers like `1.` in math mode (#50).

## 0.5.0.4

  * Add built-in identifiers for standard types (#21):
    array, bool, content, int, float, regex, length,
    alignment, color, symbol, string.

  * Adjust emphasis parser for CJK characters (#49).
    Typst documentation says that `*` strong emphasis
    "only works at word boundaries." However, in typst/typst#2648
    this was changed for CJK.
@tats-u
Copy link

tats-u commented May 6, 2025

Fullwidth alphanumerics are not covered by this approach.
(Scripts cannot cover characters shared by multiple scripts)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants