Fix some bugs in Core Graphics native rendering
This commit is contained in:
parent
0642e65c9d
commit
9dda148b38
|
@ -31,7 +31,7 @@ extern crate serde_derive;
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use euclid::{Point2D, Transform2D};
|
use euclid::{Point2D, Transform2D};
|
||||||
use image::{DynamicImage, ImageBuffer, ImageFormat, ImageLuma8};
|
use image::{DynamicImage, ImageBuffer, ImageFormat, ImageRgba8};
|
||||||
use lru_cache::LruCache;
|
use lru_cache::LruCache;
|
||||||
use pathfinder_font_renderer::{FontContext, FontInstance, FontKey, GlyphKey, SubpixelOffset};
|
use pathfinder_font_renderer::{FontContext, FontInstance, FontKey, GlyphKey, SubpixelOffset};
|
||||||
use pathfinder_partitioner::mesh_library::MeshLibrary;
|
use pathfinder_partitioner::mesh_library::MeshLibrary;
|
||||||
|
@ -489,7 +489,7 @@ fn render_reference(request: Json<RenderReferenceRequest>)
|
||||||
dimensions.size.height,
|
dimensions.size.height,
|
||||||
glyph_image.pixels).unwrap();
|
glyph_image.pixels).unwrap();
|
||||||
let reference_image = ReferenceImage {
|
let reference_image = ReferenceImage {
|
||||||
image: ImageLuma8(image_buffer),
|
image: ImageRgba8(image_buffer),
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(reference_image)
|
Ok(reference_image)
|
||||||
|
|
|
@ -18,7 +18,7 @@ use core_graphics_sys::geometry::{CGSize, CG_ZERO_POINT};
|
||||||
use core_graphics_sys::path::CGPathElementType;
|
use core_graphics_sys::path::CGPathElementType;
|
||||||
use core_text::font::CTFont;
|
use core_text::font::CTFont;
|
||||||
use core_text;
|
use core_text;
|
||||||
use euclid::{Point2D, Size2D, Vector2D};
|
use euclid::{Point2D, Rect, Size2D, Vector2D};
|
||||||
use pathfinder_path_utils::cubic::{CubicPathCommand, CubicPathCommandApproxStream};
|
use pathfinder_path_utils::cubic::{CubicPathCommand, CubicPathCommandApproxStream};
|
||||||
use pathfinder_path_utils::PathCommand;
|
use pathfinder_path_utils::PathCommand;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
@ -120,7 +120,12 @@ impl FontContext {
|
||||||
let subpixel_offset = Point2D::new(glyph_key.subpixel_offset.into(), 0.0);
|
let subpixel_offset = Point2D::new(glyph_key.subpixel_offset.into(), 0.0);
|
||||||
|
|
||||||
// Round out to pixel boundaries.
|
// Round out to pixel boundaries.
|
||||||
let bounding_box = &bounding_boxes[0];
|
let scale = 1.0 / font_instance.size.to_f64_px();
|
||||||
|
let bounding_box =
|
||||||
|
Rect::new(Point2D::new(bounding_boxes[0].origin.x,
|
||||||
|
bounding_boxes[0].origin.y),
|
||||||
|
Size2D::new(bounding_boxes[0].size.width,
|
||||||
|
bounding_boxes[0].size.height)).scale(scale, scale);
|
||||||
let mut lower_left = Point2D::new(bounding_box.origin.x.floor() as i32,
|
let mut lower_left = Point2D::new(bounding_box.origin.x.floor() as i32,
|
||||||
bounding_box.origin.y.floor() as i32);
|
bounding_box.origin.y.floor() as i32);
|
||||||
let mut upper_right = Point2D::new((bounding_box.origin.x + bounding_box.size.width +
|
let mut upper_right = Point2D::new((bounding_box.origin.x + bounding_box.size.width +
|
||||||
|
|
Loading…
Reference in New Issue