These are chat archives for AvaloniaUI/Avalonia

9th
Jun 2018
ahopper
@ahopper
Jun 09 2018 08:09
what is involved in supporting color fonts https://www.colorfonts.wtf/ ?
Benedikt Schroeder
@Gillibald
Jun 09 2018 09:51
DirectWrite only supports color fonts sinse late windows 10. I can't say if skia handles them but most likely not. Maybe when we introduce a text rendering backend in the future we can support them. But that will probably take a while.
ahopper
@ahopper
Jun 09 2018 10:30
once we have svg support will we be able to display them as drawings, they look like another good source of icons
Nelson Carrillo
@nc4rrillo
Jun 09 2018 15:50
Skia supports color fonts
setEmbeddedBitmapText(bool) toggles the support on/off
Nelson Carrillo
@nc4rrillo
Jun 09 2018 16:07
our Skia backend seems to already support it (???) if I try to render a "Segoe UI Emoji" glyph it gives me the colored version
Benedikt Schroeder
@Gillibald
Jun 09 2018 17:21
I can confirm that color fonts work with our Direct2D1 backend. Some changes are required but these aren't big. These changes even remove some dead code from the project because the TextRenderer implementation isnt used. Will create a PR to support color fonts for Direct2D1.
ahopper
@ahopper
Jun 09 2018 17:59
great :+1:
Benedikt Schroeder
@Gillibald
Jun 09 2018 18:39
Dont know if that worked before but now we have fallbacks for non present glyphs. Now you can use emojis everywhere you want and they just work. But this is only available with DirectWrite. We would have to use HarfBuzz to add that feature to Skia.
Nelson Carrillo
@nc4rrillo
Jun 09 2018 18:51
Question: LinearGradientBrushes don't have a MappingMode, but the Parse function for RelativePoint seems to switch to relative units if a % is included in the Start/Stop points
Is this documented anywhere? I think that's a fairly significant departure from WPF
Nelson Carrillo
@nc4rrillo
Jun 09 2018 19:00
I also don't understand why the scale factor is 0.01 when using relative units
Nelson Carrillo
@nc4rrillo
Jun 09 2018 19:05
Basically I'm trying to set the foreground of a text run to be a linear gradient. if I change that to 1.0, and scale the offsets in the gradient stops by the size of the text run, then I get the intended effect.
also we don't currently support text decorations it seems :(
Benedikt Schroeder
@Gillibald
Jun 09 2018 19:42
Text decorations are indeed missing
Just realised TextRenderer is an interface
Nelson Carrillo
@nc4rrillo
Jun 09 2018 19:47
yeah, its a bit more convoluted
https://msdn.microsoft.com/en-us/library/windows/desktop/mt765165(v=vs.85).aspx is a good write up on Color Fonts in DWrite and what to do to support them
The relevant bit is the code that uses the lower level API
Benedikt Schroeder
@Gillibald
Jun 09 2018 19:55
Selection still works with my changes. Am i missing something?
Nelson Carrillo
@nc4rrillo
Jun 09 2018 20:02
does the foreground color change on the selected text
TextPresenter uses a FormattedTextSpan to change the foreground color of selected text on the fly
The FormattedText object, which contains FormattedTextSpans are passed to the platform impl
and those get fed to the FormattedTextImpl and used in ApplySpans
Nelson Carrillo
@nc4rrillo
Jun 09 2018 20:10
I think if you want to not use the AvaloniaTextRender you'd need to keep track of which brushes apply to which spans of text, the Skia backend does this and its complicated
Benedikt Schroeder
@Gillibald
Jun 09 2018 20:10
That does't work i will change the AvaloniaTextRenderer to support color fonts
Seems i cant avoid TextRenderer
Still dont understand why effect dont work with the default
Nelson Carrillo
@nc4rrillo
Jun 09 2018 20:11
I think its less work to just make TextRenderer aware of color glyphs
Benedikt Schroeder
@Gillibald
Jun 09 2018 20:13
We lose a lot by using TextRender or atleast we have to implement a lot on our own
Will check if glyph fallbacks still work
Nelson Carrillo
@nc4rrillo
Jun 09 2018 20:15
sharpdx/SharpDX#1017 has support for TranslateColorGlyphRun
you pass the GlyphRun in the DrawGlyphRun method of TextRenderer
and you get back a ColorGlyphRunEnumerator
Benedikt Schroeder
@Gillibald
Jun 09 2018 20:17
Thats probably the reason why this worked already with skia
Nelson Carrillo
@nc4rrillo
Jun 09 2018 20:18
Skia I'm not sure what it does behind the scenes, because I've set Bitmap font support on SkPaint to false and it still works (!?)
but who even knows
TextRenderer is also likely required for things like text decorations though
Nelson Carrillo
@nc4rrillo
Jun 09 2018 23:22
Yikes @Gillibald saw your comment about SharpDX not being fully baked w.r.t color glyphs
I can experiment with what it'll take to wrap the missing methods
Benedikt Schroeder
@Gillibald
Jun 09 2018 23:26
Looks like the current TextRenderer is not properly implemented. If i change the implementation to use a PathGeometry etc selection and Placement of text is working as expected. Will play with that a bit more.
I wonder if we can register the newest factory versions available at startup. I always have to query for newer versions.
Nelson Carrillo
@nc4rrillo
Jun 09 2018 23:27
I wonder if we can use CreateAlphaTexture to create an alpha mask of the glyph and just render through that, it may be a great bit more complex
otherwise it looks like wrapping this new API would be the way to go