message: adds glyph positions
diff: @@ -139,6 +139,7 @@ struct CachedMetrics {
  string: Option<String>,
  width: Option<f32>,
  height: Option<f32>,
  + glyph_positions: Vec<mint::Point2<f32>>,
  }
  impl Default for CachedMetrics {
  @@ -147,6 +148,7 @@ impl Default for CachedMetrics {
  string: None,
  width: None,
  height: None,
  + glyph_positions: Vec::new(),
  }
  }
  }
  @@ -327,6 +329,42 @@ impl Text {
  string_accm
  }
  + /// Calculates, caches, and returns position of the glyphs
  + fn calculate_glyph_positions(
  + &self,
  + gb: &mut GlyphBrush<DrawParam>,
  + ) -> std::cell::Ref<Vec<mint::Point2<f32>>> {
  + if let Ok(metrics) = self.cached_metrics.try_borrow() {
  + if !metrics.glyph_positions.is_empty() {
  + return std::cell::Ref::map(metrics, |metrics| &metrics.glyph_positions);
  + }
  + }
  + let glyph_positions: Vec<mint::Point2<f32>> = {
  + let varied_section = self.generate_varied_section(Point2::new(0.0, 0.0), None);
  + use glyph_brush::GlyphCruncher;
  + gb
  + .glyphs(varied_section)
  + .map(|glyph| glyph.glyph.position)
  + .map(|pos| mint::Point2 { x: pos.x, y: pos.y })
  + .collect()
  + };
  + if let Ok(mut metrics) = self.cached_metrics.try_borrow_mut() {
  + metrics.glyph_positions = glyph_positions;
  + } else {
  + panic!();
  + }
  + if let Ok(metrics) = self.cached_metrics.try_borrow() {
  + return std::cell::Ref::map(metrics, |metrics| &metrics.glyph_positions);
  + } else {
  + panic!();
  + }
  + }
  +
  + /// Returns a Vec containing the coordinates of the formatted and wrapped text.
  + pub fn glyph_positions(&self, context: &Context) -> std::cell::Ref<Vec<mint::Point2<f32>>> {
  + self.calculate_glyph_positions(&mut context.gfx_context.glyph_brush.borrow_mut())
  + }
  +
  /// Calculates, caches, and returns width and height of formatted and wrapped text.
  fn calculate_dimensions(&self, gb: &mut GlyphBrush<DrawParam>) -> Rect {
  if let Ok(metrics) = self.cached_metrics.try_borrow() {
  