Repository navigation
script: Implement CanvasRenderingContext2D.measureText - #32704
Conversation
|
🔨 Triggering try run (#9807939572) for Linux WPT |
|
Test results for linux-wpt-layout-2020 from try job (#9807939572): Flaky unexpected result (9)
Stable unexpected results that are known to be intermittent (21)
Stable unexpected results (2)
|
|
|
mrobinson
left a comment
There was a problem hiding this comment.
Thanks for this change. A couple things that make this complicated:
- We are going to be removing as much of the
font-kitdependency as possible, so I don't think it makes sense to add more hooks for font kit into thefontscrate. - Font handling for canvas needs to move back to the script thread, as that is what has access to web fonts.
I'm happy to discuss these constraints on Zulip.
e3a2556 to
c1a2ec4
Compare
c1a2ec4 to
7273c40
Compare
|
@mrobinson I've addressed the issues you mentioned. I'd be happy to get it reviewed. |
| fn typographic_bounds(&self, glyph_id: GlyphId) -> RectF { | ||
| let face = self.face.lock(); | ||
| assert!(!face.is_null()); | ||
|
|
||
| let load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING; | ||
| let result = unsafe { FT_Load_Glyph(*face, glyph_id as FT_UInt, load_flags) }; | ||
| if 0 != result { | ||
| debug!("Unable to load glyph {}. reason: {:?}", glyph, result); | ||
| return RectF::default(); | ||
| } | ||
|
|
||
| let metrics = unsafe { &(*(**face).glyph).metrics }; | ||
| let rect = RectI::new( | ||
| Vector2I::new( | ||
| metrics.horiBearingX as i32, | ||
| (metrics.horiBearingY - metrics.height) as i32, | ||
| ), | ||
| Vector2I::new(metrics.width as i32, metrics.height as i32), | ||
| ); | ||
| (rect.to_f32() * (1. / 64.)).round() | ||
| } |
There was a problem hiding this comment.
Could this be replaced with (hb-font-get-glyph-extents)[https://harfbuzz.github.io/harfbuzz-hb-font.html#hb-font-get-glyph-extents]?
There was a problem hiding this comment.
It doesn't seem to work correctly, at least in my environment.
bf30be1 to
189b6be
Compare
mrobinson
left a comment
There was a problem hiding this comment.
Nice work and I appreciate all the changes. It looks like the main thing missing here is support for fallback, but otherwise this is looking really nice.
21f25eb to
e4e962f
Compare
e4e962f to
c926ec5
Compare
Co-authored-by: Martin Robinson <[email protected]> Signed-off-by: Chocolate Pie <[email protected]>
c926ec5 to
5dff4c7
Compare
Signed-off-by: Chocolate Pie <[email protected]> Co-authored-by: Martin Robinson <[email protected]>
Replace stub implementation of
CanvasRenderingContext2D.measureTextwith real one../mach build -ddoes not report any errors./mach test-tidydoes not report any errors