maplibre/legacy/
font_stack.rs

1//! Translated from https://github.com/maplibre/maplibre-native/blob/4add9ea/src/mbgl/util/font_stack.cpp
2
3use std::collections::BTreeSet;
4
5use crate::{legacy::util::hash_combine, style::layer::StyleLayer};
6
7// An array of font names
8/// maplibre/maplibre-native#4add9ea original name: FontStack
9pub type FontStack = Vec<String>;
10/// maplibre/maplibre-native#4add9ea original name: FontStackHash
11pub type FontStackHash = u64;
12
13/// maplibre/maplibre-native#4add9ea original name: FontStackHasher
14pub struct FontStackHasher;
15
16impl FontStackHasher {
17    /// maplibre/maplibre-native#4add9ea original name: new
18    pub fn new(font_stack: &FontStack) -> u64 {
19        let mut seed = 0;
20        for font in font_stack {
21            hash_combine(&mut seed, font);
22        }
23        seed
24    }
25}
26
27/// maplibre/maplibre-native#4add9ea original name: fontStackToString
28pub fn font_stack_to_string(font_stack: &FontStack) -> String {
29    font_stack.join(",")
30}
31
32/// Statically evaluate layer properties to determine what font stacks are used.
33/// maplibre/maplibre-native#4add9ea original name: fontStacks
34pub fn font_stacks(layers: &Vec<StyleLayer>) -> BTreeSet<FontStack> {
35    let mut result = BTreeSet::new();
36    for layer in layers {
37        populate_font_stack(layer, &mut result);
38    }
39
40    result
41}
42
43/// maplibre/maplibre-native#4add9ea original name: populateFontStack
44pub(crate) fn populate_font_stack(layer: &StyleLayer, stack: &mut BTreeSet<FontStack>) {
45    todo!()
46}