core icon indicating copy to clipboard operation
core copied to clipboard

Chinese fonts cannot be vertically centered when used alone. (whether default or manually set).

Open qq1792569310 opened this issue 7 months ago • 1 comments

Describe the bug

Image

How to reproduce

  1. Create the simplest program.
  2. Create three buttons, one displaying in Chinese, one in English, and one displaying in a mix of Chinese and English.
  3. Observe the text positions.

Example code

package main

import (
	"cogentcore.org/core/core"
	"cogentcore.org/core/gpu"
	"cogentcore.org/core/styles"
	"cogentcore.org/core/text/text"
)

func main() {
	gpu.SelectAdapter = 0
	b := core.NewBody()
	core.NewButton(b).SetText("Hello, World!").Styler(func(s *styles.Style) {
		s.Text.Align = text.Center
		s.Text.AlignV = text.Center
	})
	core.NewButton(b).SetText("你好世界").Styler(func(s *styles.Style) {
		s.Text.Align = text.Center
		s.Text.AlignV = text.Center
	})
	core.NewButton(b).SetText("Hello世界").Styler(func(s *styles.Style) {
		s.Text.Align = text.Center
		s.Text.AlignV = text.Center
	})
	b.RunMainWindow()
}

Relevant output


Platform

Windows

qq1792569310 avatar May 25 '25 09:05 qq1792569310

Thank you for reporting this. I can reproduce this and we will work on fixing this soon.

kkoreilly avatar May 30 '25 19:05 kkoreilly