[Libreoffice-commits] .: vcl/aqua vcl/inc

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Sep 11 22:14:54 PDT 2012


 vcl/aqua/source/gdi/coretext/salcoretextfontutils.cxx |   40 +++++++++---------
 vcl/aqua/source/gdi/coretext/salcoretextlayout.cxx    |   25 +++++------
 vcl/aqua/source/gdi/coretext/salcoretextstyle.cxx     |    7 ++-
 vcl/aqua/source/gdi/coretext/salgdi.cxx               |   19 ++++++--
 vcl/inc/aqua/coretext/salcoretextstyle.hxx            |    3 -
 vcl/inc/aqua/coretext/salgdi.h                        |    6 --
 6 files changed, 57 insertions(+), 43 deletions(-)

New commits:
commit 5aaef82232f7f51ddd658f3ad34903f3fe7107d4
Author: Norbert Thiebaud <nthiebaud at gmail.com>
Date:   Sat Jul 14 00:13:40 2012 +0200

    coretext: use only the FontFace ref from the Style
    
    Change-Id: I696065f6f60fb55eaa24e4a8b4cbff1e93856f04
    Reviewed-on: https://gerrit.libreoffice.org/306
    Reviewed-by: Norbert Thiebaud <nthiebaud at gmail.com>
    Tested-by: Norbert Thiebaud <nthiebaud at gmail.com>

diff --git a/vcl/aqua/source/gdi/coretext/salcoretextfontutils.cxx b/vcl/aqua/source/gdi/coretext/salcoretextfontutils.cxx
index a54cfb9..d02838a 100644
--- a/vcl/aqua/source/gdi/coretext/salcoretextfontutils.cxx
+++ b/vcl/aqua/source/gdi/coretext/salcoretextfontutils.cxx
@@ -196,24 +196,31 @@ SystemFontList::SystemFontList()
     {
         CFArrayRef font_descriptors = CTFontCollectionCreateMatchingFontDescriptors(font_collection);
 
-        for(int i = 0; i < CFArrayGetCount(font_descriptors); i++)
+        if(font_descriptors)
         {
-            CTFontDescriptorRef font_descriptor = (CTFontDescriptorRef)CFArrayGetValueAtIndex(font_descriptors, i);
-            CTFontRef font = CTFontCreateWithFontDescriptor(font_descriptor, 0, NULL);
-            ImplDevFontAttributes devfont_attr;
-            if(GetDevFontAttributes( font_descriptor, devfont_attr ) )
+            for(int i = 0; i < CFArrayGetCount(font_descriptors); i++)
             {
-                CoreTextPhysicalFontFace* font_data = new CoreTextPhysicalFontFace(devfont_attr, font);
-                if(font_data && font_data->GetCTFont())
+                CTFontDescriptorRef font_descriptor = (CTFontDescriptorRef)CFArrayGetValueAtIndex(font_descriptors, i);
+                CTFontRef font = CTFontCreateWithFontDescriptor(font_descriptor, 0, NULL);
+                if(font)
                 {
-                    m_aFontContainer [ font_data->GetCTFont() ] = font_data;
+                    ImplDevFontAttributes devfont_attr;
+                    if(GetDevFontAttributes( font_descriptor, devfont_attr ) )
+                    {
+                        CoreTextPhysicalFontFace* font_face = new CoreTextPhysicalFontFace(devfont_attr, font);
+                        if(font_face && font_face->GetCTFont())
+                        {
+                            m_aFontContainer [ font_face->GetCTFont() ] = font_face;
+                        }
+                    }
+                    CFRelease(font);
                 }
             }
-            CFRelease(font);
+            CFRelease(font_descriptors);
         }
-        CFRelease(font_descriptors);
+        CFRelease(font_collection);
     }
-    CFRelease(font_collection);
+
 }
 
 SystemFontList::~SystemFontList()
