mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Implement TextRun::metrics_for_range, and text box splitter helper.
This commit is contained in:
parent
78cfdee5e8
commit
451828bce0
2 changed files with 8 additions and 3 deletions
|
@ -26,9 +26,9 @@ pub fn adapt_textbox_with_range(box_data: &RenderBoxData, run: @TextRun,
|
|||
offset: uint, length: uint) -> @RenderBox {
|
||||
let new_box_data = copy *box_data;
|
||||
let new_text_data = TextBoxData(run, offset, length);
|
||||
let metrics = run.metrics_for_range(offset, length);
|
||||
new_box_data.position.size = metrics.bounding_box.size;
|
||||
@TextBox(move new_box_data, move new_text_data)
|
||||
// TODO: set position based on run metrics
|
||||
//new_box_data.position.size = { width: run.font
|
||||
}
|
||||
|
||||
trait UnscannedMethods {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use arc = std::arc;
|
||||
use arc::ARC;
|
||||
use au = gfx::geometry;
|
||||
use font::Font;
|
||||
use font::{RunMetrics, Font};
|
||||
use font_cache::FontCache;
|
||||
use geom::point::Point2D;
|
||||
use geom::size::Size2D;
|
||||
|
@ -49,6 +49,7 @@ trait TextRunMethods {
|
|||
pure fn glyphs(&self) -> &self/GlyphStore;
|
||||
pure fn iter_indivisible_pieces_for_range(&self, offset: uint, length: uint, f: fn(uint, uint) -> bool);
|
||||
|
||||
fn metrics_for_range(offset: uint, length: uint) -> RunMetrics;
|
||||
fn min_width_for_range(offset: uint, length: uint) -> au;
|
||||
fn iter_natural_lines_for_range(&self, offset: uint, length: uint, f: fn(uint, uint) -> bool);
|
||||
}
|
||||
|
@ -56,6 +57,10 @@ trait TextRunMethods {
|
|||
impl TextRun : TextRunMethods {
|
||||
pure fn glyphs(&self) -> &self/GlyphStore { &self.glyphs }
|
||||
|
||||
fn metrics_for_range(offset: uint, length: uint) -> RunMetrics {
|
||||
self.font.measure_text(&self, offset, length)
|
||||
}
|
||||
|
||||
fn min_width_for_range(offset: uint, length: uint) -> au {
|
||||
assert length > 0;
|
||||
assert offset < self.text.len();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue