diff --git a/.github/files/lambda-function/config.yaml b/.github/files/lambda-function/config.yaml index 36cdfa5c9..f13cf337e 100644 --- a/.github/files/lambda-function/config.yaml +++ b/.github/files/lambda-function/config.yaml @@ -1,3 +1,6 @@ pmtiles: sources: webp2: ./webp2.pmtiles + # if lambdas are added/removed for one request, + # caching needs to be done externally +cache_size_mb: 0 diff --git a/.github/files/lambda.yaml b/.github/files/lambda.yaml index 7baaf448a..57b59f05e 100644 --- a/.github/files/lambda.yaml +++ b/.github/files/lambda.yaml @@ -17,3 +17,4 @@ Resources: - Ref: MartinLayer CodeUri: lambda-function/ Handler: config.yaml + MemorySize: 350 diff --git a/martin-core/src/resources/fonts/mod.rs b/martin-core/src/resources/fonts/mod.rs index 4b84a000f..9ff5f1295 100644 --- a/martin-core/src/resources/fonts/mod.rs +++ b/martin-core/src/resources/fonts/mod.rs @@ -32,8 +32,12 @@ use pbf_font_tools::{Fontstack, Glyphs, render_sdf_glyph}; use regex::Regex; use serde::{Deserialize, Serialize}; -/// Maximum Unicode codepoint supported (U+FFFF - Basic Multilingual Plane). -const MAX_UNICODE_CP: usize = 0xFFFF; +/// Maximum Unicode codepoint supported. +/// +/// Although U+FFFF covers the Basic Multilingual Plane, the Unicode standard +/// allows to use up to U+10FFFF, including for private use. +/// (cf. ) +const MAX_UNICODE_CP: usize = 0x0010_FFFF; /// Size of each Unicode codepoint range (256 characters). const CP_RANGE_SIZE: usize = 256; /// Font size in pixels for SDF glyph rendering. @@ -367,3 +371,28 @@ fn parse_font( Ok(()) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_get_available_codepoints() { + let lib = Library::init().unwrap(); + + // U+3320: SQUARE SANTIIMU, U+1F60A: SMILING FACE WITH SMILING EYES + for codepoint in [0x3320, 0x1f60a] { + let font_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join(format!("src/resources/fonts/tests/u+{codepoint:x}.ttf")); + assert!(font_path.is_file()); // make sure the file path is correct + + let mut face = lib.new_face(&font_path, 0).unwrap(); + + let (_codepoints, count, _ranges, first, last) = + get_available_codepoints(&mut face).unwrap(); + assert_eq!(count, 1); + assert_eq!(format!("U+{first:X}"), format!("U+{codepoint:X}")); + assert_eq!(format!("U+{last:X}"), format!("U+{codepoint:X}")); + } + } +} diff --git a/martin-core/src/resources/fonts/tests/u+1f60a.ttf b/martin-core/src/resources/fonts/tests/u+1f60a.ttf new file mode 100644 index 000000000..b61c4bf8c Binary files /dev/null and b/martin-core/src/resources/fonts/tests/u+1f60a.ttf differ diff --git a/martin-core/src/resources/fonts/tests/u+3320.ttf b/martin-core/src/resources/fonts/tests/u+3320.ttf new file mode 100644 index 000000000..388023713 Binary files /dev/null and b/martin-core/src/resources/fonts/tests/u+3320.ttf differ diff --git a/tests/expected/auto/catalog_auto.json b/tests/expected/auto/catalog_auto.json index eb27e1951..7c0fb22e8 100644 --- a/tests/expected/auto/catalog_auto.json +++ b/tests/expected/auto/catalog_auto.json @@ -1,16 +1,16 @@ { "fonts": { "Overpass Mono Light": { - "end": 64258, + "end": 128276, "family": "Overpass Mono", - "glyphs": 931, + "glyphs": 934, "start": 0, "style": "Light" }, "Overpass Mono Regular": { - "end": 64258, + "end": 128276, "family": "Overpass Mono", - "glyphs": 931, + "glyphs": 934, "start": 0, "style": "Regular" } diff --git a/tests/expected/configured/catalog_cfg.json b/tests/expected/configured/catalog_cfg.json index 49234405e..720b54d2f 100644 --- a/tests/expected/configured/catalog_cfg.json +++ b/tests/expected/configured/catalog_cfg.json @@ -1,16 +1,16 @@ { "fonts": { "Overpass Mono Light": { - "end": 64258, + "end": 128276, "family": "Overpass Mono", - "glyphs": 931, + "glyphs": 934, "start": 0, "style": "Light" }, "Overpass Mono Regular": { - "end": 64258, + "end": 128276, "family": "Overpass Mono", - "glyphs": 931, + "glyphs": 934, "start": 0, "style": "Regular" }