Skip to content

Reproduce lfPitchAndFamily ET lfCharSet #43

Description

@moi15moi

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions