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 |
|
@david-vanderson I have been working on the database changes i mentioned in a previous conversation on discord, id like to know if this path works for you or if i should try going in another direction. |
I'm very unsure myself. The variable/family feels a bit weird to have a hashmap inside the hashmap, but makes some sense. I suspect the problem point will be font fallback. Seems like the idea is to have a list of family names, so that level of fallback makes sense. But how do you deal with falling back to a family that doesn't have the given style/weight? |
|
I will say My idea for fallback is the following:
In my opinion fallbacks are something that should be implemented on the caller side (in this case, in the font rendering pipeline), usually when one asks a cache or database for an entry you want to get that exact entry and not a related one, yes this adds a "step in between" if you will but makes it a more flexible api. |
|
That sounds mostly right to me, but I don't have a sense for how the code would do the fallbacks:
I agree that usually we want fallbacks to be specified by the usage code. But there are cases (like a note-taking app) where the code wants to say "let the user pick any font on the system, and fallback to other system fonts as needed". I don't know how much we need to worry about that right now. I'm worried we're trying to do too much at once here, and I'm having trouble nailing down specifics. Can we set an intermediate goal of just dealing with weight/style/underline/strike and deal with the fallback stuff separately? |
Yes, if there is a variable font thete is no need to have different variants, however maybe this is not ideal, i know a few families that have different variable fonts but im unsure on hlw they differ from each other and how we could make that distinction too.
I dont think this is necessary but i have not gotten to it yet so maybe it might endup that way.
Absolutely; altough the db/cache changes are still necessary fallback doesnt need to be implemented for that to happen. |
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.