Skip to content

Commit

Permalink
Show kerning groups in the sidebar.
Browse files Browse the repository at this point in the history
  • Loading branch information
xorgy committed Apr 11, 2021
1 parent dd96bda commit 6084ca0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
53 changes: 53 additions & 0 deletions runebender-lib/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ pub struct GlyphDetail {
// the full outline, including things like components
pub outline: Arc<BezPath>,
metrics: FontMetrics,
pub kern1_group: String,
pub kern2_group: String,
is_placeholder: bool,
}

Expand Down Expand Up @@ -722,10 +724,27 @@ mod lenses {
let outline = state.font.get_bezier(&glyph.name);
let is_placeholder = outline.is_none();
let metrics = state.font.info.metrics.clone();
let mut kern1_group = "".to_string();
let mut kern2_group = "".to_string();
if let Some(gs) = &state.font.font.ufo.groups {
for (gk, gv) in gs.iter() {
if let Some(gn) = gk.strip_prefix("public.kern1.") {
if (*gv).iter().any(|n| *n == glyph.name) {
kern1_group = gn.to_string();
}
} else if let Some(gn) = gk.strip_prefix("public.kern2.") {
if (*gv).iter().any(|n| *n == glyph.name) {
kern2_group = gn.to_string();
}
}
}
}
GlyphDetail {
glyph,
outline: outline.unwrap_or_else(|| state.font.font.placeholder.clone()),
is_placeholder,
kern1_group,
kern2_group,
metrics,
}
}
Expand Down Expand Up @@ -762,10 +781,27 @@ mod lenses {
let outline = data.get_bezier(&glyph.name);
let is_placeholder = outline.is_none();
let metrics = data.info.metrics.clone();
let mut kern1_group = "".to_string();
let mut kern2_group = "".to_string();
if let Some(gs) = &data.font.ufo.groups {
for (gk, gv) in gs.iter() {
if let Some(gn) = gk.strip_prefix("public.kern1.") {
if (*gv).iter().any(|n| *n == glyph.name) {
kern1_group = gn.to_string();
}
} else if let Some(gn) = gk.strip_prefix("public.kern2.") {
if (*gv).iter().any(|n| *n == glyph.name) {
kern2_group = gn.to_string();
}
}
}
}
GlyphDetail {
glyph: Arc::clone(glyph),
outline: outline.unwrap_or_else(|| data.font.placeholder.clone()),
metrics,
kern1_group,
kern2_group,
is_placeholder,
}
});
Expand All @@ -786,10 +822,27 @@ mod lenses {
let outline = data.get_bezier(&glyph.name);
let is_placeholder = outline.is_none();
let metrics = data.info.metrics.clone();
let mut kern1_group = "".to_string();
let mut kern2_group = "".to_string();
if let Some(gs) = &data.font.ufo.groups {
for (gk, gv) in gs.iter() {
if let Some(gn) = gk.strip_prefix("public.kern1.") {
if (*gv).iter().any(|n| *n == glyph.name) {
kern1_group = gn.to_string();
}
} else if let Some(gn) = gk.strip_prefix("public.kern2.") {
if (*gv).iter().any(|n| *n == glyph.name) {
kern2_group = gn.to_string();
}
}
}
}
GlyphDetail {
glyph: Arc::clone(glyph),
outline: outline.unwrap_or_else(|| data.font.placeholder.clone()),
metrics,
kern1_group,
kern2_group,
is_placeholder,
}
});
Expand Down
4 changes: 2 additions & 2 deletions runebender-lib/src/widgets/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ fn selected_glyph_widget() -> impl Widget<GlyphDetail> {
.with_child(
Flex::row()
.with_child(
Label::new("kern group")
Label::dynamic(|d: &GlyphDetail, _| (*d.kern2_group).to_string())
.with_text_color(theme::SECONDARY_TEXT_COLOR)
.with_font(theme::UI_DETAIL_FONT),
)
.with_flex_spacer(1.0)
.with_child(
Label::new("kern group")
Label::dynamic(|d: &GlyphDetail, _| (*d.kern1_group).to_string())
.with_text_color(theme::SECONDARY_TEXT_COLOR)
.with_font(theme::UI_DETAIL_FONT),
)
Expand Down

0 comments on commit 6084ca0

Please sign in to comment.