Draft: Separate text styling from Font#862
Conversation
It did compile but... idk why i thought this would work tbh
|
I have made some very very rough changes for it to compile* using
I'd like some feedback/input before i move forward with some more deep changes to address the above (and other) issues. * Due to how |
|
The current state of my draft is also making me question if there is any reason for |
|
Currently I'm confused, so this is confused feedback. I thought the idea was to separate Font from styling, but FontStyle seems to smoosh them together?
This is something we need to nail down. The reason I separated them is that a single Font.Source can back multiple Fonts. Example is font size - each size uses the same underlying Font.Source, but has to rasterize separately so we need extra machinery. Unlike line_height_factor which we can on-the-fly adjust for any Font. So the idea is that Font.Source roughly corresponds to a font file. Font is the way code asks for a particular instance. In the future with glyph fallback rendering a Font might pull from multiple Font.Source. Given that, I thought text styling would be things that can apply to any font, like underline, strikethrough, and (in the future) shadow. Is that what you are thinking? I think we need a few concrete usecases for me to understand the intention. I'm imagining something like:
Is that the primary way you see this working?
Yes good point, will think about this.
I'm unsure if messing with opacity makes sense (by default). Maybe we should do more color mixing?
Yeah - don't worry about this yet. |
This does make more sense, given I think this distinction makes sense; and the glaring problem i see in my draft is that due to the size "issue" you mentioned (that only applies to freetype) The solution i see for it is to keep font as a way to get an instance of a font with certain properties, however we can change the api to be easier to use (like no more So This changes would also means that my proposal would turn into recoding and renaming
Coloring (fills, borders, etc) are also part of styling and, as it stands right now, there is no easy way to customize things like Even something like text outline/border i think would be very weird to be implemented on the current
To put it in a very simple form, the idea is to have a construct that is reusable, easy to use/understand, and can define/alter any property related to text. As currently the only way to do something like this is to keep entire |
|
I'm somewhat following.
It's hard to get details right unless we can describe in detail the usecases you need. I suspect most of this is driven by the markdown rendering right? My guess is that the main problem there is how to combine information from the theme (font family name and base size?) with info coming from markdown (bold, italic, underline, how much bigger/smaller than base etc.). Is that in the right direction? |
For example,
Partially yes, i had some problems before that could be adressed with hacks like duplicating the theme and modifying it but they always felt very ugly and not very easy to maintain. As i have mentioned before; in the app im working on i want to allow users to create their own themes, the problem with that is that due to the hacks required there is no viable way to do that besides having my own theme on top of dvui's theme which cannot be used internally by dvui and would require a bunch of workarounds and wasted memory to work as one would expect as a user. One other thing that is a problem is font fallback (which dvui doesnt support yet) in the current system i find it very hard to see a user friendly way to implement such for the reason that the user might (and most likely will) want different fallbacks for different parts of the application, one simple example being emojis, you might want one part of the app to use colored emojis and another to use monochrome emojis, and complexity can spiral from there. If this was to be done via |
Okay this is starting to make sense to me. So you want to define a style like "second-level heading" or "hyperlink" that can be applied to any Then style modifies the font (default) you get from the theme (or callsite) by adjusting:
If the user changes the theme, that would change the underlying font (and default size), but the "second-level heading" style would still adjust things? Sounds like we might have to duplicate some features across |
|
Ideally, This is why i think The only fonts defined in the |
Initial draft for #849
There are naming issues,
Styleended up not being the best of ideas, going withFontStylefor now but perhaps something likeTextStylewould be more ideal.As of opening the draft it only includes a rough idea of what
FontStyleis aiming to be, a way to unify font style in a place independent from the font itself.