Print font name when selecting character
This commit is contained in:
parent
210622d084
commit
a50294676d
3 changed files with 14 additions and 3 deletions
|
|
@ -38,7 +38,9 @@ impl FontLineIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Font<'a> {
|
pub struct Font<'a> {
|
||||||
data: &'a [u8],
|
pub name: &'a str,
|
||||||
|
pub data: &'a [u8],
|
||||||
|
pub index: u32,
|
||||||
pub rustybuzz: rustybuzz::Face<'a>,
|
pub rustybuzz: rustybuzz::Face<'a>,
|
||||||
#[cfg(feature = "ab_glyph")]
|
#[cfg(feature = "ab_glyph")]
|
||||||
pub ab_glyph: ab_glyph::FontRef<'a>,
|
pub ab_glyph: ab_glyph::FontRef<'a>,
|
||||||
|
|
@ -52,9 +54,11 @@ pub struct Font<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Font<'a> {
|
impl<'a> Font<'a> {
|
||||||
pub fn new(data: &'a [u8], index: u32) -> Option<Self> {
|
pub fn new(name: &'a str, data: &'a [u8], index: u32) -> Option<Self> {
|
||||||
Some(Self {
|
Some(Self {
|
||||||
|
name,
|
||||||
data,
|
data,
|
||||||
|
index,
|
||||||
rustybuzz: rustybuzz::Face::from_slice(data, index)?,
|
rustybuzz: rustybuzz::Face::from_slice(data, index)?,
|
||||||
#[cfg(feature = "ab_glyph")]
|
#[cfg(feature = "ab_glyph")]
|
||||||
ab_glyph: ab_glyph::FontRef::try_from_slice_and_index(data, index).ok()?,
|
ab_glyph: ab_glyph::FontRef::try_from_slice_and_index(data, index).ok()?,
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ impl FontSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
let font_opt = Font::new(
|
let font_opt = Font::new(
|
||||||
|
&face.post_script_name,
|
||||||
match &face.source {
|
match &face.source {
|
||||||
fontdb::Source::Binary(data) => {
|
fontdb::Source::Binary(data) => {
|
||||||
data.deref().as_ref()
|
data.deref().as_ref()
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,13 @@ fn main() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let text_line = &buffer.text_lines()[line.line_i.get()];
|
let text_line = &buffer.text_lines()[line.line_i.get()];
|
||||||
eprintln!("{}, {}: '{}'", glyph.start, glyph.end, &text_line[glyph.start..glyph.end]);
|
eprintln!(
|
||||||
|
"{}, {}: '{}': '{}'",
|
||||||
|
glyph.start,
|
||||||
|
glyph.end,
|
||||||
|
glyph.font.name,
|
||||||
|
&text_line[glyph.start..glyph.end],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue