Repository: servo/servo
File: components/fonts/platform/freetype/font_list.rs (Rust)

Code before:
                None,
                None,
            ))
        }

        FcFontSetDestroy(matches);
        FcPatternDestroy(pattern);
        FcObjectSetDestroy(object_set);
    }
}

// Based on gfxPlatformGtk::GetCommonFallbackFonts() in Gecko
pub fn fallback_font_families(options: FallbackFontSelectionOptions) -> Vec<&'static str> {
    let mut families = Vec::new();
    if options.presentation_preference == EmojiPresentationPreference::Emoji {
        families.push("Noto Color Emoji");
    }

    add_noto_fallback_families(options.clone(), &mut families);

    if let Some(block) = options.character.block() {
        match block {
            // In Japanese typography, it is not common to use different fonts
            // for Kanji(Han), Hiragana, and Katakana within the same document.
            // We uniformly fallback to Japanese fonts when the document language is Japanese.
            _ if options.lang == XLang("ja".into()) => {
                families.push("TakaoPGothic");
            },
            _ if matches!(
                Script::from(options.character),
                Script::Bopomofo | Script::Han
            ) && options.lang != XLang("ja".into()) =>
            {
                families.push("WenQuanYi Micro Hei");
            },
            UnicodeBlock::HalfwidthandFullwidthForms |
            UnicodeBlock::EnclosedIdeographicSupplement => families.push("WenQuanYi Micro Hei"),
            UnicodeBlock::Hiragana |
            UnicodeBlock::Katakana |
            UnicodeBlock::KatakanaPhoneticExtensions => {
                families.push("TakaoPGothic");
            },
            _ => {},
        }
    }

    families.push("DejaVu Serif");
    families.push("FreeSerif");
    families.push("DejaVu Sans");
    families.push("DejaVu Sans Mono");
    families.push("FreeSans");

Review comment (suggestion):
Fine either way, but maybe more clear like

```suggestion
            _ if options.lang == XLang(atom!("ja")) => {
```

Code after:
                None,
                None,
            ))
        }

        FcFontSetDestroy(matches);
        FcPatternDestroy(pattern);
        FcObjectSetDestroy(object_set);
    }
}

// Based on gfxPlatformGtk::GetCommonFallbackFonts() in Gecko
pub fn fallback_font_families(options: FallbackFontSelectionOptions) -> Vec<&'static str> {
    let mut families = Vec::new();
    if options.presentation_preference == EmojiPresentationPreference::Emoji {
        families.push("Noto Color Emoji");
    }

    add_noto_fallback_families(options.clone(), &mut families);

    if let Some(block) = options.character.block() {
        match block {
            // In Japanese typography, it is not common to use different fonts
            // for Kanji(Han), Hiragana, and Katakana within the same document.
            // We uniformly fallback to Japanese fonts when the document language is Japanese.
            _ if options.lang == XLang(Atom::from("ja")) => {
                families.push("TakaoPGothic");
            },
            _ if matches!(
                Script::from(options.character),
                Script::Bopomofo | Script::Han
            ) && options.lang != XLang(Atom::from("ja")) =>
            {
                families.push("WenQuanYi Micro Hei");
            },
            UnicodeBlock::HalfwidthandFullwidthForms |
            UnicodeBlock::EnclosedIdeographicSupplement => families.push("WenQuanYi Micro Hei"),
            UnicodeBlock::Hiragana |
            UnicodeBlock::Katakana |
            UnicodeBlock::KatakanaPhoneticExtensions => {
                families.push("TakaoPGothic");
            },
            _ => {},
        }
    }

    families.push("DejaVu Serif");
    families.push("FreeSerif");
    families.push("DejaVu Sans");
    families.push("DejaVu Sans Mono");
    families.push("FreeSans");