Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primary font ignores the fontconfig's charset property. #30

Open
huyuehui opened this issue Aug 26, 2021 · 4 comments
Open

Primary font ignores the fontconfig's charset property. #30

huyuehui opened this issue Aug 26, 2021 · 4 comments

Comments

@huyuehui
Copy link

huyuehui commented Aug 26, 2021

I reported an issue several days ago. Maybe at that time I didn't make myself clear. I guess that the following source blocks cause this issue.

In src/ft/mod.rs :
In my case, the function load_face_with_glyph(...) has never been called. Because in face_for_glyph(...), it always returns early inside the 'if let' block.

In the get_face(...) function, the 'coverage' of the 'Fallbacklist' struct doesn't include the charset of the primary font. So setting the charset property of the first matched font (the primary font) in fonts.conf doesn't work if no fallback is happened.

@chrisduerr
Copy link
Member

Ah, I understand what you mean now. Seems like you're right and we do indeed not check the charset for the primary font. We check the char index to make sure the character is contained at all, but that's it.

It seems like the charset also isn't read for fallback fonts that have been loaded already (see the Some(face) branch in load_face_with_glyph).

Generally once a font is loaded, we only have access to FreeType things iirc. So at that point we don't check anything fontconfig anymore. But the charset would have to be checked every time a glyph load is attempted, we'd likely have to persist it from fontconfig after loading.

Curious if @kchibisov is aware of/has an opinion on this, since he did do a bunch of freetype/fontconfig stuff in the past.

@kchibisov
Copy link
Member

@huyuehui would you mind providing example fontconfig configuration? I'm not into its syntax wrt charsets so it could help.

@huyuehui
Copy link
Author

huyuehui commented Apr 3, 2022

@kchibisov
It is something like the following:

...

  <match target="scan">
	  <test name="family"><string>Migu 1M</string></test>
	  <edit name="charset">
		  <charset>
			  <!-- 基本拉丁(ASCII) -->
			  <range><int>0x0020</int><int>0x007E</int></range>
			  <!-- 拉丁-1增补 + 拉丁扩展A/B -->
			  <range><int>0x00A0</int><int>0x0181</int></range>
			  <int>0x0186</int><int>0x0189</int><int>0x018A</int>
			  <range><int>0x018E</int><int>0x0194</int></range>
			  <range><int>0x0198</int><int>0x019B</int></range>
			  <range><int>0x019D</int><int>0x01A1</int></range>
			  <range><int>0x01AF</int><int>0x01B1</int></range>
			  <range><int>0x01B3</int><int>0x01B6</int></range>
			  <range><int>0x01BF</int><int>0x01E3</int></range>
			  <range><int>0x01E6</int><int>0x01ED</int></range>
			  <range><int>0x01EF</int><int>0x01F5</int></range>
			  <range><int>0x01F7</int><int>0x01FF</int></range>
			  <range><int>0x0218</int><int>0x021F</int></range>
			  <range><int>0x0230</int><int>0x0233</int></range>
			  <int>0x0237</int><int>0x023D</int>
			  <!-- 国际音标 + 空格调整字母 -->
			  <range><int>0x0250</int><int>0x02FF</int></range>
			  <!-- 希腊语 -->
			  <range><int>0x0372</int><int>0x0375</int></range>
			  <int>0x037A</int><int>0x037E</int><int>0x038C</int>
			  <range><int>0x0384</int><int>0x038A</int></range>
			  <range><int>0x038E</int><int>0x03A1</int></range>
			  <range><int>0x03A3</int><int>0x03E1</int></range>
			  <!-- 西里尔语 -->
			  <range><int>0x0400</int><int>0x045F</int></range>
			  <int>0x0462</int><int>0x0463</int>
			  <range><int>0x0472</int><int>0x0475</int></range>
			  <int>0x0480</int><int>0x0481</int><int>0x0490</int><int>0x0491</int>
			  <int>0x04AE</int><int>0x04AF</int><int>0x04E8</int><int>0x04E9</int>
			  <!-- 货币符号 -->
			  <int>0x20A1</int><range><int>0x20A8</int><int>0x20AC</int></range>
			  <range><int>0x20AF</int><int>0x20B3</int></range><int>0x20B5</int>
			  <!-- 字母符号 -->
			  <int>0x2103</int><int>0x2113</int><int>0x2116</int><int>0x211E</int>
			  <int>0x2121</int><int>0x2122</int><int>0x2126</int><int>0x2127</int>
			  <!-- 数字形式(罗马) -->
			  <range><int>0x2160</int><int>0x216B</int></range>
			  <range><int>0x2170</int><int>0x217B</int></range>
			  <!-- 箭头 -->
			  <range><int>0x2190</int><int>0x2199</int></range>
			  <range><int>0x21B0</int><int>0x21B5</int></range>
			  <range><int>0x21C4</int><int>0x21CA</int></range>
			  <range><int>0x21D0</int><int>0x21D9</int></range>
			  <range><int>0x21E4</int><int>0x21ED</int></range>
			  <!-- 控制图片 -->
			  <range><int>0x2400</int><int>0x2426</int></range>
			  <!-- 带圈的字母与数字 -->
			  <range><int>0x2460</int><int>0x2473</int></range>
			  <range><int>0x24D0</int><int>0x24FF</int></range>
			  <range><int>0x2776</int><int>0x2793</int></range>
			  <!-- 数学乘号 + 拉丁扩展C -->
			  <int>0x2A2F</int><int>0x2C71</int><int>0x2C7D</int>
			  <!-- 平假名 + 片假名 + 片假名语音扩展 -->
			  <range><int>0x3041</int><int>0x3096</int></range>
			  <range><int>0x3099</int><int>0x30FF</int></range>
			  <range><int>0x31F0</int><int>0x31FF</int></range>
			  <!-- 拉丁扩展D -->
			  <int>0xA78B</int><int>0xA78C</int>
			  <!-- 拉丁组合字 -->
			  <range><int>0xFB00</int><int>0xFB04</int></range>
			  <!-- 字节顺序标记 -->
			  <int>0xFEFF</int>
		  </charset>
	  </edit>
  </match> 

...

@kchibisov
Copy link
Member

Ok, I'll try to take a look when I have time...

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

No branches or pull requests

3 participants