Skip to content

Commit 42549d1

Browse files
Merge pull request #7 from stadiamaps/named-font-stack
Add the ability to explicitly name the font stack; upgrade freetype.
2 parents 3ca39a1 + 36af025 commit 42549d1

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pbf_font_tools"
3-
version = "2.1.0"
3+
version = "2.2.0"
44
authors = ["Ian Wagner <ian@stadiamaps.com>", "Luke Seelenbinder <luke@stadiamaps.com>"]
55
license = "BSD-3-Clause"
66
repository = "https://github.com/stadiamaps/pbf_font_tools"
@@ -9,6 +9,7 @@ description = "Tools for working with SDF font glyphs encoded in protobuf format
99
keywords = ["sdf", "protobuf", "fonts"]
1010
categories = ["encoding", "parsing", "rendering::data-formats"]
1111
edition = "2021"
12+
exclude = [".github/"]
1213

1314
[features]
1415
freetype = ["freetype-rs", "sdf_glyph_renderer/freetype"]
@@ -27,11 +28,11 @@ protobuf-codegen = "3.0.3"
2728
protoc-bin-vendored = "3.0.0"
2829

2930
[dependencies.freetype-rs]
30-
version = "0.30.1"
31+
version = "0.31.0"
3132
optional = true
3233

3334
[dependencies.sdf_glyph_renderer]
34-
version = "0.3.0"
35+
version = "0.4.0"
3536
optional = true
3637

3738
[dev-dependencies.tokio]

src/lib.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ type GlyphResult = Result<glyphs::Glyphs, protobuf::Error>;
2929
/// See the documentation for `combine_glyphs` for further details.
3030
/// Unlike `combine_glyphs`, the result of this method will always contain a `glyphs` message,
3131
/// even if the loaded range is empty for a given font.
32-
pub async fn get_font_stack(
32+
pub async fn get_named_font_stack(
3333
font_path: &Path,
3434
font_names: &[&str],
35+
stack_name: String,
3536
start: u32,
3637
end: u32,
3738
) -> GlyphResult {
@@ -53,14 +54,24 @@ pub async fn get_font_stack(
5354
let mut result = glyphs::Glyphs::new();
5455

5556
let mut stack = glyphs::Fontstack::new();
56-
stack.set_name(font_names.join(", "));
57+
stack.set_name(stack_name);
5758
stack.set_range(format!("{start}-{end}"));
5859

5960
result.stacks.push(stack);
6061
result
6162
}))
6263
}
6364

65+
pub async fn get_font_stack(
66+
font_path: &Path,
67+
font_names: &[&str],
68+
start: u32,
69+
end: u32,
70+
) -> GlyphResult {
71+
let stack_name = font_names.join(", ");
72+
get_named_font_stack(font_path, font_names, stack_name, start, end).await
73+
}
74+
6475
/// Loads a single font PBF slice from disk.
6576
///
6677
/// Fonts are assumed to be stored in <font_path>/<font_name>/<start>-<end>.pbf.

0 commit comments

Comments
 (0)