-
Notifications
You must be signed in to change notification settings - Fork 94
Implement checking if the font familly exists in pango #455
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
7218cf2
43796b3
eb7b455
b3d9b85
f0e6f1c
6291c38
154eaf6
1ff7276
1101f30
f413247
d21f23a
7ca9372
88ccad2
bb0a741
0372651
720c44c
4f1fdbc
7eb17e8
bcedb2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ use std::rc::Rc; | |
|
||
use glib::translate::{from_glib_full, ToGlibPtr}; | ||
|
||
use pango::prelude::FontFamilyExt; | ||
use pango::prelude::FontMapExt; | ||
use pango::AttrList; | ||
use pango_sys::pango_attr_insert_hyphens_new; | ||
|
@@ -166,7 +167,12 @@ impl Text for CairoText { | |
type TextLayoutBuilder = CairoTextLayoutBuilder; | ||
|
||
fn font_family(&mut self, family_name: &str) -> Option<FontFamily> { | ||
//TODO: Veryify that a family exists with the requested name | ||
// The pango documentation says this is always a stirng, and never null. I trust them on that. | ||
// Would be weird to have a font family without a name anyways. | ||
self.pango_context | ||
.list_families() | ||
.iter() | ||
.find(|family| family.name().unwrap().as_str() == family_name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a note: a fancier version of this might do things like return Additionally, it looks like we aren't using this check? If we don't find the font we should return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What check do you mean? I can add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I mean is that we're looking at the families to see if We may also want to keep around a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for fun here are some useful guidelines on font matching: https://drafts.csswg.org/css-fonts-3/#font-matching-algorithm There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I feel really stupid now. I just noticed this as well while looking at the code again. As for the matching, I am honestly not sure how I would go about implementing that. Stripping away all the stuff we dont have/need, im left with the only restriction being "a case insensitive match". it should be easy to match case insensitively, but that doesnt solve the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There exists a function in pango for matching, I just use that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a change you're going to make, or is it in the current version? I didn't see it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I currently made a change so that it uses the pango matching function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (the |
||
Some(FontFamily::new_unchecked(family_name)) | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.