@@ -250,6 +257,7 @@ CoreTextPhysicalFontFace::CoreTextPhysicalFontFace( const ImplDevFontAttributes&
 ,   m_bHasCJKSupport( false )
 ,   m_bFontCapabilitiesRead( false )
 {
+    msgs_debug(font,"retain %p as %p",font, m_CTFontRef);
 }
 
 CoreTextPhysicalFontFace::~CoreTextPhysicalFontFace()
@@ -258,10 +266,8 @@ CoreTextPhysicalFontFace::~CoreTextPhysicalFontFace()
     {
         m_pCharMap->DeReference();
     }
-    if( m_CTFontRef )
-    {
-        CFRelease(m_CTFontRef);
-    }
+    msgs_debug(font,"release font %p", m_CTFontRef);
+    SafeCFRelease(m_CTFontRef);
 }
 
 PhysicalFontFace* CoreTextPhysicalFontFace::Clone() const
@@ -274,6 +280,7 @@ PhysicalFontFace* CoreTextPhysicalFontFace::Clone() const
     if( m_CTFontRef )
     {
         pClone->m_CTFontRef = (CTFontRef)CFRetain(m_CTFontRef);
+        msgs_debug(font,"clone ref %p into %p", m_CTFontRef, pClone->m_CTFontRef);
     }
     return pClone;
 }
@@ -391,9 +398,6 @@ bool CoreTextPhysicalFontFace::GetRawFontData( std::vector<unsigned char>& rBuff
         if(CFF_table)
         {
             *pJustCFF = CFDataGetLength(CFF_table) ? true : false;
-        }
-        if(CFF_table)
-        {
             CFRelease(CFF_table);
             return true;
         }
diff --git a/vcl/aqua/source/gdi/coretext/salcoretextlayout.cxx b/vcl/aqua/source/gdi/coretext/salcoretextlayout.cxx
index 408f2b2..07ff289 100644
--- a/vcl/aqua/source/gdi/coretext/salcoretextlayout.cxx
+++ b/vcl/aqua/source/gdi/coretext/salcoretextlayout.cxx
@@ -98,8 +98,14 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const
     CTLineDraw(m_line, gr.mrContext);
 #else
     InitGIA();
-    msgs_debug(layout,"at- pos (%ld, %ld)", pos.X(), pos.Y());
+    msgs_debug(layout,"at- pos (%ld, %ld) ctfont=%p", pos.X(), pos.Y(),
+               m_style->GetFont());
     CGFontRef cg_font = CTFontCopyGraphicsFont(m_style->GetFont(), NULL);
+    if(!cg_font)
+    {
+        msgs_debug(layout, "Error cg_font is %s", "NULL");
+        return;
+    }
     CGContextSetFont(gr.mrContext, cg_font);
     CGContextSetFontSize(gr.mrContext, CTFontGetSize(m_style->GetFont()));
     CGContextSetTextDrawingMode(gr.mrContext, kCGTextFill);
@@ -114,20 +120,10 @@ void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const
         CGContextSetRGBFillColor(gr.mrContext, 0.0, 0.0, 0.0, 1.0);
     }
     CFRelease(cg_font);
-//    CGContextSetTextPosition(gr.mrContext, pos.X(), pos.Y());
     CGContextSetTextMatrix(gr.mrContext, CGAffineTransformMakeScale(1.0, -1.0));
     CGContextSetShouldAntialias( gr.mrContext, !gr.mbNonAntialiasedText );
     CGContextTranslateCTM(gr.mrContext, pos.X(), pos.Y());
-//    for(int i = 0; i < m_glyphs_count ; ++i)
-//    {
-//        msgs_debug(layout,"m_glyph=%p m_glyph_positions=%p count=%d", m_glyphs, m_glyph_positions, m_glyphs_count);
-//        msgs_debug(layout,"glyph[%d]=0x%x position(%g,%g)", i, m_glyphs[i], m_glyph_positions[i].x, m_glyph_positions[i].y);
-        CGContextShowGlyphs(gr.mrContext, m_glyphs, m_glyphs_count);
-//        CGContextShowGlyphsAtPositions(gr.mrContext, m_glyphs, m_glyph_positions, m_glyphs_count);
-//        CGContextShowGlyphsWidthAdvances(gr.mrContext, m_glyphs, m_glyph_advances, m_glyphs_count);
-
-//        CGContextShowGlyphsAtPoint(gr.mrContext, pos.X(), pos.Y(), m_glyphs, m_glyphs_count);
-//    }
+    CGContextShowGlyphs(gr.mrContext, m_glyphs, m_glyphs_count);
 #endif
     // restore the original graphic context transformations
     CGContextRestoreGState( gr.mrContext );
@@ -362,6 +358,8 @@ bool CoreTextLayout::InitGIA() const
                     for (CFIndex j = 0 ; j < nb_glyphs; ++p, ++j )
                     {
                         m_glyphs[ p ] = glyphs[ j ];
+                        msgs_debug(layout,"m_glyphys[%d]=glyphs[%d] run %d : 0x%x\n",
+                                   p,(int)j, (int)i, glyphs[j]);
                         CFIndex k = indices[ j ];
                         m_glyphs2chars[p] = k;
                         m_chars2glyphs[k] = p;
@@ -385,7 +383,8 @@ bool CoreTextLayout::InitGIA() const
 
 bool CoreTextLayout::LayoutText(ImplLayoutArgs& args)
 {
-    msgs_debug(layout,"-->");
+    msgs_debug(layout,"-->(m_style=%p font=%p",
+               m_style, m_style->GetFont());
     Clean();
     m_style->SetColor();
     /* retreive MinCharPos EndCharPos Flags and Orientation */
diff --git a/vcl/aqua/source/gdi/coretext/salcoretextstyle.cxx b/vcl/aqua/source/gdi/coretext/salcoretextstyle.cxx
index 90d5187..dfd0631 100644
--- a/vcl/aqua/source/gdi/coretext/salcoretextstyle.cxx
+++ b/vcl/aqua/source/gdi/coretext/salcoretextstyle.cxx
@@ -35,13 +35,14 @@ long CoreTextStyleInfo::GetFontStretchedSize() const
 void CoreTextStyleInfo::SetFont(FontSelectPattern* requested_font)
 {
     msgs_debug(style,"req(%p) release font %p -->", requested_font, m_CTFont);
-    SafeCFRelease(m_CTFont);
+
     if(!requested_font)
     {
+        SafeCFRelease(m_CTFont);
         m_font_face = NULL;
         return;
     }
-    m_font_face = static_cast<const CoreTextPhysicalFontFace*>(requested_font->mpFontData);
+    m_font_face = (CoreTextPhysicalFontFace*)(requested_font->mpFontData);
 
     m_matrix = CGAffineTransformIdentity;
     CGFloat font_size = (CGFloat)requested_font->mfExactHeight;
@@ -69,6 +70,8 @@ void CoreTextStyleInfo::SetFont(FontSelectPattern* requested_font)
         m_matrix = CGAffineTransformScale(m_matrix, m_stretch_factor, 1.0F );
     }
 
+    SafeCFRelease(m_CTFont);
+
     /* FIXME: pass attribute to take into accout 'VerticalStyle' */
     /* FIXME: how to deal with 'rendering options' i.e anti-aliasing, does it even matter in CoreText ? */
     m_CTFont = CTFontCreateCopyWithAttributes(m_font_face->GetCTFont(), font_size, &m_matrix, NULL);
diff --git a/vcl/aqua/source/gdi/coretext/salgdi.cxx b/vcl/aqua/source/gdi/coretext/salgdi.cxx
index 153d4b0..7e822e0 100644
--- a/vcl/aqua/source/gdi/coretext/salgdi.cxx
+++ b/vcl/aqua/source/gdi/coretext/salgdi.cxx
@@ -23,7 +23,6 @@ AquaSalGraphics::AquaSalGraphics()
     , mxClipPath( NULL )
     , maLineColor( COL_WHITE )
     , maFillColor( COL_BLACK )
-    , m_font_face( NULL )
     , mbNonAntialiasedText( false )
     , mbPrinter( false )
     , mbVirDev( false )
@@ -152,20 +151,30 @@ sal_uLong AquaSalGraphics::GetKernPairs( sal_uLong, ImplKernPairData* )
 
 bool AquaSalGraphics::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
 {
-    if( !m_font_face )
+    if( !m_style )
     {
         return false;
     }
-    return m_font_face->GetImplFontCapabilities(rFontCapabilities);
+    CoreTextPhysicalFontFace* font_face = m_style->GetFontFace();
+    if( !font_face)
+    {
+        return false;
+    }
+    return font_face->GetImplFontCapabilities(rFontCapabilities);
 }
 
 const ImplFontCharMap* AquaSalGraphics::GetImplFontCharMap() const
 {
-    if( !m_font_face )
+    if( !m_style )
+    {
+        return false;
+    }
+    CoreTextPhysicalFontFace* font_face = m_style->GetFontFace();
+    if( !font_face)
     {
         return ImplFontCharMap::GetDefaultMap();
     }
-    return m_font_face->GetImplFontCharMap();
+    return font_face->GetImplFontCharMap();
 }
 
 bool AquaSalGraphics::GetRawFontData( const PhysicalFontFace* pFontFace,
diff --git a/vcl/inc/aqua/coretext/salcoretextstyle.hxx b/vcl/inc/aqua/coretext/salcoretextstyle.hxx
index 6313986..08186d1 100644
--- a/vcl/inc/aqua/coretext/salcoretextstyle.hxx
+++ b/vcl/inc/aqua/coretext/salcoretextstyle.hxx
@@ -14,6 +14,7 @@ public:
     CoreTextStyleInfo();
     ~CoreTextStyleInfo();
     CTFontRef GetFont() const { return m_CTFont; };
+    CoreTextPhysicalFontFace* GetFontFace() const { return m_font_face; };
     long GetFontStretchedSize() const;
     float GetFontStretchFactor() const { return m_stretch_factor; };
     CTParagraphStyleRef GetParagraphStyle() const { return m_CTParagraphStyle; } ;
@@ -33,7 +34,7 @@ private:
     CTParagraphStyleRef m_CTParagraphStyle;
     CTFontRef m_CTFont;
     CGColorRef m_color;
-    const CoreTextPhysicalFontFace* m_font_face;
+    CoreTextPhysicalFontFace* m_font_face;
 
 };
 
diff --git a/vcl/inc/aqua/coretext/salgdi.h b/vcl/inc/aqua/coretext/salgdi.h
index 8786526..f3f4462 100644
--- a/vcl/inc/aqua/coretext/salgdi.h
+++ b/vcl/inc/aqua/coretext/salgdi.h
@@ -48,8 +48,6 @@ protected:
     RGBAColor maLineColor; //< pen color RGBA
     RGBAColor maFillColor; //< brush color RGBA
 
-    CoreTextPhysicalFontFace* m_font_face; //< Device Font settings
-
     bool mbNonAntialiasedText; //< allows text to be rendered without antialiasing
 
     // Graphics types
@@ -60,8 +58,6 @@ protected:
 
     RGBColor m_TextColor;
 
-    CoreTextStyleInfo* m_style;
-
 public:
     AquaSalGraphics();
     virtual ~AquaSalGraphics();
@@ -271,6 +267,8 @@ public:
     virtual SystemFontData GetSysFontData( int /* nFallbacklevel */ ) const;
 
 private:
+    CoreTextStyleInfo* m_style;
+
     // differences between VCL, Quartz and kHiThemeOrientation coordinate systems
     // make some graphics seem to be vertically-mirrored from a VCL perspective
     bool IsFlipped() const { return mbWindow; };


More information about the Libreoffice-commits mailing list