servo: gfx: Fix Cocoa rendering by removing commented-out font loading code.
authorPatrick Walton <pcwalton@mimiga.net>
Thu, 28 Feb 2013 18:13:29 -0800
changeset 380006 8c2bb502d79efb05c886a7fe9493657edd5baf9c
parent 380005 db33cf0fc0fab119319be2a9c901617936e1a993
child 380007 934ecb19448f10b358188d83a873c43ad3a3d4de
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
servo: gfx: Fix Cocoa rendering by removing commented-out font loading code. Source-Repo: https://github.com/servo/servo Source-Revision: 36da30cc855fff4774f360d7d679a07469a1662a
servo/src/servo-gfx/font.rs
servo/src/servo-gfx/quartz/font.rs
servo/src/servo-gfx/quartz/font_list.rs
--- a/servo/src/servo-gfx/font.rs
+++ b/servo/src/servo-gfx/font.rs
@@ -350,23 +350,21 @@ pub impl Font {
 
 
 pub impl Font {
     fn draw_text_into_context(rctx: &RenderContext,
                               run: &TextRun,
                               range: &const Range,
                               baseline_origin: Point2D<Au>,
                               color: Color) {
-        use libc::types::common::c99::{uint16_t, uint32_t};
-        use azure::{AzDrawOptions,
-                    AzGlyph,
-                    AzGlyphBuffer};
-        use azure::azure::bindgen::{AzCreateColorPattern,
-                                    AzDrawTargetFillGlyphs,
-                                    AzReleaseColorPattern};
+        use core::libc::types::common::c99::{uint16_t, uint32_t};
+        use azure::{AzDrawOptions, AzGlyph, AzGlyphBuffer};
+        use azure::azure::bindgen::{AzCreateColorPattern};
+        use azure::azure::bindgen::{AzDrawTargetFillGlyphs};
+        use azure::azure::bindgen::{AzReleaseColorPattern};
 
         let target = rctx.get_draw_target();
         let azfontref = self.get_azure_font();
         let pattern = ColorPattern(color);
         let azure_pattern = pattern.azure_color_pattern;
         assert azure_pattern.is_not_null();
 
         let options = struct__AzDrawOptions {
--- a/servo/src/servo-gfx/quartz/font.rs
+++ b/servo/src/servo-gfx/quartz/font.rs
@@ -1,56 +1,42 @@
+/// Implementation of Quartz (CoreGraphics) fonts.
+
 extern mod core_foundation;
 extern mod core_graphics;
 extern mod core_text;
 
-use quartz;
+use geometry::Au;
+use gfx_font::{CSSFontWeight, FontHandleMethods, FontMetrics, FontTable, FontTableMethods};
+use gfx_font::{FontTableTag, FontWeight100, FontWeight200, FontWeight300, FontWeight400};
+use gfx_font::{FontWeight500, FontWeight600, FontWeight700, FontWeight800, FontWeight900};
+use gfx_font::{FractionalPixel, SpecifiedFontStyle};
 use quartz::font::core_foundation::base::{CFIndex, CFTypeRef, CFWrapper};
 use quartz::font::core_foundation::data::{CFData, CFDataRef};
 use quartz::font::core_foundation::string::UniChar;
-
 use quartz::font::core_graphics::base::{CGFloat, CGAffineTransform};
 use quartz::font::core_graphics::data_provider::{CGDataProviderRef, CGDataProvider};
 use quartz::font::core_graphics::font::{CGFont, CGFontRef, CGGlyph};
 use quartz::font::core_graphics::geometry::CGRect;
-
 use quartz::font::core_text::font::CTFont;
+use quartz::font::core_text::font_descriptor::{SymbolicTraitAccessors};
 use quartz::font::core_text::font_descriptor::{kCTFontDefaultOrientation, CTFontSymbolicTraits};
-use quartz::font::core_text::font_descriptor::{SymbolicTraitAccessors};
-
 use quartz::font_context::QuartzFontContextHandle;
-use geometry::Au;
-use gfx_font::{
-    CSSFontWeight,
-    FontHandleMethods,
-    FontMetrics,
-    FontTable,
-    FontTableMethods,
-    FontTableTag,
-    FontWeight100,
-    FontWeight200,
-    FontWeight300,
-    FontWeight400,
-    FontWeight500,
-    FontWeight600,
-    FontWeight700,
-    FontWeight800,
-    FontWeight900,
-    FractionalPixel,
-    SpecifiedFontStyle,
-};
+use quartz;
 use text::glyph::GlyphIndex;
 
 use core::libc::size_t;
 
 struct QuartzFontTable {
     data: CFData,
+}
 
-    drop {  }
-}
+
+// Noncopyable.
+impl Drop for QuartzFontTable { fn finalize(&self) {} }
 
 pub impl QuartzFontTable {
     static fn wrap(data: CFData) -> QuartzFontTable {
         QuartzFontTable { data: data }
     }
 }
 
 pub impl FontTableMethods for QuartzFontTable {
@@ -100,17 +86,17 @@ pub impl QuartzFontHandle {
                 let cgfont = self.ctfont.copy_to_CGFont();
                 self.cgfont = Some(CFWrapper::clone(&cgfont));
                 cgfont
             }
         }
     }
 }
 
-pub impl FontHandleMethods for QuartzFontHandle {
+impl FontHandleMethods for QuartzFontHandle {
     pure fn family_name() -> ~str {
         self.ctfont.family_name()
     }
     
     pure fn face_name() -> ~str {
         self.ctfont.face_name()
     }
 
@@ -126,20 +112,22 @@ pub impl FontHandleMethods for QuartzFon
         if normalized < 1.0 { return FontWeight100; }
         if normalized < 2.0 { return FontWeight200; }
         if normalized < 3.0 { return FontWeight300; }
         if normalized < 4.0 { return FontWeight400; }
         if normalized < 5.0 { return FontWeight500; }
         if normalized < 6.0 { return FontWeight600; }
         if normalized < 7.0 { return FontWeight700; }
         if normalized < 8.0 { return FontWeight800; }
-        else { return FontWeight900; }
+        return FontWeight900;
     }
 
-    fn clone_with_style(fctx: &QuartzFontContextHandle, style: &SpecifiedFontStyle) -> Result<QuartzFontHandle,()> {
+    fn clone_with_style(fctx: &QuartzFontContextHandle,
+                        style: &SpecifiedFontStyle)
+                     -> Result<QuartzFontHandle,()> {
         let new_font = self.ctfont.clone_with_font_size(style.pt_size);
         return QuartzFontHandle::new_from_CTFont(fctx, new_font);
     }
 
     fn glyph_index(codepoint: char) -> Option<GlyphIndex> {
         let characters: [UniChar * 1] = [codepoint as UniChar];
         let glyphs: [mut CGGlyph * 1] = [mut 0 as CGGlyph];
         let count: CFIndex = 1;
@@ -156,31 +144,33 @@ pub impl FontHandleMethods for QuartzFon
         assert glyphs[0] != 0; // FIXME: error handling
         return Some(glyphs[0] as GlyphIndex);
     }
 
     fn glyph_h_advance(glyph: GlyphIndex) -> Option<FractionalPixel> {
         let glyphs = [glyph as CGGlyph];
         unsafe {
             let advance = self.ctfont.get_advances_for_glyphs(kCTFontDefaultOrientation,
-                                                              ptr::to_unsafe_ptr(&glyphs[0]),
+                                                              &glyphs[0],
                                                               ptr::null(),
                                                               1);
             return Some(advance as FractionalPixel);
         }
     }
 
     fn get_metrics() -> FontMetrics {
         let bounding_rect: CGRect = self.ctfont.bounding_box();
         let ascent = Au::from_pt(self.ctfont.ascent() as float);
         let descent = Au::from_pt(self.ctfont.descent() as float);
 
         let metrics =  FontMetrics {
             underline_size:   Au::from_pt(self.ctfont.underline_thickness() as float),
-            // TODO(Issue #201): underline metrics are not reliable. Have to pull out of font table directly.
+            // TODO(Issue #201): underline metrics are not reliable. Have to pull out of font table
+            // directly.
+            //
             // see also: https://bugs.webkit.org/show_bug.cgi?id=16768
             // see also: https://bugreports.qt-project.org/browse/QTBUG-13364
             underline_offset: Au::from_pt(self.ctfont.underline_position() as float),
             leading:          Au::from_pt(self.ctfont.leading() as float),
             x_height:         Au::from_pt(self.ctfont.x_height() as float),
             em_size:          ascent + descent,
             ascent:           ascent,
             descent:          descent,
--- a/servo/src/servo-gfx/quartz/font_list.rs
+++ b/servo/src/servo-gfx/quartz/font_list.rs
@@ -29,22 +29,22 @@ pub impl QuartzFontListHandle {
     static fn new(fctx: &native::FontContextHandle) -> QuartzFontListHandle {
         QuartzFontListHandle { fctx: fctx.clone() }
     }
 
     fn get_available_families() -> FontFamilyMap {
         let family_names: CFArray<CFStringRef> =
             quartz::font_list::core_text::font_collection::get_family_names();
         let mut family_map : FontFamilyMap = LinearMap::new();
-        for family_names.each |strref: &CFStringRef| {
-            /*let family_name = CFWrapper::wrap_shared(strref).to_str();
+        for family_names.each |&strref: &CFStringRef| {
+            let family_name = CFString::wrap_extern(strref).to_str();
             debug!("Creating new FontFamily for family: %s", family_name);
 
             let new_family = @FontFamily::new(family_name);
-            family_map.insert(family_name, new_family);*/
+            family_map.insert(family_name, new_family);
         }
         return family_map;
     }
 
     fn load_variations_for_family(family: @FontFamily) {
         let family_name = &family.family_name;
         debug!("Looking for faces of family: %s", *family_name);