Revert "make it not crash"

Junkui Zhang created

This reverts commit a7e34ab0bc1540f7110fdf1ffa7d62a8fcd08aff.

Change summary

crates/gpui/src/platform/windows/direct_write.rs | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

Detailed changes

crates/gpui/src/platform/windows/direct_write.rs 🔗

@@ -634,7 +634,7 @@ impl DirectWriteState {
         let advance = [0.0f32];
         let offset = [DWRITE_GLYPH_OFFSET::default()];
         let glyph_run = DWRITE_GLYPH_RUN {
-            fontFace: unsafe { std::mem::transmute_copy(&font.font_face) },
+            fontFace: ManuallyDrop::new(Some(font.font_face.cast()?)),
             fontEmSize: params.font_size.0,
             glyphCount: 1,
             glyphIndices: glyph_id.as_ptr(),
@@ -644,6 +644,7 @@ impl DirectWriteState {
             bidiLevel: 0,
         };
 
+        let transform = DWRITE_MATRIX::default();
         let rendering_mode = DWRITE_RENDERING_MODE1_NATURAL_SYMMETRIC;
         let measuring_mode = DWRITE_MEASURING_MODE_NATURAL;
         let baseline_origin_x = 0.0;
@@ -652,7 +653,7 @@ impl DirectWriteState {
         let glyph_analysis = unsafe {
             self.components.factory.CreateGlyphRunAnalysis(
                 &glyph_run,
-                None,
+                Some(&transform as *const _),
                 rendering_mode,
                 measuring_mode,
                 DWRITE_GRID_FIT_MODE_DEFAULT,
@@ -829,7 +830,7 @@ impl DirectWriteState {
                 ));
             }
 
-            let mut alpha_data = vec![0u8; (width * height * 3) as usize];
+            let mut alpha_data = vec![0u8; (width * height) as usize];
 
             unsafe {
                 glyph_analysis.CreateAlphaTexture(