-
-
Notifications
You must be signed in to change notification settings - Fork 777
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
Implement device font rendering #1862
Comments
I think this also covers #1724 |
I started trying to have a look at this, and I was trying to understand where to start. I found some code for identifying the best match font available in use font_kit::properties::Properties;
use font_kit::source::SystemSource;
for family in args[1].split(',') {
let family = family.replace('\'', "");
let family = family.trim();
families.push(match family {
"serif" => FamilyName::Serif,
"sans-serif" => FamilyName::SansSerif,
"monospace" => FamilyName::Monospace,
"cursive" => FamilyName::Cursive,
"fantasy" => FamilyName::Fantasy,
_ => FamilyName::Title(family.to_string()),
});
}
let handle = SystemSource::new().select_best_match(&families, &properties)?;
let font = handle.load()?; And I found some methods that might be helpful for the first pass at rendering output: font.rasterize_glyph(
&mut canvas,
glyph_id,
size,
Transform2F::from_translation(-raster_rect.origin().to_f32()) * transform,
hinting_options,
rasterization_options,
) I found various places where fonts are consumed and I wasn't sure exactly how to hook in to the codebase. In So @Herschel - my main questions are really:
Anyway, it sounds like perhaps this is too big a project (in an area like Fonts that I'm not experienced with) - so perhaps I'm just highlighting that I'm not the person for the job - but it was on my list of possible contribs, so I at least waned to give it a valiant effort. Let me know what you think at any rate :-) |
I think the core of my confusion is what to output, / what modules responsibility should be. I'm assuming when rendering text fields what we want is to make sure the font is available or an appropriate fallback identified ideally - then let the system handle the raster, but they work in quite different ways: Canvas in JS only needs a string combining the variant, size, weight and font face, and a colour and layout etc.
And I'm guessing we need to access the But then the Desktop via Font-Kit I'm not sure what to do after trying to identify the font itself. The output of Also, as far as webGL is concerned - there is perhaps an interesting tutorial on creating text using off-screen canvas, and generating a texture to use in webGL (which seems far simpler than trying to do font rendering properly in webGL) https://delphic.me.uk/tutorials/webgl-text |
it would be really helpful for people with non-English alphabets (or writing systems) if you could implement this. Many thanks for your help. |
@Herschel, until this is implemented would it be possible to add all characters from the Latin-1 Supplement Unicode block to the Noto Sans font embedded in Ruffle? Besides one question in discussions, 9 issues will be fixed with that simple measure. Just in case it might be relevant to be considered. |
I need to be honest too, I haven't had the opportunity to look into this further, and I think it was something that is too out of my knowledge area to do well, so it is unlikely I'll be looking at this. At least for a while. Extra chars in embedded font is certainly worthy of consideration though as a stop-gap.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
…On Wednesday, February 24th, 2021 at 16:13, Pablo Rodríguez ***@***.***> wrote:
@Herschel, until this is implemented would it be possible to add all characters from the Latin-1 Supplement Unicode block to the Noto Sans font embedded in Ruffle?
Besides one question in discussions, 9 issues will be fixed with that simple measure.
Just in case it might be relevant to be considered.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@Herschel, since the implementation of this issue might take a while, would it be possible that the embedded device font doesn’t remove chars, so chars with diacritical marks in Latin texts may be displayed? (Sorry, I don’t remember which one is the embedded device font, so I can’t say whether other non-Latin scripts may benefit from this.) |
+1 from me on adding at least the accented Latin glyphs to the embedded pseudo-device-font. |
Is there a temporary solution to this problem |
I’m afraid that only embedding the fonts in SWF files is could be a fix right now. (And I agree this makes no sense for SWF files that cannot be recreated.) |
@Herschel |
@ROBERT-MCDOWELL, I’m afraid it seems that it might take a while before Firefox will have this implemented (after having considered their position on the it) . |
@ousia nevermind firefox does it or not, they will follow chrome/safari which is already implemented. |
For an example swf, visit https://judithedelman.com/ and click on News |
The main part of this issue has been closed by #14535. Web still requires site configuration to load "device" fonts into. |
In Flash, text fields can either use "outline fonts" (embedded glyph shapes in the SWF) or "device fonts" (use the OS to render).
For device fonts, we currently cheat by embedding a version of Noto Sans into Ruffle, and rendering this the same as an outline font.
However, this is reaching the limit of its usefulness: the faux-device-font only has basic characters embedded and will display nothing for international text or other glyphs that it is missing (#1616). We need to properly render device text, using system fonts as appropriate.
Let's add a new
TextBackend
that handles text rendering for each platform:font-kit
canvasRenderingContext2d.measureText
/fillText
.The text was updated successfully, but these errors were encountered: