mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Move shaper and textrun back to src/servo/text/. Add a text redirector.
This commit is contained in:
parent
b8d7824067
commit
72c11b6fba
15 changed files with 92 additions and 73 deletions
|
@ -8,6 +8,7 @@ servo.rc. This is not ideal and may be changed in the future. */
|
|||
pub use au = geometry;
|
||||
pub use dl = display_list;
|
||||
|
||||
pub use display_list::DisplayItem;
|
||||
pub use display_list::DisplayList;
|
||||
pub use font::Font;
|
||||
pub use font::FontDescriptor;
|
||||
|
@ -18,9 +19,6 @@ pub use font::RunMetrics;
|
|||
pub use font_context::FontContext;
|
||||
pub use font_matcher::FontMatcher;
|
||||
pub use geometry::Au;
|
||||
pub use shaper::Shaper;
|
||||
pub use text_run::TextRun;
|
||||
pub use text_run::SendableTextRun;
|
||||
|
||||
pub use render_context::RenderContext;
|
||||
pub use render_layers::RenderLayer;
|
|
@ -1,13 +1,14 @@
|
|||
use azure::azure_hl::DrawTarget;
|
||||
use au = gfx::geometry;
|
||||
use au::Au;
|
||||
use geom::rect::Rect;
|
||||
use geom::point::Point2D;
|
||||
use gfx::SendableTextRun;
|
||||
|
||||
use geom::Rect;
|
||||
use geom::Point2D;
|
||||
|
||||
use gfx::{au, Au};
|
||||
use color::{Color, rgb};
|
||||
use image::base::Image;
|
||||
use render_context::RenderContext;
|
||||
use text::SendableTextRun;
|
||||
use util::range::Range;
|
||||
use color::{Color, rgb};
|
||||
|
||||
use std::arc::ARC;
|
||||
use clone_arc = std::arc::clone;
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
use au = gfx::geometry;
|
||||
use au::Au;
|
||||
use azure::{
|
||||
AzFloat,
|
||||
AzScaledFontRef,
|
||||
};
|
||||
use core::dvec::DVec;
|
||||
use gfx::RenderContext;
|
||||
|
||||
use gfx::au;
|
||||
use gfx::{Au, RenderContext};
|
||||
use geom::{Point2D, Rect, Size2D};
|
||||
use glyph::{GlyphStore, GlyphIndex};
|
||||
use servo_util::range::Range;
|
||||
use util::range::Range;
|
||||
use text::glyph::{GlyphStore, GlyphIndex};
|
||||
use text::{
|
||||
Shaper,
|
||||
TextRun,
|
||||
};
|
||||
|
||||
use core::dvec::DVec;
|
||||
|
||||
use native::FontHandle;
|
||||
|
||||
|
|
|
@ -4,12 +4,10 @@ extern mod core_text;
|
|||
|
||||
use font::{FontMetrics, FractionalPixel};
|
||||
use font_context::QuartzFontContext;
|
||||
use gfx::au;
|
||||
use text::glyph::GlyphIndex;
|
||||
|
||||
use au = gfx::geometry;
|
||||
use cast::transmute;
|
||||
use glyph::GlyphIndex;
|
||||
use libc::size_t;
|
||||
use ptr::null;
|
||||
|
||||
use cf = core_foundation;
|
||||
use cf::base::{
|
||||
|
@ -73,10 +71,10 @@ pub impl QuartzFontHandle {
|
|||
static pub fn new(_fctx: &QuartzFontContext, buf: @~[u8], pt_size: float) -> Result<QuartzFontHandle, ()> {
|
||||
let fontprov = vec::as_imm_buf(*buf, |cbuf, len| {
|
||||
CGDataProviderCreateWithData(
|
||||
null(),
|
||||
unsafe { transmute(copy cbuf) },
|
||||
ptr::null(),
|
||||
unsafe { cast::transmute(copy cbuf) },
|
||||
len as size_t,
|
||||
null())
|
||||
ptr::null())
|
||||
});
|
||||
if fontprov.is_null() { return Err(()); }
|
||||
|
||||
|
@ -120,7 +118,7 @@ pub impl QuartzFontHandle {
|
|||
|
||||
let glyphs = ~[glyph as CGGlyph];
|
||||
let advance = do vec::as_imm_buf(glyphs) |glyph_buf, _l| {
|
||||
CTFontGetAdvancesForGlyphs(self.ctfont, kCTFontDefaultOrientation, glyph_buf, null(), 1)
|
||||
CTFontGetAdvancesForGlyphs(self.ctfont, kCTFontDefaultOrientation, glyph_buf, ptr::null(), 1)
|
||||
};
|
||||
|
||||
return Some(advance as FractionalPixel);
|
||||
|
@ -156,5 +154,5 @@ pub impl QuartzFontHandle {
|
|||
fn ctfont_from_cgfont(cgfont: CGFontRef, pt_size: float) -> CTFontRef {
|
||||
assert cgfont.is_not_null();
|
||||
|
||||
CTFontCreateWithGraphicsFont(cgfont, pt_size as CGFloat, null(), null())
|
||||
CTFontCreateWithGraphicsFont(cgfont, pt_size as CGFloat, ptr::null(), ptr::null())
|
||||
}
|
|
@ -4,9 +4,9 @@ use gfx::{
|
|||
Au,
|
||||
Font,
|
||||
FontContext,
|
||||
TextRun,
|
||||
};
|
||||
use image::base::Image;
|
||||
use text::TextRun;
|
||||
use util::range::Range;
|
||||
|
||||
use cairo::cairo_hl::ImageSurface;
|
||||
|
|
|
@ -1,37 +1,39 @@
|
|||
/* Fundamental layout structures and algorithms. */
|
||||
|
||||
use newcss::color::rgb;
|
||||
use arc = std::arc;
|
||||
use arc::ARC;
|
||||
use au = gfx::geometry;
|
||||
use au::Au;
|
||||
use core::dvec::DVec;
|
||||
use core::to_str::ToStr;
|
||||
use core::rand;
|
||||
use css::node_style::StyledNode;
|
||||
use newcss::complete::CompleteStyle;
|
||||
use newcss::units::{BoxSizing, Length, Px};
|
||||
use newcss::values::{CSSDisplay, Specified, CSSBackgroundColorColor, CSSBackgroundColorTransparent};
|
||||
use newcss::values::{CSSBorderColor, CSSPositionAbsolute};
|
||||
use newcss::values::{CSSBorderWidthLength, CSSBorderWidthMedium};
|
||||
use newcss::color::{Color, rgba};
|
||||
use geom::{Rect, Size2D, Point2D};
|
||||
|
||||
use css::node_style::{NodeStyle, StyledNode};
|
||||
use dom::element::{ElementKind, HTMLDivElement, HTMLImageElement};
|
||||
use dom::node::{Element, Node, NodeData, NodeKind, NodeTree};
|
||||
use geom::rect::Rect;
|
||||
use geom::size::Size2D;
|
||||
use geom::point::Point2D;
|
||||
use gfx::display_list::{DisplayItem, DisplayList, DisplayListBuilder};
|
||||
use gfx::{au, dl};
|
||||
use gfx::{
|
||||
Au,
|
||||
DisplayItem,
|
||||
DisplayList,
|
||||
};
|
||||
use image::{Image, ImageHolder};
|
||||
use layout::context::LayoutContext;
|
||||
use layout::debug::BoxedDebugMethods;
|
||||
use layout::display_list_builder::DisplayListBuilder;
|
||||
use layout::flow::FlowContext;
|
||||
use layout::text::TextBoxData;
|
||||
use gfx::TextRun;
|
||||
use std::net::url::Url;
|
||||
use task::spawn;
|
||||
use newcss::color::{Color, rgba, rgb};
|
||||
use newcss::units::{BoxSizing, Length, Px};
|
||||
use newcss::values::{CSSBorderColor, CSSPositionAbsolute};
|
||||
use newcss::values::{CSSBorderWidthLength, CSSBorderWidthMedium};
|
||||
use newcss::values::{CSSDisplay, Specified, CSSBackgroundColorColor, CSSBackgroundColorTransparent};
|
||||
use servo_text::TextRun;
|
||||
use util::range::*;
|
||||
use util::tree;
|
||||
|
||||
use arc = std::arc;
|
||||
use arc::ARC;
|
||||
use core::dvec::DVec;
|
||||
use core::to_str::ToStr;
|
||||
use core::rand;
|
||||
use std::net::url::Url;
|
||||
use task::spawn;
|
||||
|
||||
/**
|
||||
Render boxes (`struct RenderBox`) are the leafs of the layout
|
||||
tree. They cannot position themselves. In general, render boxes do not
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
use au = gfx::geometry;
|
||||
use core::dlist::DList;
|
||||
use core::dvec::DVec;
|
||||
use newcss::values::{BoxAuto, BoxLength, Px};
|
||||
use geom::{Point2D, Rect, Size2D};
|
||||
|
||||
use dom::node::Node;
|
||||
use geom::point::Point2D;
|
||||
use geom::rect::Rect;
|
||||
use geom::size::Size2D;
|
||||
use gfx::display_list::{DisplayList, DisplayListBuilder};
|
||||
use gfx::font::FontStyle;
|
||||
use gfx::geometry::Au;
|
||||
use gfx::dl;
|
||||
use gfx::{
|
||||
Au,
|
||||
FontStyle,
|
||||
};
|
||||
use layout::box::*;
|
||||
use layout::context::LayoutContext;
|
||||
use layout::flow::{FlowContext, InlineFlow};
|
||||
use layout::text::TextBoxData;
|
||||
use newcss::values::{BoxAuto, BoxLength, Px};
|
||||
use servo_text::util::*;
|
||||
use util::range::{MutableRange, Range};
|
||||
use util::tree;
|
||||
|
||||
use core::dlist::DList;
|
||||
use core::dvec::DVec;
|
||||
use num::Num;
|
||||
use std::arc;
|
||||
use util::range::{MutableRange, Range};
|
||||
use util::text::*;
|
||||
use util::tree;
|
||||
|
||||
/*
|
||||
Lineboxes are represented as offsets into the child list, rather than
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/** Text layout. */
|
||||
|
||||
use gfx::TextRun;
|
||||
use servo_text::TextRun;
|
||||
use layout::box::{TextBox, RenderBox, RenderBoxData, UnscannedTextBox};
|
||||
use util::range::Range;
|
||||
|
||||
|
|
|
@ -85,20 +85,12 @@ pub mod gfx {
|
|||
pub mod font;
|
||||
pub mod font_cache;
|
||||
pub mod font_matcher;
|
||||
pub mod glyph;
|
||||
pub mod text_run;
|
||||
|
||||
// Typedefs and pub-uses for multiple implementations.
|
||||
// native contains redirects, so one can write native::FontHandle.
|
||||
pub mod native;
|
||||
pub mod font_context;
|
||||
pub mod font_handle;
|
||||
pub mod shaper;
|
||||
|
||||
// Below are the actual platform-specific parts.
|
||||
pub mod harfbuzz {
|
||||
pub mod shaper;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub mod quartz {
|
||||
|
@ -140,11 +132,22 @@ pub mod resource {
|
|||
pub mod resource_task;
|
||||
}
|
||||
|
||||
pub mod text {
|
||||
pub mod glyph;
|
||||
pub mod text_run;
|
||||
pub mod util;
|
||||
pub mod shaper;
|
||||
|
||||
// Below are the actual platform-specific parts.
|
||||
pub mod harfbuzz {
|
||||
pub mod shaper;
|
||||
}
|
||||
}
|
||||
|
||||
pub mod util {
|
||||
pub mod actor;
|
||||
pub mod cache;
|
||||
pub mod range;
|
||||
pub mod text;
|
||||
pub mod time;
|
||||
pub mod tree;
|
||||
pub mod url;
|
||||
|
@ -154,3 +157,4 @@ pub mod util {
|
|||
pub mod opts;
|
||||
|
||||
use servo_util = util;
|
||||
use servo_text = text;
|
||||
|
|
9
src/servo/text.rs
Normal file
9
src/servo/text.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
/* This file exists just to make it easier to import things inside of
|
||||
./text/ without specifying the file they came out of imports.
|
||||
|
||||
Note that you still must define each of the files as a module in
|
||||
servo.rc. This is not ideal and may be changed in the future. */
|
||||
|
||||
pub use shaper::Shaper;
|
||||
pub use text_run::TextRun;
|
||||
pub use text_run::SendableTextRun;
|
|
@ -1,18 +1,18 @@
|
|||
extern mod harfbuzz;
|
||||
|
||||
use geom::Point2D;
|
||||
|
||||
use gfx::au;
|
||||
use gfx::{
|
||||
Au,
|
||||
Font,
|
||||
};
|
||||
|
||||
use geom::point::Point2D;
|
||||
use glyph::{GlyphStore, GlyphIndex, GlyphData};
|
||||
|
||||
use libc::types::common::c99::int32_t;
|
||||
use libc::{c_uint, c_int, c_void, c_char};
|
||||
use ptr::{null, to_unsafe_ptr, offset};
|
||||
use std::arc;
|
||||
use util = util::text;
|
||||
|
||||
use harfbuzz::{HB_MEMORY_MODE_READONLY,
|
||||
HB_DIRECTION_LTR};
|
|
@ -4,7 +4,7 @@ Uniscribe, Pango, or Coretext.
|
|||
|
||||
Currently, only harfbuzz bindings are implemented.
|
||||
*/
|
||||
use font::Font;
|
||||
use gfx::Font;
|
||||
|
||||
pub type Shaper/& = harfbuzz::shaper::HarfbuzzShaper;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue