Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hardwired baseline to match MapLibre behavior #20

Merged
merged 1 commit into from
Feb 21, 2023
Merged
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
10 changes: 6 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ void do_codepoint(protozero::pbf_writer &parent, std::vector<FT_Face> &faces, FT
glyph_message.add_uint32(1,static_cast<uint32_t>(char_code));
}

// double to int
double top = static_cast<double>(glyph.top) - glyph.ascender;
// node-fontnik uses glyph.top - glyph.ascender, assuming that the baseline
// will be based on the ascender. However, Mapbox/MapLibre shaping assumes
// a baseline calibrated on DIN Pro w/ ascender of ~25 at 24pt
int32_t top = glyph.top - 25;
if (top < numeric_limits<int32_t>::min() || top > numeric_limits<int32_t>::max()) {
throw runtime_error("Invalid value for glyph.top-glyph.ascender");
throw runtime_error("Invalid value for glyph.top-25");
} else {
glyph_message.add_sint32(6,static_cast<int32_t>(top));
glyph_message.add_sint32(6,top);
}

// double to uint
Expand Down