mirror of
https://github.com/emilk/egui.git
synced 2026-06-26 22:53:14 -04:00
Fix WASM build: rename ScaledMetrics to StyledMetrics, fix web-sys API
- ScaledMetrics was renamed to StyledMetrics but canvas_renderer.rs and font.rs still referenced the old name - web-sys 0.3.91 changed get_image_data params from f64 to i32
This commit is contained in:
@@ -4,7 +4,7 @@ use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement};
|
||||
|
||||
use crate::text::font::ScaledMetrics;
|
||||
use crate::text::font::StyledMetrics;
|
||||
|
||||
/// Data for a glyph rendered via HTML5 canvas
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -63,7 +63,7 @@ impl CanvasGlyphRenderer {
|
||||
pub fn render_glyph(
|
||||
&mut self,
|
||||
chr: char,
|
||||
metrics: &ScaledMetrics,
|
||||
metrics: &StyledMetrics,
|
||||
font_families: &[String],
|
||||
bin: crate::text::font::SubpixelBin,
|
||||
) -> Option<CanvasGlyphData> {
|
||||
@@ -162,7 +162,7 @@ impl CanvasGlyphRenderer {
|
||||
// Extract image data (now at device pixel resolution)
|
||||
let image_data = self
|
||||
.context
|
||||
.get_image_data(0.0, 0.0, width as f64, height as f64)
|
||||
.get_image_data(0, 0, width as i32, height as i32)
|
||||
.ok()?;
|
||||
|
||||
let rgba_data = image_data.data().0;
|
||||
@@ -210,7 +210,7 @@ fn ensure_canvas_renderer() -> Result<(), JsValue> {
|
||||
/// Render a glyph using the thread-local canvas renderer
|
||||
pub fn render_glyph_with_canvas(
|
||||
chr: char,
|
||||
metrics: &ScaledMetrics,
|
||||
metrics: &StyledMetrics,
|
||||
font_families: &[String],
|
||||
bin: crate::text::font::SubpixelBin,
|
||||
) -> Option<CanvasGlyphData> {
|
||||
|
||||
@@ -644,7 +644,7 @@ impl FontFace {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn try_allocate_canvas_glyph_static(
|
||||
atlas: &mut TextureAtlas,
|
||||
metrics: &ScaledMetrics,
|
||||
metrics: &StyledMetrics,
|
||||
chr: char,
|
||||
bin: SubpixelBin,
|
||||
) -> Option<GlyphAllocation> {
|
||||
@@ -826,7 +826,7 @@ fn invisible_char(c: char) -> bool {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub(super) fn allocate_canvas_glyph(
|
||||
atlas: &mut TextureAtlas,
|
||||
metrics: &ScaledMetrics,
|
||||
metrics: &StyledMetrics,
|
||||
canvas_data: crate::text::canvas_renderer::CanvasGlyphData,
|
||||
) -> GlyphAllocation {
|
||||
use crate::text::canvas_renderer::CanvasGlyphData;
|
||||
|
||||
@@ -176,7 +176,7 @@ fn layout_section(
|
||||
|
||||
let mut last_glyph_id = None;
|
||||
|
||||
// Optimization: only recompute `ScaledMetrics` when the concrete `FontImpl` changes.
|
||||
// Optimization: only recompute `StyledMetrics` when the concrete `FontImpl` changes.
|
||||
let mut current_font = FontFaceKey::INVALID;
|
||||
let mut current_font_face_metrics = StyledMetrics::default();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user