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
feat(components): move font styling out of Style and use families #879
Conversation
let fromFile: (~variant: variantSolver=?, string) => t; | ||
let system: string => t; | ||
|
||
let default: t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! It's great to finally have a default!
let weight = _ => 1; | ||
}; | ||
|
||
module FontFamilyCache = Lru.M.Make(FontFamilyHashable, FontDescriptorWeight); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to use the LruCache, to help bound the number of familes we keep in memory!
) | ||
}; | ||
|
||
module FontFamilyHashable = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍 It's great that these implementation details aren't exposed to consumers of the FontFamily
module - this is all tucked away behind the interface.
val mutable _fontFamily = Family.default; | ||
val mutable _fontWeight = Weight.Normal; | ||
val mutable _italicized = false; | ||
val mutable _monospaced = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding these!
pub setFontFamily = fontFamily => { | ||
if (_fontFamily !== fontFamily) { | ||
_this#markLayoutDirty(); | ||
}; | ||
_fontFamily = fontFamily; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the work to wire this up!
*. Text.getLineHeight( | ||
~fontFamily= | ||
Family.toPath( | ||
_fontFamily, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to think about is, maybe later, we could have the Family
return a Font.t
directly. Not a blocker for this change, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't wait to have a real concept of font families!
I have updated your lock dirs and formatted the code. |
let equal = (a, b) => | ||
String.equal(a.familyName, b.familyName) | ||
&& a.weight == b.weight | ||
&& a.italicized == b.italicized | ||
&& a.monospaced == b.monospaced; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity, why not just a == b
? Does String.equal
differ in behaviour from ==
?
This creates a couple API changes:
FontFamily
with at
that can be made withsystem
andfromFile
FontProps
with family, weight, italicized, and monospaced informationFontProps
directly on theText
component/node