Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/files/lambda-function/config.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .github/files/lambda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Resources:
- Ref: MartinLayer
CodeUri: lambda-function/
Handler: config.yaml
MemorySize: 350
33 changes: 31 additions & 2 deletions martin-core/src/resources/fonts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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. <https://en.wikipedia.org/wiki/Unicode_block>)
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.
Expand Down Expand Up @@ -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
Comment thread
yutannihilation marked this conversation as resolved.
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}"));
}
}
}
Binary file added martin-core/src/resources/fonts/tests/u+1f60a.ttf
Binary file not shown.
Binary file added martin-core/src/resources/fonts/tests/u+3320.ttf
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/expected/auto/catalog_auto.json
Original file line number Diff line number Diff line change
@@ -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"
}
Expand Down
8 changes: 4 additions & 4 deletions tests/expected/configured/catalog_cfg.json
Original file line number Diff line number Diff line change
@@ -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"
}
Expand Down
Loading