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

So.. why? #1

Open
abitrolly opened this issue Dec 20, 2020 · 4 comments
Open

So.. why? #1

abitrolly opened this issue Dec 20, 2020 · 4 comments

Comments

@abitrolly
Copy link

I could find an explanation, so I have to ask why a new generation is needed?

@marguerite
Copy link
Owner

@abitrolly

Hi,

Sorry I wrote something about this before on my blog but it's in Chinese, I forgot to add an English version.

Nowadays:

  1. we have Noto Sans as the default font

it's a huge font family, but most of the fonts are useless for those who never know that language.

so it's not wise for me to develop a long fontconfig list for that and installed for every user.

it'll make debug ugly and runtime lag

so I have to find a way to detect the installed fonts and generate fonts.conf programmingly.

  1. many browsers support emoji.

but they do not prepend a "emoji" alias in css, they just put emoji font along with sans-serif.

so actually currentlly emoji fonts has to fight with sans-serif, they have to be small enough to "just display emojis"

but it's not the case, almost every emoji font available has 0-9 and some other common symbols.

if it is prepended before sans-serif. the 0-9 and common symbols in them will take effect. Noto Color Emoji even has a long long space as emoji which will break the page content.

so I have to append emoji in the last part of the sans-serif match to avoid this, then blacklist all the emoji characters in sans-serif fonts to let emoji font do the job.

then we need to programmingly know what sans-serif are avaiable and what charaters they have, the intersected characters and so on.

@abitrolly
Copy link
Author

I must admit I am not really that familiar with fontconfig. Came here mostly after the problems with missing fonts in snap packages, numerous fontconfig warnings during start up of various programs and very slow startup time for BleachBut with fontconfig involved. Maybe the real question was - what fontconfig is doing and why it is doing it wrong?

It works better for me to learn things by comparison rather than reading a lot of theory. Probably some of my questions are naive, and already covered in some lengthy manual, but I will still ask them anyway if you don't mind. )

it's a huge font family, but most of the fonts are useless for those who never know that language.

Is the problem that unused fonts take too much space?

so it's not wise for me to develop a long fontconfig list for that and installed for every user.

What is the role of fontconfig list? Just installing the font is not enough to use that?

but they do not prepend a "emoji" alias in css, they just put emoji font along with sans-serif.

Meaning that they just show a symbol from a font that looks like emoji?

then we need to programmingly know what sans-serif are avaiable and what charaters they have, the intersected characters and so on.

So. the fontconfig scans installed fonts to see which codes from unicode tables are included? Then make an index for those symbols? If I understand it right, the fontconfig was invented before sqlite era. Is the problem that it is not optimized for performance at all? No multithreading, efficient database for indexes, etc.

@marguerite
Copy link
Owner

marguerite commented Jan 7, 2021

@abitrolly

  1. how to define "unused", for me (I'am Chinese, товарищ), I need only one Latin sans-serif font for my system display. but xorg-x11-fonts-core introduced many Latin fonts :-(

I found out you are a developer. so things may be easy for you to understand. on linux, application ask for a font (usually sans-serif), but there's no font with name "sans-serif" anywhere. it's an alias for a list. application just use the first one in that list as "sans-serif". then how to change the order of the list to make sure the 1st one is just the one you want? fontconfig does.

so you may have limited fonts installed on your system as I do, because Korean may be not our interests . but openSUSE has Korean users, right? as openSUSE developer, we have to make sure if a Korean user installs noto-sans-kr, he/she can display korean right away, and display it beautiful. then we need to pre-install fontconfig configuration for Korean fonts.

But, it's useless for you Russian/Ukrainian and me Chinese...

So, it's not because the unused fonts take too much space, but the unused configurations take too much parsing time and generate garbage at runtime. such "unsed" configuration is a must for a system, but not a must for your system.

fontconfig parses all configurations for the system. there's no way to selectively parse parts or some of them.

the new generattion tries to solve that problem. we try to provide configuration at runtime not at build time to reduce the garbage. of course there's another solution: ship the configuration for a single font with the single font. but the quality will be out of our control, and make it harder to maintain a font (I as a Chinese, I don't know what is "beautiful configuration" for Russian/Ukrainian, right?) and we will lose the whole picture, what if two fonts (one in factory and one in somebody's home) occasionally both declare to be the system default?

  1. the role for fontconfig list. if you have two Russian/Ukrainian font installed, A and B. then you will not know if a Russian/Ukrainian sentence is displayed with A or B. fontconfig let you choose A and B.

  2. font are shapes, one shape refers to one unicode point. emojis are special unicode points. browser css usually writes like this:
    "Noto Sans, sans-serif". there will be no "emoji" or "Noto Color Emoji" in that css at all. Current solution is to prepend "Noto Color Emoji" to the top of the sans-serif list. then the system reads the css like this: "Noto Sans, Noto Color Emoji, Russian/UkrainianSans, Chinese Sans, blabla".

if the page content has a char, system will try to see if Noto Color Emoji contains that char (unicode point) first, then check the Russian/Ukrainian font, then check the Chinese font. but if Noto Color Emoji has that char, Russian/Ukrainian will not be checked at all. So how you see the page depends on what the emoji font has. You may see Russian/Ukrainian displayed with Funny images :-)

that's the problem. as a solution, we have to put Emoji to the last part to make sure Russian/Ukrainian is displayed like Russian/Ukrainian. but your Russian/Ukrainiann font may have a unicode point represent "smile face" too. then we'll have to blacklist that unicode point in Russian/Ukrainian font to make sure smile face is displayed like Emoji. that is, no matter where emoji font is placed, it has to fight with normal fonts.

  1. fontconfig scans both installed fonts and configurations. it scans the fonts to get the unicode coverage information, it scans the configuration for which font to use. then application know which font to use first from fontconfig, then cairo/freetype2 stuff reads the unicode information, query the shape and display.

so the question is not about the scan stage (actually fonts-config-ng should avoid a second scan, we get all information from fontconfig directly to avoid the disk IO). it's about font based or unicode point based. applications are font based. you can not pick the shape represent A from all the font, then choose to display A with shape in A font and B with shape in B font. you ask for a font, and display eveything it can display with it. and display the undisplayed thing with another font.

@marguerite
Copy link
Owner

@abitrolly by the way you can show me the snap package and I can help with that, for the fontfonfig part.

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

No branches or pull requests

2 participants