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 units_per_em for default caret_slope_rise #637

Merged
merged 1 commit into from
Dec 7, 2023
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
21 changes: 8 additions & 13 deletions fontir/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,19 +405,14 @@ impl GlobalMetrics {
let x_height = x_height.unwrap_or(0.5 * units_per_em as f32);
set(GlobalMetric::XHeight, x_height);

// https://github.com/googlefonts/ufo2ft/blob/0d2688cd847d003b41104534d16973f72ef26c40/Lib/ufo2ft/fontInfoData.py#L133-L150
// https://github.com/googlefonts/ufo2ft/blob/0d2688cd847d003b41104534d16973f72ef26c40/Lib/ufo2ft/fontInfoData.py#L153-L163
if italic_angle == 0.0 {
set(GlobalMetric::CaretSlopeRise, 1.0);
set(GlobalMetric::CaretSlopeRun, 0.0);
} else {
let slope_rise = 1000.0;
set(GlobalMetric::CaretSlopeRise, slope_rise);
set(
GlobalMetric::CaretSlopeRun,
adjust_offset(slope_rise, italic_angle),
);
}
// https://github.com/googlefonts/ufo2ft/blob/150c2d6a00da9d5854173c8457a553ce03b89cf7/Lib/ufo2ft/fontInfoData.py#L133-L148
// https://github.com/googlefonts/ufo2ft/blob/150c2d6a00da9d5854173c8457a553ce03b89cf7/Lib/ufo2ft/fontInfoData.py#L151-L161
let slope_rise = units_per_em as f32;
set(GlobalMetric::CaretSlopeRise, slope_rise);
set(
GlobalMetric::CaretSlopeRun,
adjust_offset(slope_rise, italic_angle),
);

// https://github.com/googlefonts/ufo2ft/blob/0d2688cd847d003b41104534d16973f72ef26c40/Lib/ufo2ft/fontInfoData.py#L367
set(GlobalMetric::CaretOffset, 0.0);
Expand Down
2 changes: 1 addition & 1 deletion glyphs2fontir/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1470,7 +1470,7 @@ mod tests {
pos: static_metadata.default_location().clone(),
ascender: 737.0.into(),
descender: (-42.0).into(),
caret_slope_rise: 1.0.into(),
caret_slope_rise: 1000.0.into(),
cap_height: 702.0.into(),
x_height: 501.0.into(),
subscript_x_size: 650.0.into(),
Expand Down
2 changes: 1 addition & 1 deletion ufo2fontir/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1773,7 +1773,7 @@ mod tests {
pos: static_metadata.default_location().clone(),
ascender: 737.0.into(),
descender: (-42.0).into(),
caret_slope_rise: 1.0.into(),
caret_slope_rise: 1000.0.into(),
cap_height: 702.0.into(),
x_height: 501.0.into(),
subscript_x_size: 650.0.into(),
Expand Down