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

Reproduce lfPitchAndFamily ET lfCharSet #43

Open
moi15moi opened this issue Apr 29, 2024 · 0 comments
Open

Reproduce lfPitchAndFamily ET lfCharSet #43

moi15moi opened this issue Apr 29, 2024 · 0 comments

Comments

@moi15moi
Copy link
Owner

FontCollector tries to reproduce what VSFilter does. VSFilter uses GDI to select a font and display it, so we need to emulate it.
We already properly emulate the score for the lfWeight and lfItalic attributes, but we don't emulate the score for lfPitchAndFamily and lfCharSet.

99% of the time, these properties don't affect the font that will be picked up. In general, they can affect the font picked up when the user has two fonts that are the same, but one is TrueType and the other is OpenType.

lfPitchAndFamily score algorithm

font_family = FF_DECORATIVE, FF_DONTCARE, FF_MODERN, FF_ROMAN, FF_SCRIPT or FF_SWISS
requested_family = is it always FF_DONTCARE
requested_charset = Depend on \fe tag or the ass style
if (jMapCharSet == SYMBOL_CHARSET) {
	requested_family = font_family
} else if (font_family != FF_DONTCARE) {
	requested_family = FF_SWISS // Technically, if the requested font is "Tms Rmn", it will be FF_ROMAN, but I am not sure if we want this behavior
}

if (requested_family != font_family) {
	if (font_family == FF_DONTCARE) {
		score += 8000;
	} else {
		if (font_family  > FF_MODERN) {
			score += 50;
		}
		score += 9000;
	}
}

lfCharSet score algorithm

requested_charset = Depend on \fe tag or the ass style
font_charsets = list of charset
if requested_charset != DEFAULT_CHARSET and requested_charset not in font_charsets:
	REJECT the font

I still don't fully understand how GDI sets lfCharSet and lfPitchAndFamily, so I will need to dig deeper before I can implement it.

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

1 participant