[Libreoffice-commits] .: 13 commits - bridges/source canvas/source cppuhelper/source ios/qa stoc/source vcl/inc vcl/ios vcl/Library_vcl.mk

Tor Lillqvist tml at kemper.freedesktop.org
Sun Apr 15 02:57:31 PDT 2012


 bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno.cxx          |   18 
 bridges/source/cpp_uno/gcc3_ios_arm/except.cxx           |    2 
 bridges/source/cpp_uno/gcc3_ios_arm/generate-snippets.pl |    9 
 bridges/source/cpp_uno/gcc3_ios_arm/makefile.mk          |    2 
 bridges/source/cpp_uno/gcc3_ios_arm/share.hxx            |    9 
 canvas/source/cairo/cairo_textlayout.cxx                 |    6 
 cppuhelper/source/shlib.cxx                              |   17 
 ios/qa/sc/Makefile                                       |    7 
 stoc/source/stocservices/stocservices.cxx                |   20 
 vcl/Library_vcl.mk                                       |    2 
 vcl/inc/ios/common.h                                     |   34 
 vcl/inc/ios/salcoretextfontutils.hxx                     |   53 
 vcl/inc/ios/salcoretextlayout.hxx                        |   90 
 vcl/inc/ios/salcoretextstyle.hxx                         |   42 
 vcl/inc/ios/salctfontutils.hxx                           |   60 
 vcl/inc/ios/salgdi.h                                     |  392 --
 vcl/inc/ios/salgdicommon.hxx                             |   84 
 vcl/inc/vcl/sysdata.hxx                                  |    4 
 vcl/ios/source/gdi/salcoretextfontutils.cxx              |  609 +++
 vcl/ios/source/gdi/salcoretextlayout.cxx                 |  632 ++-
 vcl/ios/source/gdi/salcoretextstyle.cxx                  |   96 
 vcl/ios/source/gdi/salgdi.cxx                            | 2412 ---------------
 vcl/ios/source/gdi/salgdicommon.cxx                      | 1581 +++++++++
 vcl/ios/source/gdi/salgdiutils.cxx                       |    8 
 24 files changed, 3280 insertions(+), 2909 deletions(-)

New commits:
commit fd7d34ef3d27fe34272e14488ad7040e4f985233
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 11:55:16 2012 +0200

    Add more libs, add the test documents

diff --git a/ios/qa/sc/Makefile b/ios/qa/sc/Makefile
index f63c758..d674098 100644
--- a/ios/qa/sc/Makefile
+++ b/ios/qa/sc/Makefile
@@ -39,7 +39,7 @@ SRCS = filters-test.m
 
 CFLAGS = $(SOLARINC)
 
-LIBS = -Wl,$(OUTDIR)/bin/cppunit/cppunittester.a -Wl,$(WORKDIR)/LinkTarget/CppunitTest/libtest_sc_filters_test.a -Wl,$(OUTDIR)/lib/bootstrap.uno.a -Wl,$(OUTDIR)/lib/configmgr.uno.a -Wl,$(OUTDIR)/lib/i18npool.uno.a -Wl,$(OUTDIR)/lib/unoexceptionprotector.a $(SOLARLIB) -lavmedialo -lbasegfxlo -lcanvastoolslo -lcomphelpgcc3 -lcppcanvaslo -lcppunit -ldrawinglayerlo -leditenglo -lfilterconfiglo -lforlo -lforuilo -lfwelo -lfwilo -lfwklo -lgcc3_uno -li18nisolang1gcc3 -li18npaperlo -li18nutilgcc3 -licudata -licui18n -licuuc -ljpeg -ljvmfwk -llnglo -lreg -lsal_textenc -lsalcpprt -lsaxlo -lsclo -lsfxlo -lstore -lsvllo -lsvtlo -lsvxlo -lsvxcorelo -lsotlo -ltest -ltklo -ltllo -lucb1 -lucbhelper4gcc3 -lucpfile1 -luno_cppuhelpergcc3 -luno_cppu -luno_sal -luno_salhelpergcc3 -lunotest -lutllo -lvcllo -lxml2 -lxmlreader -lxolo -lz $(addprefix -framework , $(gb_Library__FRAMEWORKS)) -liconv -lobjc
+LIBS = -Wl,$(WORKDIR)/LinkTarget/CppunitTest/libtest_sc_filters_test.a $(foreach LIB, bin/cppunit/cppunittester lib/bootstrap.uno lib/configmgr.uno lib/i18npool.uno lib/stocservices.uno lib/unoexceptionprotector, -Wl,$(OUTDIR)/$(LIB).a) $(SOLARLIB) -lavmedialo -lbasegfxlo -lcanvastoolslo -lcomphelpgcc3 -lcppcanvaslo -lcppunit -ldrawinglayerlo -leditenglo -lfilterconfiglo -lforlo -lforuilo -lfwelo -lfwilo -lfwklo -lgcc3_uno -li18nisolang1gcc3 -li18npaperlo -li18nutilgcc3 -licudata -licui18n -licuuc -ljpeg -ljvmfwk -llnglo -lreg -lsal_textenc -lsalcpprt -lsaxlo -lsclo -lsfxlo -lstore -lsvllo -lsvtlo -lsvxlo -lsvxcorelo -lsotlo -ltest -ltklo -ltllo -lucb1 -lucbhelper4gcc3 -lucpfile1 -luno_cppuhelpergcc3 -luno_cppu -luno_sal -luno_salhelpergcc3 -lunotest -lutllo -lvcllo -lxml2 -lxmlreader -lxolo -lxstor -lz $(addprefix -framework , $(gb_Library__FRAMEWORKS)) -liconv -lobjc
 
 all: $(APPDIR)/$(APP) stuff
 
@@ -75,7 +75,6 @@ stuff:
 		mkdir -p $(APPDIR)/ComponentTarget/`dirname $$F`; \
 	        cp $(WORKDIR)/ComponentTarget/$$F.component $(APPDIR)/ComponentTarget/$$F.component; \
 	done
-
 #
 # .res files
 #
@@ -86,6 +85,10 @@ stuff:
 	for F in $(OUTDIR)/bin/*.res; do \
 		cp $$F $(APPDIR)/program/resource; \
 	done
+#
+# Test documents for filters_test
+	(cd $(SRC_ROOT) && tar cf - sc/qa/unit/data) | (cd $(APPDIR) && tar xvf -)
+
 
 clean:
 	rm -rf $(APPDIR)
commit 7021bfe89b4b02e2e683c23763faa9e4a10e3f2e
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 11:54:24 2012 +0200

    Modify for static linking (DISABLE_DYNLOADING, i.e. iOS)

diff --git a/stoc/source/stocservices/stocservices.cxx b/stoc/source/stocservices/stocservices.cxx
index 89d034a..b5be16f 100644
--- a/stoc/source/stocservices/stocservices.cxx
+++ b/stoc/source/stocservices/stocservices.cxx
@@ -41,6 +41,17 @@ using namespace cppu;
 using namespace osl;
 using namespace stoc_services;
 
+#ifdef DISABLE_DYNLOADING
+
+// Do we really to have non-static global variable with the same name
+// g_moduleCount in *all* (more or less, it seems) modules even in the
+// normal dynamic loading case? Weird. Anyway, in the DISABLE_DYNLOADING
+// case we have no use for these, and they can't be the same name.
+
+#define g_moduleCount g_stocservices_moduleCount
+
+#endif
+
 rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
 
 static struct ImplementationEntry g_entries[] =
@@ -88,12 +99,19 @@ static struct ImplementationEntry g_entries[] =
 extern "C"
 {
 
+#ifndef DISABLE_DYNLOADING
+
 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_canUnload( TimeValue *pTime )
 {
     return g_moduleCount.canUnload( &g_moduleCount , pTime );
 }
 
-//==================================================================================================
+#endif
+
+#ifdef DISABLE_DYNLOADING
+#define component_getFactory stocservices_component_getFactory
+#endif
+
 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
     const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
 {
commit 906aa9dea2982efa6497880fb8158537d2e96646
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 11:46:37 2012 +0200

    Add utl and xstor UNO component mapping

diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index 421df0f..b336100 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -473,6 +473,8 @@ extern "C"
     extern void * i18npool_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * ucb_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * ucpfile_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
+    extern void * utl_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
+    extern void * xstor_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
 }
 #endif
 
@@ -541,6 +543,8 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
         { "libsfxlo.a", sfx_component_getFactory },
         { "libucb1.a", ucb_component_getFactory },
         { "libucpfile1.a", ucpfile_component_getFactory },
+        { "libutllo.a", utl_component_getFactory },
+        { "libxstor.a", xstor_component_getFactory },
         { "stocservices.uno.a", stocservices_component_getFactory },
         { NULL, NULL }
     };
commit 3061e9e86621c092ab4b4f64509b6394a326afe5
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 10:51:30 2012 +0200

    Add newline...

diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index 5b85161..421df0f 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -561,7 +561,7 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
 #if OSL_DEBUG_LEVEL > 1
         if ( pSym == NULL )
         {
-            fprintf( stderr, "attempting to load unknown library %s", OUStringToOString( rLibName, RTL_TEXTENCODING_ASCII_US ).getStr() );
+            fprintf( stderr, "attempting to load unknown library %s\n", OUStringToOString( rLibName, RTL_TEXTENCODING_ASCII_US ).getStr() );
             assert( !"Attempt to load unknown library" );
         }
 #endif
commit d31997559adac6f03d932cb6c5819149c38c1398
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 10:49:41 2012 +0200

    Add comphelp and stocservices UNO component mapping

diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index f83db94..5b85161 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -465,9 +465,11 @@ extern "C"
 {
     extern void * bootstrap_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * configmgr_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
+    extern void * comphelp_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * filterconfig1_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * fwk_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * sfx_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
+    extern void * stocservices_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * i18npool_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * ucb_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * ucpfile_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
@@ -533,11 +535,13 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
         { "bootstrap.uno" SAL_DLLEXTENSION, bootstrap_component_getFactory },
         { "configmgr.uno.a", configmgr_component_getFactory },
         { "i18npool.uno.a", i18npool_component_getFactory },
+        { "libcomphelp" CPPU_STRINGIFY(CPPU_ENV) ".a", comphelp_component_getFactory },
         { "libfilterconfiglo.a", filterconfig1_component_getFactory },
         { "libfwklo.a", fwk_component_getFactory },
         { "libsfxlo.a", sfx_component_getFactory },
         { "libucb1.a", ucb_component_getFactory },
         { "libucpfile1.a", ucpfile_component_getFactory },
+        { "stocservices.uno.a", stocservices_component_getFactory },
         { NULL, NULL }
     };
     for (int i = 0; pSym == NULL && non_app_specific_map[i].lib != NULL; ++i)
commit 220336d73660a7713b95ae8b85f80d14ce02b58f
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 09:06:10 2012 +0200

    Just assert if trying to "load" an unknown library when DISABLE_DYNLOADING

diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index 44945b7..f83db94 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -556,7 +556,10 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
         }
 #if OSL_DEBUG_LEVEL > 1
         if ( pSym == NULL )
-            OSL_TRACE( "attempting to load unknown library %s", OUStringToOString( rLibName, RTL_TEXTENCODING_ASCII_US ).getStr() );
+        {
+            fprintf( stderr, "attempting to load unknown library %s", OUStringToOString( rLibName, RTL_TEXTENCODING_ASCII_US ).getStr() );
+            assert( !"Attempt to load unknown library" );
+        }
 #endif
     }
 #else
commit e56b2109c07498242608064a47b4776423352ddb
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 09:01:39 2012 +0200

    Map and link in also the sfx UNO component

diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index 64ff498..44945b7 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -467,6 +467,7 @@ extern "C"
     extern void * configmgr_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * filterconfig1_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * fwk_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
+    extern void * sfx_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * i18npool_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * ucb_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * ucpfile_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
@@ -534,6 +535,7 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
         { "i18npool.uno.a", i18npool_component_getFactory },
         { "libfilterconfiglo.a", filterconfig1_component_getFactory },
         { "libfwklo.a", fwk_component_getFactory },
+        { "libsfxlo.a", sfx_component_getFactory },
         { "libucb1.a", ucb_component_getFactory },
         { "libucpfile1.a", ucpfile_component_getFactory },
         { NULL, NULL }
commit 30196132e1aa618b291d6eab3393331fbee65005
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 08:45:38 2012 +0200

    Link with libfiltergonfiglo

diff --git a/ios/qa/sc/Makefile b/ios/qa/sc/Makefile
index d46e14e..f63c758 100644
--- a/ios/qa/sc/Makefile
+++ b/ios/qa/sc/Makefile
@@ -39,7 +39,7 @@ SRCS = filters-test.m
 
 CFLAGS = $(SOLARINC)
 
-LIBS = -Wl,$(OUTDIR)/bin/cppunit/cppunittester.a -Wl,$(WORKDIR)/LinkTarget/CppunitTest/libtest_sc_filters_test.a -Wl,$(OUTDIR)/lib/bootstrap.uno.a -Wl,$(OUTDIR)/lib/configmgr.uno.a -Wl,$(OUTDIR)/lib/i18npool.uno.a -Wl,$(OUTDIR)/lib/unoexceptionprotector.a $(SOLARLIB) -lavmedialo -lbasegfxlo -lcanvastoolslo -lcomphelpgcc3 -lcppcanvaslo -lcppunit -ldrawinglayerlo -leditenglo -lforlo -lforuilo -lfwelo -lfwilo -lfwklo -lgcc3_uno -li18nisolang1gcc3 -li18npaperlo -li18nutilgcc3 -licudata -licui18n -licuuc -ljpeg -ljvmfwk -llnglo -lreg -lsal_textenc -lsalcpprt -lsaxlo -lsclo -lsfxlo -lstore -lsvllo -lsvtlo -lsvxlo -lsvxcorelo -lsotlo -ltest -ltklo -ltllo -lucb1 -lucbhelper4gcc3 -lucpfile1 -luno_cppuhelpergcc3 -luno_cppu -luno_sal -luno_salhelpergcc3 -lunotest -lutllo -lvcllo -lxml2 -lxmlreader -lxolo -lz $(addprefix -framework , $(gb_Library__FRAMEWORKS)) -liconv -lobjc
+LIBS = -Wl,$(OUTDIR)/bin/cppunit/cppunittester.a -Wl,$(WORKDIR)/LinkTarget/CppunitTest/libtest_sc_filters_test.a -Wl,$(OUTDIR)/lib/bootstrap.uno.a -Wl,$(OUTDIR)/lib/configmgr.uno.a -Wl,$(OUTDIR)/lib/i18npool.uno.a -Wl,$(OUTDIR)/lib/unoexceptionprotector.a $(SOLARLIB) -lavmedialo -lbasegfxlo -lcanvastoolslo -lcomphelpgcc3 -lcppcanvaslo -lcppunit -ldrawinglayerlo -leditenglo -lfilterconfiglo -lforlo -lforuilo -lfwelo -lfwilo -lfwklo -lgcc3_uno -li18nisolang1gcc3 -li18npaperlo -li18nutilgcc3 -licudata -licui18n -licuuc -ljpeg -ljvmfwk -llnglo -lreg -lsal_textenc -lsalcpprt -lsaxlo -lsclo -lsfxlo -lstore -lsvllo -lsvtlo -lsvxlo -lsvxcorelo -lsotlo -ltest -ltklo -ltllo -lucb1 -lucbhelper4gcc3 -lucpfile1 -luno_cppuhelpergcc3 -luno_cppu -luno_sal -luno_salhelpergcc3 -lunotest -lutllo -lvcllo -lxml2 -lxmlreader -lxolo -lz $(addprefix -framework , $(gb_Library__FRAMEWORKS)) -liconv -lobjc
 
 all: $(APPDIR)/$(APP) stuff
 
commit 91ff02ec77cd8ea06496c871819677ecfd575f96
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 08:44:45 2012 +0200

    Map and link in also the filterconfig1 UNO component

diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index 0627e30..64ff498 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -465,6 +465,7 @@ extern "C"
 {
     extern void * bootstrap_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * configmgr_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
+    extern void * filterconfig1_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * fwk_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * i18npool_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
     extern void * ucb_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
@@ -531,6 +532,7 @@ Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
         { "bootstrap.uno" SAL_DLLEXTENSION, bootstrap_component_getFactory },
         { "configmgr.uno.a", configmgr_component_getFactory },
         { "i18npool.uno.a", i18npool_component_getFactory },
+        { "libfilterconfiglo.a", filterconfig1_component_getFactory },
         { "libfwklo.a", fwk_component_getFactory },
         { "libucb1.a", ucb_component_getFactory },
         { "libucpfile1.a", ucpfile_component_getFactory },
commit 5d369a2ca7d4511701484ee24f7b19b246f410ee
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 08:32:29 2012 +0200

    Nah, don't obscure the right type with void*

diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx
index 30493f9..adea863 100644
--- a/canvas/source/cairo/cairo_textlayout.cxx
+++ b/canvas/source/cairo/cairo_textlayout.cxx
@@ -511,7 +511,7 @@ namespace cairocanvas
             //       when CGFont (Mac OS X 10.5 API) is provided by the AQUA VCL backend.
             font_face = cairo_quartz_font_face_create_for_atsu_font_id((ATSUFontID) rSysFontData.aATSUFontID);
 # else // iOS
-            font_face = cairo_quartz_font_face_create_for_cgfont( CTFontCopyGraphicsFont( (CTFontRef) rSysFontData.rCTFont, NULL ) );
+            font_face = cairo_quartz_font_face_create_for_cgfont( CTFontCopyGraphicsFont( rSysFontData.rCTFont, NULL ) );
 # endif
 
 #elif defined CAIRO_HAS_WIN32_SURFACE
diff --git a/vcl/inc/vcl/sysdata.hxx b/vcl/inc/vcl/sysdata.hxx
index 81195b1..6f39cc9 100644
--- a/vcl/inc/vcl/sysdata.hxx
+++ b/vcl/inc/vcl/sysdata.hxx
@@ -44,7 +44,7 @@ class NSView;
 #endif
 
 #ifdef IOS
-typedef struct CGFont *CGFontRef;
+typedef const struct __CTFont * CTFontRef;
 typedef struct CGContext *CGContextRef;
 typedef struct CGLayer *CGLayerRef;
 #ifdef __OBJC__
@@ -203,7 +203,7 @@ struct SystemFontData
 #elif defined( QUARTZ )
     void*           aATSUFontID;    // native font object
 #elif defined( IOS )
-    void*           rCTFont;        // native font object
+    CTFontRef       rCTFont;        // native font object
 #elif defined( UNX )
     void*           nFontId;        // native font id
     int             nFontFlags;     // native font flags
diff --git a/vcl/ios/source/gdi/salgdi.cxx b/vcl/ios/source/gdi/salgdi.cxx
index f7f6bcd..32cc9fb 100644
--- a/vcl/ios/source/gdi/salgdi.cxx
+++ b/vcl/ios/source/gdi/salgdi.cxx
@@ -204,7 +204,7 @@ SystemFontData IosSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) const
 
     CTFontRef font = CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 0.0, NULL);
     font = (CTFontRef)CFRetain(font);
-    aSysFontData.rCTFont = (void*)font;
+    aSysFontData.rCTFont = font;
 
     CTFontRef italic_font = CTFontCreateCopyWithSymbolicTraits( font,
                                                                 0.0,
commit 4067e629f7fc9e93b8eb36fffc5fdcc0c3fa8906
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sun Apr 15 01:36:27 2012 +0200

    Fix crasher and generate PIC for iOS simulator
    
    Had an embarrassing thinko in the assembler generation for the iOS
    simulator, had forgotten the $ for a literal number. While at it, make
    also the simulator read-only code snippet data structures
    position-independent. Some minor comment improvements. Bridge seems to
    work now on simulator.

diff --git a/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno.cxx
index 12e9d97..9e6fba0 100644
--- a/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_ios_arm/cpp2uno.cxx
@@ -367,11 +367,7 @@ extern "C" void cpp_vtable_call(
 //==================================================================================================
 extern "C" { 
 extern int nFunIndexes, nVtableOffsets;
-#ifdef __arm
 extern int codeSnippets[];
-#else
-extern unsigned char **codeSnippets;
-#endif
 }
 
 unsigned char * codeSnippet(
@@ -395,7 +391,7 @@ unsigned char * codeSnippet(
     return ((unsigned char *) &codeSnippets) + codeSnippets[functionIndex*nVtableOffsets*2 + vtableOffset*2 + bHasHiddenParam];
 #else
     enum { General, Void, Hyper, Float, Double, Class } exec;
-    int flag = 0;
+    bool bHasHiddenParam = false;
     if (pReturnTypeRef == 0) {
         exec = Void;
     }
@@ -434,7 +430,7 @@ unsigned char * codeSnippet(
         case typelib_TypeClass_SEQUENCE:
         case typelib_TypeClass_INTERFACE:
         case typelib_TypeClass_ANY:
-            flag = 1;
+            bHasHiddenParam = 1;
             exec = Class;
             break;
         default:
@@ -443,7 +439,12 @@ unsigned char * codeSnippet(
         }
     }
 
-    return codeSnippets[functionIndex*nVtableOffsets*6*2 + vtableOffset*6*2 + exec*2 + flag];
+    // The codeSnippets table is indexed by functionIndex, vtableOffset, exec and flag
+
+    fprintf(stderr, "Indexing codeSnippets with %ld [%ld,%ld,%d,%d]\n",
+            functionIndex*nVtableOffsets*6*2 + vtableOffset*6*2 + exec*2 + bHasHiddenParam,
+            functionIndex, vtableOffset, (int) exec, bHasHiddenParam);
+    return ((unsigned char *) &codeSnippets) + codeSnippets[functionIndex*nVtableOffsets*6*2 + vtableOffset*6*2 + exec*2 + bHasHiddenParam];
 #endif
 }
 
@@ -548,6 +549,7 @@ unsigned char * bridges::cpp_uno::shared::VtableFactory::addLocalFunctions(
 
 void bridges::cpp_uno::shared::VtableFactory::flushCode(
     unsigned char const *, unsigned char const *)
-{}
+{
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/bridges/source/cpp_uno/gcc3_ios_arm/except.cxx b/bridges/source/cpp_uno/gcc3_ios_arm/except.cxx
index f28d9e2..eba5d13 100644
--- a/bridges/source/cpp_uno/gcc3_ios_arm/except.cxx
+++ b/bridges/source/cpp_uno/gcc3_ios_arm/except.cxx
@@ -52,7 +52,6 @@ using namespace ::rtl;
 using namespace ::com::sun::star::uno;
 using namespace ::__cxxabiv1;
 
-
 namespace CPPU_CURRENT_NAMESPACE
 {
 
@@ -253,7 +252,6 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
 
     // destruct uno exception
     ::uno_any_destruct( pUnoExc, 0 );
-    // avoiding locked counts
 	rtti = (type_info *)RTTISingleton::get().getRTTI( (typelib_CompoundTypeDescription *) pTypeDescr );
     TYPELIB_DANGER_RELEASE( pTypeDescr );
     OSL_ENSURE( rtti, "### no rtti for throwing exception!" );
diff --git a/bridges/source/cpp_uno/gcc3_ios_arm/generate-snippets.pl b/bridges/source/cpp_uno/gcc3_ios_arm/generate-snippets.pl
index b6bd0e9..2e6d6fe 100755
--- a/bridges/source/cpp_uno/gcc3_ios_arm/generate-snippets.pl
+++ b/bridges/source/cpp_uno/gcc3_ios_arm/generate-snippets.pl
@@ -42,11 +42,13 @@ sub gen_x86 ($$$)
 {
     my ($funIndex, $vtableOffset, $executor) = @_;
     printf ("codeSnippet%08x%d%s:\n", $funIndex, $vtableOffset, $executor);
-    printf ("\tmovl %#08x, %%eax\n", $funIndex);
+    printf ("\tmovl \$%#08x, %%eax\n", $funIndex);
     printf ("\tmovl \$%d, %%edx\n", $vtableOffset);
     printf ("\tjmp _privateSnippetExecutor%s\n", $executor);
 }
 
+printf (".text\n");
+
 printf ("#ifdef __arm\n");
 printf ("\t.align 4\n");
 
@@ -60,6 +62,7 @@ foreach my $funIndex (0 .. $nFunIndexes-1)
 }
 
 printf ("#else\n");
+printf ("\t.align 1, 0x90\n");
 
 foreach my $funIndex (0 .. $nFunIndexes-1)
 {
@@ -96,8 +99,8 @@ foreach my $funIndex (0 .. $nFunIndexes-1)
 	printf ("#else\n");
 	foreach my $executor ('General', 'Void', 'Hyper', 'Float', 'Double', 'Class')
 	{
-	    printf ("\t.long codeSnippet%08x%d%s\n", $funIndex, $vtableOffset, $executor);
-	    printf ("\t.long codeSnippet%08x%d%s\n", $funIndex|0x80000000, $vtableOffset, $executor);
+	    printf ("\t.long codeSnippet%08x%d%s - _codeSnippets\n", $funIndex, $vtableOffset, $executor);
+	    printf ("\t.long codeSnippet%08x%d%s - _codeSnippets\n", $funIndex|0x80000000, $vtableOffset, $executor);
 	}
 	printf ("#endif\n");
     }
diff --git a/bridges/source/cpp_uno/gcc3_ios_arm/makefile.mk b/bridges/source/cpp_uno/gcc3_ios_arm/makefile.mk
index e3c48ea..e38399c 100644
--- a/bridges/source/cpp_uno/gcc3_ios_arm/makefile.mk
+++ b/bridges/source/cpp_uno/gcc3_ios_arm/makefile.mk
@@ -68,7 +68,7 @@ SHL1STDLIBS= \
 .INCLUDE :  target.mk
 
 $(SLO)/helper.obj: helper.S $(MISC)/codesnippets.S generate-snippets.pl
-    $(CC) -c -I $(MISC) -o $(SLO)/helper.o helper.S
+    $(CC) $(CFLAGS) -c -I $(MISC) -o $(SLO)/helper.o helper.S
     touch $@
 
 $(MISC)/codesnippets.S: generate-snippets.pl
diff --git a/bridges/source/cpp_uno/gcc3_ios_arm/share.hxx b/bridges/source/cpp_uno/gcc3_ios_arm/share.hxx
index 61cb474..06692bf 100644
--- a/bridges/source/cpp_uno/gcc3_ios_arm/share.hxx
+++ b/bridges/source/cpp_uno/gcc3_ios_arm/share.hxx
@@ -450,7 +450,7 @@ namespace abi = __cxxabiv1;
 #endif // __RTTI_H
 
 // As this code is used both for the simulatos (x86) and device (ARM),
-// this file is a combination of the share.hxx in ../gcc3_linux_intel
+// this file is a combination of the share.hxx in ../gcc3_macosx_intel
 // and in ../gcc3_linux_arm.
 
 #ifdef __arm
@@ -473,9 +473,10 @@ namespace CPPU_CURRENT_NAMESPACE
         __cxa_exception *nextException;
 
         int handlerCount;
+
 #ifdef __ARM_EABI__
-    __cxa_exception *nextPropagatingException;
-    int propagationCount;
+        __cxa_exception *nextPropagatingException;
+        int propagationCount;
 #else
         int handlerSwitchValue;
         const unsigned char *actionRecord;
@@ -545,6 +546,8 @@ struct __cxa_exception
     void *catchTemp;
     void *adjustedPtr;
 
+    size_t referenceCount;
+
     _Unwind_Exception unwindHeader;
 };
 
commit 83ba7b4e8f67cc3a21fbaf476621af509032ae47
Author: Tor Lillqvist <tml at iki.fi>
Date:   Sat Apr 14 22:15:30 2012 +0200

    Copy and adapt current state of Norbert's CoreText work for iOS
    
    Compiles, but I obviously have no idea how it works yet.
    
    Yes, eventually we should factor out common parts from the iOS and
    MacOSX code.

diff --git a/canvas/source/cairo/cairo_textlayout.cxx b/canvas/source/cairo/cairo_textlayout.cxx
index 063dc0d..30493f9 100644
--- a/canvas/source/cairo/cairo_textlayout.cxx
+++ b/canvas/source/cairo/cairo_textlayout.cxx
@@ -65,6 +65,10 @@
 # error Native API needed.
 #endif
 
+#ifdef IOS
+#include <CoreText/CoreText.h>
+#endif
+
 using namespace ::cairo;
 using namespace ::com::sun::star;
 
@@ -507,7 +511,7 @@ namespace cairocanvas
             //       when CGFont (Mac OS X 10.5 API) is provided by the AQUA VCL backend.
             font_face = cairo_quartz_font_face_create_for_atsu_font_id((ATSUFontID) rSysFontData.aATSUFontID);
 # else // iOS
-            font_face = cairo_quartz_font_face_create_for_cgfont( rSysFontData.rFont);
+            font_face = cairo_quartz_font_face_create_for_cgfont( CTFontCopyGraphicsFont( (CTFontRef) rSysFontData.rCTFont, NULL ) );
 # endif
 
 #elif defined CAIRO_HAS_WIN32_SURFACE
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 7194420..d85bd99 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -523,8 +523,10 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/ios/source/dtrans/service_entry \
     vcl/ios/source/gdi/salcoretextfontutils \
     vcl/ios/source/gdi/salcoretextlayout \
+    vcl/ios/source/gdi/salcoretextstyle \
     vcl/ios/source/gdi/salbmp \
     vcl/ios/source/gdi/salgdi \
+    vcl/ios/source/gdi/salgdicommon \
     vcl/ios/source/gdi/salnativewidgets \
     vcl/ios/source/gdi/salgdiutils \
     vcl/ios/source/gdi/salvd \
diff --git a/vcl/inc/ios/common.h b/vcl/inc/ios/common.h
new file mode 100644
index 0000000..8323df2
--- /dev/null
+++ b/vcl/inc/ios/common.h
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+#ifndef _VCL_IOS_COMMON_H
+#define _VCL_IOS_COMMON_H
+
+#include <sal/types.h>
+#include <premac.h>
+#include <CoreGraphics/CoreGraphics.h>
+#include <CoreText/CoreText.h>
+#include <UIKit/UIKit.h>
+#include <postmac.h>
+#include <tools/debug.hxx>
+
+// CoreFoundation designers, in their wisdom, decided that CFRelease of NULL
+// cause a Crash, yet few API can return NULL when asking for the creation
+// of an object, which force us to peper the code with egly if construct everywhere
+// and open the door to very nasty crash on rare occasion
+// this macro hide the mess
+#define SafeCFRelease(a) do { if(a) { CFRelease(a); (a)=NULL; } } while(false)
+
+
+#define round_to_long(a) ((a) >= 0 ? ((long)((a) + 0.5)) : ((long)((a) - 0.5)))
+
+#include "vcl/salgtype.hxx"
+
+#endif/* _VCL_IOS_COMMON_H */
+
+//#define msgs_debug(c,f,...)
+//    fprintf(stderr, "%s::%s(%p:%04.4x)\n", this, #c, __func__, 0, __VA_ARGS__ )
+
+#define msgs_debug(c,f,...)                                             \
+    fprintf(stderr, "%s::%s(%p:%4.4u)" f "\n", #c, __func__, this, ((unsigned int)pthread_self() & 8191), ##__VA_ARGS__ );
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/ios/salcoretextfontutils.hxx b/vcl/inc/ios/salcoretextfontutils.hxx
index ed94b91..bcc399c 100644
--- a/vcl/inc/ios/salcoretextfontutils.hxx
+++ b/vcl/inc/ios/salcoretextfontutils.hxx
@@ -26,17 +26,48 @@
  *
  ************************************************************************/
 
-#ifndef _SV_SALCORETEXTFONTUTILS_HXX
-#define _SV_SALCORETEXTFONTUTILS_HXX
+#ifndef _VCL_IOS_CORETEXT_SALCORETEXTFONTUTILS_HXX
+#define _VCL_IOS_CORETEXT_SALCORETEXTFONTUTILS_HXX
 
-class ImplIosFontData;
+class ImplCoreTextFontData;
 class ImplDevFontList;
 
-#include <premac.h>
-#include <CoreText/CoreText.h>
-#include <postmac.h>
+#include <boost/unordered_map.hpp>
 
-#include <map>
+#include <vcl/fontcapabilities.hxx>
+
+#include "outfont.hxx"
+#include "impfont.hxx"
+
+class ImplCoreTextFontData : public ImplFontData
+{
+public:
+    ImplCoreTextFontData(const ImplDevFontAttributes&, CTFontRef font);
+    virtual ~ImplCoreTextFontData();
+    virtual ImplFontData* Clone() const;
+    virtual ImplFontEntry* CreateFontInstance( FontSelectPattern& ) const;
+    virtual sal_IntPtr GetFontId() const { return (sal_IntPtr)m_CTFontRef;};
+    CTFontRef GetCTFont() const { return m_CTFontRef; };
+    const ImplFontCharMap* GetImplFontCharMap();
+    bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities);
+    bool HasChar( sal_uInt32 cChar ) const;
+    void ReadOs2Table();
+    void ReadIosCmapEncoding();
+    bool HasCJKSupport();
+    bool GetRawFontData( std::vector<unsigned char>& rBuffer, bool* pJustCFF ) const;
+
+private:
+    void DetermineCJKSupport_OS2(CFDataRef rOS2Table);
+    void DetermineCJKSupport_cmap(CFDataRef rCmapTable);
+    CTFontRef m_CTFontRef;
+    mutable const ImplFontCharMap* m_pCharMap;
+    mutable vcl::FontCapabilities m_aFontCapabilities;
+    mutable bool m_bHasOs2Table;
+    mutable bool m_bOs2TableRead;
+    mutable bool m_bCmapTableRead; // true if cmap encoding of Mac font is read
+    mutable bool m_bHasCJKSupport; // #i78970# CJK fonts need extra leading
+    mutable bool m_bFontCapabilitiesRead;
+};
 
 /* This class has the responsibility of assembling a list of CoreText
    fonts available on the system and enabling access to that list.
@@ -48,15 +79,15 @@ public:
     ~SystemFontList();
 
     void AnnounceFonts( ImplDevFontList& ) const;
-    ImplIosFontData* GetFontDataFromRef( CTFontRef ) const;
+    ImplCoreTextFontData* GetFontDataFromRef( CTFontRef ) const;
 
 private:
-    typedef boost::unordered_map<CTFontRef,ImplIosFontData*> IosFontContainer;
-    IosFontContainer maFontContainer;
+    typedef boost::unordered_map<CTFontRef,ImplCoreTextFontData*> CoreTextFontContainer;
+    CoreTextFontContainer m_aFontContainer;
 
     void InitGlyphFallbacks();
 };
 
-#endif  // _SV_SALCORETEXTFONTUTILS_HXX
+#endif  // _VCL_IOS_CORETEXT_SALCORETEXTFONTUTILS_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/ios/salcoretextlayout.hxx b/vcl/inc/ios/salcoretextlayout.hxx
new file mode 100644
index 0000000..523d826
--- /dev/null
+++ b/vcl/inc/ios/salcoretextlayout.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _VCL_IOS_CORETEXT_SALCORETEXTLAYOUT_HXX
+#define _VCL_IOS_CORETEXT_SALCORETEXTLAYOUT_HXX
+
+#include <tools/poly.hxx>
+
+#include "sallayout.hxx"
+
+class IosSalGraphics;
+class CoreTextStyleInfo;
+
+class CoreTextLayout : public SalLayout
+{
+public:
+    CoreTextLayout( IosSalGraphics* graphics, CoreTextStyleInfo* style);
+    virtual         ~CoreTextLayout();
+
+    virtual void AdjustLayout( ImplLayoutArgs& );
+    virtual void DrawText( SalGraphics& ) const;
+    virtual void DropGlyph( int nStart );
+    virtual long FillDXArray( long* pDXArray ) const;
+    virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const;
+    virtual void GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
+    virtual bool GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const;
+    virtual int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos, int&,
+                               sal_Int32* pGlyphAdvances, int* pCharIndexes ) const;
+    virtual int GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const;
+    virtual long GetTextWidth() const;
+    virtual void InitFont() const;
+    virtual bool LayoutText( ImplLayoutArgs& );
+    virtual void MoveGlyph( int nStart, long nNewXPos );
+    virtual void Simplify( bool bIsBase );
+
+private:
+    void Clean();
+    bool InitGIA() const;
+
+    IosSalGraphics* m_graphics;
+    CoreTextStyleInfo* m_style;
+    mutable int m_glyphs_count;
+    mutable int m_chars_count;
+    mutable int* m_chars2glyphs;
+    mutable int* m_glyphs2chars;
+    mutable CGGlyph* m_glyphs;
+    mutable int* m_char_widths;
+    mutable int* m_glyph_advances;
+    mutable CGPoint* m_glyph_positions;
+    CTTypesetterRef m_typesetter;
+    CTLineRef m_line;
+    mutable bool m_has_bound_rec;
+    mutable Rectangle m_bound_rect;
+    CGFloat m_base_advance;
+    mutable CGFloat m_cached_width;
+    mutable CFIndex m_current_run_index;
+    mutable CFIndex m_current_glyph_index;
+    mutable CFIndex m_current_glyphrun_index;
+    mutable CFArrayRef m_runs;
+
+};
+
+#endif // _VCL_IOS_CORETEXT_SALCORETEXTLAYOUT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/ios/salcoretextstyle.hxx b/vcl/inc/ios/salcoretextstyle.hxx
new file mode 100644
index 0000000..3cdade1
--- /dev/null
+++ b/vcl/inc/ios/salcoretextstyle.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+
+#ifndef _VCL_AQUA_CORETEXT_SALCORETEXTSTYLE_HXX
+#define _VCL_AQUA_CORETEXT_SALCORETEXTSTYLE_HXX
+
+#include "ios/salgdicommon.hxx"
+
+class FontSelectPattern;
+class ImplCoreTextFontData;
+
+class CoreTextStyleInfo
+{
+public:
+    CoreTextStyleInfo();
+    ~CoreTextStyleInfo();
+    CTFontRef GetFont() const { return m_CTFont; };
+    long GetFontStretchedSize() const;
+    float GetFontStretchFactor() const { return m_stretch_factor; };
+    CTParagraphStyleRef GetParagraphStyle() const { return m_CTParagraphStyle; } ;
+    CGSize    GetSize() const;
+    CGColorRef GetColor() const { return m_color; } ;
+    void SetColor(SalColor color);
+    void SetColor(void);
+    void SetFont(FontSelectPattern* requested_font);
+
+private:
+    bool m_fake_bold;
+    bool m_fake_italic;
+    CGAffineTransform m_matrix;
+    float m_stretch_factor;
+    float m_font_scale;
+    float m_fake_dpi_scale;
+    CTParagraphStyleRef m_CTParagraphStyle;
+    CTFontRef m_CTFont;
+    CGColorRef m_color;
+    const ImplCoreTextFontData* m_font_data;
+
+};
+
+#endif // _VCL_AQUA_CORETEXT_SALCORETEXTSTYLE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/ios/salgdi.h b/vcl/inc/ios/salgdi.h
index 576a8df..2828b4e 100644
--- a/vcl/inc/ios/salgdi.h
+++ b/vcl/inc/ios/salgdi.h
@@ -26,262 +26,206 @@
  *
  ************************************************************************/
 
-#ifndef _SV_SALGDI_H
-#define _SV_SALGDI_H
+#ifndef _VCL_IOS_SALGDI_H
+#define _VCL_IOS_SALGDI_H
 
 #include "basegfx/polygon/b2dpolypolygon.hxx"
 
 #include "ios/iosvcltypes.h"
-#include <vcl/fontcapabilities.hxx>
-
-#include "outfont.hxx"
+#include "ios/salcoretextfontutils.hxx"
+#include "ios/salframe.h"
 #include "salgdi.hxx"
 
-#include <vector>
-
-class IosSalFrame;
-class IosSalBitmap;
-class ImplDevFontAttributes;
-
-struct CGRect;
-
-// mac specific physically available font face
-class ImplIosFontData : public ImplFontData
-{
-public:
-    ImplIosFontData( const ImplDevFontAttributes&, CTFontRef );
-
-    virtual ~ImplIosFontData();
-
-    virtual ImplFontData*   Clone() const;
-    virtual ImplFontEntry*  CreateFontInstance( FontSelectPattern& ) const;
-    virtual sal_IntPtr      GetFontId() const;
-
-    const ImplFontCharMap*  GetImplFontCharMap() const;
-    bool                    GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const;
-    bool                    HasChar( sal_uInt32 cChar ) const;
+#include "ios/salgdicommon.hxx"
 
-    void                    ReadOs2Table() const;
-    void                    ReadIosCmapEncoding() const;
-    bool                    HasCJKSupport() const;
-
-protected:
-    friend class IosSalGraphics;
-    const CTFontRef             mpFontRef;
-
-private:
-    mutable const ImplFontCharMap*  mpCharMap;
-    mutable vcl::FontCapabilities maFontCapabilities;
-    mutable bool                mbOs2Read;       // true if OS2-table related info is valid
-    mutable bool                mbHasOs2Table;
-    mutable bool                mbCmapEncodingRead; // true if cmap encoding of Ios font is read
-    mutable bool                mbHasCJKSupport; // #i78970# CJK fonts need extra leading
-    mutable bool                mbFontCapabilitiesRead;
-};
-
-// abstracting quartz color instead of having to use an CGFloat[] array
-class RGBAColor
-{
-public:
-    RGBAColor( SalColor );
-    RGBAColor( float fRed, float fGreen, float fBlue, float fAlpha ); //NOTUSEDYET
-    const float* AsArray() const    { return &mfRed; }
-    bool IsVisible() const          { return (mfAlpha > 0); }
-    void SetAlpha( float fAlpha )   { mfAlpha = fAlpha; }
-private:
-    float mfRed, mfGreen, mfBlue, mfAlpha;
-};
+class CoreTextStyleInfo;
 
 // -------------------
 // - IosSalGraphics -
 // -------------------
 class IosSalGraphics : public SalGraphics
 {
+    friend class CoreTextLayout;
 protected:
-    IosSalFrame*                           mpFrame;
-    CGLayerRef                              mxLayer;    // Quartz graphics layer
-    CGContextRef                            mrContext;  // Quartz drawing context
-    class XorEmulation*                     mpXorEmulation;
-    int                                     mnXorMode; // 0: off 1: on 2: invert only
-    int                                     mnWidth;
-    int                                     mnHeight;
-    int                                     mnBitmapDepth;  // zero unless bitmap
-    /// device resolution of this graphics
-    long                                    mnRealDPIX;
-    long                                    mnRealDPIY;
+    IosSalFrame* mpFrame;
+    CGLayerRef mxLayer;    //< Quartz graphics layer
+    CGContextRef mrContext;  //< Quartz drawing context
+    class XorEmulation* mpXorEmulation;
+    int mnXorMode; //< 0: off 1: on 2: invert only
+    int mnWidth;
+    int mnHeight;
+    int mnBitmapDepth;  //< zero unless bitmap
+    long mnRealDPIX; //< device X-resolution of this graphics
+    long mnRealDPIY; //< device Y-resolution of this graphics
+
     /// some graphics implementations (e.g. IosSalInfoPrinter) scale
     /// everything down by a factor (see SetupPrinterGraphics for details)
     /// so we have to compensate for it with the inverse factor
-    double                                  mfFakeDPIScale;
+    double mfFakeDPIScale;
+    double mfFontScale;
+
 
-    /// path representing current clip region
-    CGMutablePathRef                        mxClipPath;
+    CGMutablePathRef mxClipPath; //< path representing current clip region
 
     /// Drawing colors
-    /// pen color RGBA
-    RGBAColor                               maLineColor;
-    /// brush color RGBA
-    RGBAColor                               maFillColor;
-
-    // Device Font settings
-    const ImplIosFontData*                  mpIosFontData;
-    /// Font attributes ???
-    NSMutableDictionary*                    mpAttributes;
-    // text color
-    SalColor                                mnColor;
-    /// text rotation ???
-    Fixed                                   mnRotation;
-    /// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
-    float                                   mfFontStretch;
-    /// allows text to be rendered without antialiasing
-    bool                                    mbNonAntialiasedText;
+    RGBAColor maLineColor; //< pen color RGBA
+    RGBAColor maFillColor; //< brush color RGBA
+
+    ImplCoreTextFontData* m_pCoreTextFontData; //< Device Font settings
+
+    bool mbNonAntialiasedText; //< allows text to be rendered without antialiasing
 
     // Graphics types
 
-    /// is this a printer graphics
-    bool                                    mbPrinter;
-    /// is this a virtual device graphics
-    bool                                    mbVirDev;
-    /// is this a window graphics
-    bool                                    mbWindow;
+    bool mbPrinter; //< is this a printer graphics
+    bool mbVirDev; //< is this a virtual device graphics
+    bool mbWindow; //< is this a window graphics
+
+    CoreTextStyleInfo* m_style;
 
 public:
     IosSalGraphics();
     virtual ~IosSalGraphics();
 
-    bool                IsPenVisible() const    { return maLineColor.IsVisible(); }
-    bool                IsBrushVisible() const  { return maFillColor.IsVisible(); }
+    bool IsPenVisible() const { return maLineColor.IsVisible(); }
+    bool IsBrushVisible() const { return maFillColor.IsVisible(); }
 
-    void                SetWindowGraphics( IosSalFrame* pFrame );
-    void                SetPrinterGraphics( CGContextRef, long nRealDPIX, long nRealDPIY, double fFakeScale );
-    void                SetVirDevGraphics( CGLayerRef, CGContextRef, int nBitDepth = 0 );
+    void SetWindowGraphics( IosSalFrame* pFrame );
+    void SetPrinterGraphics( CGContextRef, long nRealDPIX, long nRealDPIY, double fFakeScale );
+    void SetVirDevGraphics( CGLayerRef, CGContextRef, int nBitDepth = 0 );
 
-    void                initResolution( UIWindow* );
-    void                copyResolution( IosSalGraphics& );
-    void                updateResolution();
+    void initResolution( UIWindow* );
+    void copyResolution( IosSalGraphics& );
+    void updateResolution();
 
-    bool                IsWindowGraphics()      const   { return mbWindow; }
-    bool                IsPrinterGraphics()     const   { return mbPrinter; }
-    bool                IsVirDevGraphics()      const   { return mbVirDev; }
-    IosSalFrame*       getGraphicsFrame() const { return mpFrame; }
-    void                setGraphicsFrame( IosSalFrame* pFrame ) { mpFrame = pFrame; }
+    bool IsWindowGraphics() const { return mbWindow; }
+    bool IsPrinterGraphics() const { return mbPrinter; }
+    bool IsVirDevGraphics() const { return mbVirDev; }
+    IosSalFrame* getGraphicsFrame() const { return mpFrame; }
+    void setGraphicsFrame( IosSalFrame* pFrame ) { mpFrame = pFrame; }
 
-    void                ImplDrawPixel( long nX, long nY, const RGBAColor& ); // helper to draw single pixels
+    void ImplDrawPixel( long nX, long nY, const RGBAColor& ); // helper to draw single pixels
 
-    bool                CheckContext();
-    void                UpdateWindow( CGRect& ); // delivered in NSView coordinates
-    void                RefreshRect( const CGRect& );
-    void                RefreshRect(float lX, float lY, float lWidth, float lHeight);
+    bool CheckContext();
+    CGContextRef GetContext();
+    void UpdateWindow( CGRect& ); // delivered in UIView coordinates
+    void RefreshRect( const CGRect& );
+    void RefreshRect(float lX, float lY, float lWidth, float lHeight);
 
-    void                SetState();
-    void                UnsetState();
+    void SetState();
+    void UnsetState();
     // InvalidateContext does an UnsetState and sets mrContext to 0
-    void                InvalidateContext();
+    void InvalidateContext();
 
-    virtual bool        setClipRegion( const Region& );
+    virtual bool setClipRegion( const Region& );
 
     // draw --> LineColor and FillColor and RasterOp and ClipRegion
-    virtual void        drawPixel( long nX, long nY );
-    virtual void        drawPixel( long nX, long nY, SalColor nSalColor );
-    virtual void        drawLine( long nX1, long nY1, long nX2, long nY2 );
-    virtual void        drawRect( long nX, long nY, long nWidth, long nHeight );
-    virtual void        drawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry );
-    virtual void        drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry );
-    virtual void        drawPolyPolygon( sal_uLong nPoly, const sal_uLong* pPoints, PCONSTSALPOINT* pPtAry );
-    virtual bool        drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency );
-    virtual sal_Bool    drawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry );
-    virtual sal_Bool    drawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry );
-    virtual sal_Bool    drawPolyPolygonBezier( sal_uLong nPoly, const sal_uLong* pPoints, const SalPoint* const* pPtAry, const sal_uInt8* const* pFlgAry );
-    virtual bool        drawPolyLine( const ::basegfx::B2DPolygon&, double fTransparency, const ::basegfx::B2DVector& rLineWidths, basegfx::B2DLineJoin );
+    virtual void drawPixel( long nX, long nY );
+    virtual void drawPixel( long nX, long nY, SalColor nSalColor );
+    virtual void drawLine( long nX1, long nY1, long nX2, long nY2 );
+    virtual void drawRect( long nX, long nY, long nWidth, long nHeight );
+    virtual void drawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry );
+    virtual void drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry );
+    virtual void drawPolyPolygon( sal_uLong nPoly, const sal_uLong* pPoints, PCONSTSALPOINT* pPtAry );
+    virtual bool drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency );
+    virtual sal_Bool drawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry );
+    virtual sal_Bool drawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry );
+    virtual sal_Bool drawPolyPolygonBezier( sal_uLong nPoly, const sal_uLong* pPoints,
+                                            const SalPoint* const* pPtAry, const sal_uInt8* const* pFlgAry );
+    virtual bool drawPolyLine( const ::basegfx::B2DPolygon&, double fTransparency,
+                               const ::basegfx::B2DVector& rLineWidths, basegfx::B2DLineJoin );
 
     // CopyArea --> No RasterOp, but ClipRegion
-    virtual void        copyArea( long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth,
-                                  long nSrcHeight, sal_uInt16 nFlags );
+    virtual void copyArea( long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth,
+                           long nSrcHeight, sal_uInt16 nFlags );
 
     // CopyBits and DrawBitmap --> RasterOp and ClipRegion
     // CopyBits() --> pSrcGraphics == NULL, then CopyBits on same Graphics
-    virtual void        copyBits( const SalTwoRect* pPosAry, SalGraphics* pSrcGraphics );
-    virtual void        drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap );
-    virtual void        drawBitmap( const SalTwoRect* pPosAry,
-                                    const SalBitmap& rSalBitmap,
-                                    SalColor nTransparentColor );
-    virtual void        drawBitmap( const SalTwoRect* pPosAry,
-                                    const SalBitmap& rSalBitmap,
-                                    const SalBitmap& rTransparentBitmap );
-    virtual void        drawMask( const SalTwoRect* pPosAry,
-                                  const SalBitmap& rSalBitmap,
-                                  SalColor nMaskColor );
-
-    virtual SalBitmap*  getBitmap( long nX, long nY, long nWidth, long nHeight );
-    virtual SalColor    getPixel( long nX, long nY );
+    virtual void copyBits( const SalTwoRect* pPosAry, SalGraphics* pSrcGraphics );
+    virtual void drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap );
+    virtual void drawBitmap( const SalTwoRect* pPosAry,
+                             const SalBitmap& rSalBitmap,
+                             SalColor nTransparentColor );
+    virtual void drawBitmap( const SalTwoRect* pPosAry,
+                             const SalBitmap& rSalBitmap,
+                             const SalBitmap& rTransparentBitmap );
+    virtual void drawMask( const SalTwoRect* pPosAry,
+                           const SalBitmap& rSalBitmap,
+                           SalColor nMaskColor );
+
+    virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight );
+    virtual SalColor getPixel( long nX, long nY );
 
     // invert --> ClipRegion (only Windows or VirDevs)
-    virtual void        invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags);
-    virtual void        invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nFlags );
+    virtual void invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags);
+    virtual void invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nFlags );
 
-    virtual sal_Bool        drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize );
+    virtual sal_Bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize );
 
-    virtual bool            drawAlphaBitmap( const SalTwoRect&,
-                                             const SalBitmap& rSourceBitmap,
-                                             const SalBitmap& rAlphaBitmap );
+    virtual bool drawAlphaBitmap( const SalTwoRect&,
+                                  const SalBitmap& rSourceBitmap,
+                                  const SalBitmap& rAlphaBitmap );
 
-    virtual bool            drawAlphaRect( long nX, long nY, long nWidth,
-                                           long nHeight, sal_uInt8 nTransparency );
+    virtual bool drawAlphaRect( long nX, long nY, long nWidth,
+                                long nHeight, sal_uInt8 nTransparency );
 
-    CGPoint*                makeCGptArray(sal_uLong nPoints, const SalPoint*  pPtAry);
+    CGPoint* makeCGptArray(sal_uLong nPoints, const SalPoint*  pPtAry);
     // native widget rendering methods that require mirroring
-    virtual sal_Bool        hitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
-                                              const Point& aPos, sal_Bool& rIsInside );
-    virtual sal_Bool        drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
-                                           ControlState nState, const ImplControlValue& aValue,
-                                           const rtl::OUString& aCaption );
-    virtual sal_Bool        getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState,
-                                                const ImplControlValue& aValue, const rtl::OUString& aCaption,
-                                                Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion );
+    virtual sal_Bool hitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
+                                           const Point& aPos, sal_Bool& rIsInside );
+    virtual sal_Bool drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
+                                        ControlState nState, const ImplControlValue& aValue,
+                                        const rtl::OUString& aCaption );
+    virtual sal_Bool getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
+                                             ControlState nState, const ImplControlValue& aValue,
+                                             const rtl::OUString& aCaption,
+                                             Rectangle &rNativeBoundingRegion,
+                                             Rectangle &rNativeContentRegion );
 
     // get device resolution
-    virtual void            GetResolution( long& rDPIX, long& rDPIY );
+    virtual void GetResolution( long& rDPIX, long& rDPIY );
     // get the depth of the device
-    virtual sal_uInt16          GetBitCount() const;
+    virtual sal_uInt16 GetBitCount() const;
     // get the width of the device
-    virtual long            GetGraphicsWidth() const;
+    virtual long GetGraphicsWidth() const;
 
     // set the clip region to empty
-    virtual void            ResetClipRegion();
+    virtual void ResetClipRegion();
 
     // set the line color to transparent (= don't draw lines)
-    virtual void            SetLineColor();
+    virtual void SetLineColor();
     // set the line color to a specific color
-    virtual void            SetLineColor( SalColor nSalColor );
+    virtual void SetLineColor( SalColor nSalColor );
     // set the fill color to transparent (= don't fill)
-    virtual void            SetFillColor();
+    virtual void SetFillColor();
     // set the fill color to a specific color, shapes will be
     // filled accordingly
-    virtual void            SetFillColor( SalColor nSalColor );
+    virtual void SetFillColor( SalColor nSalColor );
     // enable/disable XOR drawing
-    virtual void            SetXORMode( bool bSet, bool bInvertOnly );
+    virtual void SetXORMode( bool bSet, bool bInvertOnly );
     // set line color for raster operations
-    virtual void            SetROPLineColor( SalROPColor nROPColor );
+    virtual void SetROPLineColor( SalROPColor nROPColor );
     // set fill color for raster operations
-    virtual void            SetROPFillColor( SalROPColor nROPColor );
+    virtual void SetROPFillColor( SalROPColor nROPColor );
     // set the text color to a specific color
-    virtual void            SetTextColor( SalColor nSalColor );
+    virtual void SetTextColor( SalColor nSalColor );
     // set the font
-    virtual sal_uInt16         SetFont( FontSelectPattern*, int nFallbackLevel );
+    virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel );
     // get the current font's etrics
-    virtual void            GetFontMetric( ImplFontMetricData*, int nFallbackLevel );
+    virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel );
     // get kernign pairs of the current font
     // return only PairCount if (pKernPairs == NULL)
-    virtual sal_uLong           GetKernPairs( sal_uLong nPairs, ImplKernPairData* pKernPairs );
+    virtual sal_uLong GetKernPairs( sal_uLong nPairs, ImplKernPairData* pKernPairs );
     // get the repertoire of the current font
     virtual const ImplFontCharMap* GetImplFontCharMap() const;
     virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const;
     // graphics must fill supplied font list
-    virtual void            GetDevFontList( ImplDevFontList* );
+    virtual void GetDevFontList( ImplDevFontList* );
     // graphics should call ImplAddDevFontSubstitute on supplied
     // OutputDevice for all its device specific preferred font substitutions
-    virtual void            GetDevFontSubstList( OutputDevice* );
-    virtual bool            AddTempDevFont( ImplDevFontList*, const rtl::OUString& rFileURL, const rtl::OUString& rFontName );
+    virtual void GetDevFontSubstList( OutputDevice* );
+    virtual bool AddTempDevFont( ImplDevFontList*, const rtl::OUString& rFileURL,
+                                 const rtl::OUString& rFontName );
     // CreateFontSubset: a method to get a subset of glyhps of a font
     // inside a new valid font file
     // returns TRUE if creation of subset was successfull
@@ -294,14 +238,13 @@ public:
     //             rInfo: additional outgoing information
     // implementation note: encoding 0 with glyph id 0 should be added implicitly
     // as "undefined character"
-    virtual sal_Bool            CreateFontSubset( const rtl::OUString& rToFile,
-                                              const ImplFontData* pFont,
-                                              long* pGlyphIDs,
-                                              sal_uInt8* pEncoding,
-                                              sal_Int32* pWidths,
-                                              int nGlyphs,
-                                              FontSubsetInfo& rInfo // out parameter
-                                              );
+    virtual sal_Bool CreateFontSubset( const rtl::OUString& rToFile,
+                                       const ImplFontData* pFont,
+                                       long* pGlyphIDs,
+                                       sal_uInt8* pEncoding,
+                                       sal_Int32* pWidths,
+                                       int nGlyphs,
+                                       FontSubsetInfo& rInfo);
 
     // GetFontEncodingVector: a method to get the encoding map Unicode
     // to font encoded character; this is only used for type1 fonts and
@@ -325,84 +268,45 @@ public:
                                           FontSubsetInfo& rInfo,
                                           long* pDataLen );
     // frees the font data again
-    virtual void            FreeEmbedFontData( const void* pData, long nDataLen );
+    virtual void FreeEmbedFontData( const void* pData, long nDataLen );
 
-    virtual void            GetGlyphWidths( const ImplFontData*,
-                                            bool bVertical,
-                                            Int32Vector& rWidths,
-                                            Ucs2UIntMap& rUnicodeEnc );
+    virtual void GetGlyphWidths( const ImplFontData*,
+                                 bool bVertical,
+                                 Int32Vector& rWidths,
+                                 Ucs2UIntMap& rUnicodeEnc );
 
-    virtual sal_Bool                    GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& );
-    virtual sal_Bool                    GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& );
+    virtual sal_Bool GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& );
+    virtual sal_Bool GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& );
 
-    virtual SalLayout*              GetTextLayout( ImplLayoutArgs&, int nFallbackLevel );
-    virtual void                     DrawServerFontLayout( const ServerFontLayout& );
-    virtual bool                    supportsOperation( OutDevSupportType ) const;
+    virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel );
+    virtual void DrawServerFontLayout( const ServerFontLayout& );
+    virtual bool supportsOperation( OutDevSupportType ) const;
 
     // Query the platform layer for control support
     virtual sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart );
 
-    virtual SystemGraphicsData    GetGraphicsData() const;
-    virtual SystemFontData        GetSysFontData( int /* nFallbacklevel */ ) const;
+    virtual SystemGraphicsData GetGraphicsData() const;
+    virtual SystemFontData GetSysFontData( int /* nFallbacklevel */ ) const;
 
 private:
     // 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; }
+    bool IsFlipped() const { return mbWindow; };
 
     void ApplyXorContext();
     void Pattern50Fill();
     UInt32 getState( ControlState nState );
     UInt32 getTrackState( ControlState nState );
+    bool GetRawFontData( const ImplFontData* pFontData,
+                         std::vector<unsigned char>& rBuffer,
+                         bool* pJustCFF );
 };
 
-class XorEmulation
-{
-public:
-                    XorEmulation();
-    /*final*/       ~XorEmulation();
-
-    void            SetTarget( int nWidth, int nHeight, int nBitmapDepth, CGContextRef, CGLayerRef );
-    bool            UpdateTarget();
-    void            Enable()            { mbIsEnabled = true; }
-    void            Disable()           { mbIsEnabled = false; }
-    bool            IsEnabled() const   { return mbIsEnabled; }
-    CGContextRef    GetTargetContext() const { return mxTargetContext; }
-    CGContextRef    GetMaskContext() const { return (mbIsEnabled ? mxMaskContext : NULL); }
-
-private:
-    CGLayerRef      mxTargetLayer;
-    CGContextRef    mxTargetContext;
-    CGContextRef    mxMaskContext;
-    CGContextRef    mxTempContext;
-    sal_uLong*          mpMaskBuffer;
-    sal_uLong*          mpTempBuffer;
-    int             mnBufferLongs;
-    bool            mbIsEnabled;
-};
-
-
-// --- some trivial inlines
-
 inline void IosSalGraphics::RefreshRect( const CGRect& rRect )
 {
     RefreshRect( rRect.origin.x, rRect.origin.y, rRect.size.width, rRect.size.height );
 }
 
-inline RGBAColor::RGBAColor( SalColor nSalColor )
-:   mfRed( SALCOLOR_RED(nSalColor) * (1.0/255))
-,   mfGreen( SALCOLOR_GREEN(nSalColor) * (1.0/255))
-,   mfBlue( SALCOLOR_BLUE(nSalColor) * (1.0/255))
-,   mfAlpha( 1.0 )  // opaque
-{}
-
-inline RGBAColor::RGBAColor( float fRed, float fGreen, float fBlue, float fAlpha )
-:   mfRed( fRed )
-,   mfGreen( fGreen )
-,   mfBlue( fBlue )
-,   mfAlpha( fAlpha )
-{}
-
-#endif // _SV_SALGDI_H
+#endif // _VCL_IOS_SALGDI_H
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/ios/salgdicommon.hxx b/vcl/inc/ios/salgdicommon.hxx
new file mode 100644
index 0000000..795fe50
--- /dev/null
+++ b/vcl/inc/ios/salgdicommon.hxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org.  If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _VCL_IOS_SALGDICOMMON_H
+#define _VCL_IOS_SALGDICOMMON_H
+
+// abstracting quartz color instead of having to use an CGFloat[] array
+class RGBAColor
+{
+public:
+    RGBAColor( SalColor );
+    RGBAColor( float fRed, float fGreen, float fBlue, float fAlpha ); //NOTUSEDYET
+    const float* AsArray() const { return &m_fRed; }
+    bool IsVisible() const { return m_fAlpha > 0; }
+    void SetAlpha( float fAlpha ) { m_fAlpha = fAlpha; }
+private:
+    float m_fRed, m_fGreen, m_fBlue, m_fAlpha;
+};
+
+inline RGBAColor::RGBAColor( SalColor nSalColor )
+:   m_fRed( SALCOLOR_RED(nSalColor) * (1.0/255))
+,   m_fGreen( SALCOLOR_GREEN(nSalColor) * (1.0/255))
+,   m_fBlue( SALCOLOR_BLUE(nSalColor) * (1.0/255))
+,   m_fAlpha( 1.0 )  // opaque
+{}
+
+inline RGBAColor::RGBAColor( float fRed, float fGreen, float fBlue, float fAlpha )
+:   m_fRed( fRed )
+,   m_fGreen( fGreen )
+,   m_fBlue( fBlue )
+,   m_fAlpha( fAlpha )
+{}
+
+class XorEmulation
+{
+public:
+    XorEmulation();
+    ~XorEmulation();
+
+    void SetTarget( int nWidth, int nHeight, int nBitmapDepth, CGContextRef, CGLayerRef );
+    bool UpdateTarget();
+    void Enable() { m_bIsEnabled = true; }
+    void Disable() { m_bIsEnabled = false; }
+    bool IsEnabled() const { return m_bIsEnabled; }
+    CGContextRef GetTargetContext() const { return m_xTargetContext; }
+    CGContextRef GetMaskContext() const { return (m_bIsEnabled ? m_xMaskContext : NULL); }
+
+private:
+    CGLayerRef m_xTargetLayer;
+    CGContextRef m_xTargetContext;
+    CGContextRef m_xMaskContext;
+    CGContextRef m_xTempContext;
+    sal_uLong* m_pMaskBuffer;
+    sal_uLong* m_pTempBuffer;
+    int m_nBufferLongs;
+    bool m_bIsEnabled;
+};
+
+#endif /* _VCL_IOS_SALGDICOMMON_H */
diff --git a/vcl/inc/vcl/sysdata.hxx b/vcl/inc/vcl/sysdata.hxx
index 4e4e71f..81195b1 100644
--- a/vcl/inc/vcl/sysdata.hxx
+++ b/vcl/inc/vcl/sysdata.hxx
@@ -203,7 +203,7 @@ struct SystemFontData
 #elif defined( QUARTZ )
     void*           aATSUFontID;    // native font object
 #elif defined( IOS )
-    CGFontRef       rFont;          // native font object
+    void*           rCTFont;        // native font object
 #elif defined( UNX )
     void*           nFontId;        // native font id
     int             nFontFlags;     // native font flags
diff --git a/vcl/ios/source/gdi/salcoretextfontutils.cxx b/vcl/ios/source/gdi/salcoretextfontutils.cxx
index 388d497..2d88c8d 100644
--- a/vcl/ios/source/gdi/salcoretextfontutils.cxx
+++ b/vcl/ios/source/gdi/salcoretextfontutils.cxx
@@ -26,74 +26,595 @@
  *
  ************************************************************************/
 
-#include <boost/assert.hpp>
-#include <vector>
-#include <set>
+#include "ios/common.h"
 
-#include "vcl/svapp.hxx"
-
-#include "ios/salgdi.h"
-#include "ios/saldata.hxx"
 #include "ios/salcoretextfontutils.hxx"
+#include "ios/salgdi.h"
+
+#include "sft.hxx"
+#include "ios/salinst.h"
+
+
+static bool GetDevFontAttributes( CTFontDescriptorRef font_descriptor, ImplDevFontAttributes& rDFA  )
+{
+
+    // reset the attributes
+    rDFA.meFamily     = FAMILY_DONTKNOW;
+    rDFA.mePitch      = PITCH_VARIABLE;
+    rDFA.meWidthType  = WIDTH_NORMAL;
+    rDFA.meWeight     = WEIGHT_NORMAL;
+    rDFA.meItalic     = ITALIC_NONE;
+    rDFA.mbSymbolFlag = false;
+    rDFA.mbOrientation = true;
+    rDFA.mbDevice      = true;
+    rDFA.mnQuality     = 0;
+
+    CFNumberRef format = (CFNumberRef)CTFontDescriptorCopyAttribute(font_descriptor, kCTFontFormatAttribute);
+    int value = 0;
+    CFNumberGetValue(format, kCFNumberIntType, &value);
+    CFRelease(format);
+
+    if (value == kCTFontFormatBitmap)
+    {
+        /* we don't want bitmap fonts */
+        return false;
+    }
+    rDFA.mbSubsettable  = true;
+    rDFA.mbEmbeddable   = false;
+
+    CFStringRef family_name = (CFStringRef)CTFontDescriptorCopyAttribute(font_descriptor, kCTFontFamilyNameAttribute);
+    rDFA.maName = GetOUString(family_name);
+    CFRelease(family_name);
+
+    CFDictionaryRef traits = (CFDictionaryRef)CTFontDescriptorCopyAttribute(font_descriptor, kCTFontTraitsAttribute);
+    CFNumberRef symbolics = (CFNumberRef)CFDictionaryGetValue(traits, kCTFontSymbolicTrait);
+
+    value = 0;
+    CFNumberGetValue(symbolics, kCFNumberIntType, &value);
+    CFRelease(symbolics);
+
+    if (value & kCTFontMonoSpaceTrait)
+    {
+        rDFA.mePitch = PITCH_FIXED;
+    }
+
+    if (value & kCTFontItalicTrait)
+    {
+        rDFA.meItalic = ITALIC_NORMAL;
+    }
+
+    if (value & kCTFontBoldTrait)
+    {
+        rDFA.meWeight = WEIGHT_BOLD;
+    }
+
+    if (value & kCTFontCondensedTrait)
+    {
+        rDFA.meWidthType = WIDTH_CONDENSED;
+    }
+    else if (value & kCTFontExpandedTrait)
+    {
+        rDFA.meWidthType = WIDTH_EXPANDED;
+    }
+    switch(value & kCTFontClassMaskTrait)
+    {
+    case kCTFontOldStyleSerifsClass:
+        rDFA.meFamily = FAMILY_ROMAN;
+        break;
+    case kCTFontTransitionalSerifsClass:
+    case kCTFontModernSerifsClass:
+    case kCTFontClarendonSerifsClass:
+    case kCTFontSlabSerifsClass:
+    case kCTFontFreeformSerifsClass:
+        break;
+    case kCTFontSansSerifClass:
+        rDFA.meFamily = FAMILY_SWISS;
+    case kCTFontOrnamentalsClass:
+        rDFA.meFamily = FAMILY_DECORATIVE;
+        break;
+    case kCTFontScriptsClass:
+        rDFA.meFamily = FAMILY_SCRIPT;
+        break;
+    case kCTFontSymbolicClass:
+        rDFA.mbSymbolFlag = true;
+        break;
+    }
+
+    CFNumberRef weight = (CFNumberRef)CFDictionaryGetValue(traits, kCTFontWeightTrait);
+    float fdval = 0.0;
+    CFNumberGetValue(weight, kCFNumberFloatType, &fdval);
+    if (fdval > 0.6)
+    {
+        rDFA.meWeight = WEIGHT_BLACK;
+    }
+    else if (fdval > 0.4)
+    {
+        rDFA.meWeight = WEIGHT_ULTRABOLD;
+    }
+    else if (fdval > 0.3)
+    {
+        rDFA.meWeight = WEIGHT_BOLD;
+    }
+    else if (fdval > 0.0)
+    {
+        rDFA.meWeight = WEIGHT_SEMIBOLD;
+    }
+    else if (fdval <= -0.8)
+    {
+        rDFA.meWeight = WEIGHT_ULTRALIGHT;
+    }
+    else if (fdval <= -0.4)
+    {
+        rDFA.meWeight = WEIGHT_LIGHT;
+    }
+    else if (fdval <= -0.3)
+    {
+        rDFA.meWeight = WEIGHT_SEMILIGHT;
+    }
+    else if (fdval <= -0.2)
+    {
+        rDFA.meWeight = WEIGHT_THIN;
+    }
+    else
+    {
+        rDFA.meWeight = WEIGHT_NORMAL;
+    }
+
+    CFStringRef string_ref = (CFStringRef)CTFontDescriptorCopyAttribute(font_descriptor, kCTFontStyleNameAttribute);
+    rtl::OUString font_name = GetOUString(string_ref);
+    rtl::OUString font_name_lc(font_name.toAsciiLowerCase());
+    CFRelease(string_ref);
+
+    // heuristics to adjust font slant
+    if ( (font_name_lc.indexOf("oblique") != -1) ||
+        (font_name_lc.indexOf("inclined") != -1) ||
+        (font_name_lc.indexOf("slanted") != -1) )
+    {
+        rDFA.meItalic = ITALIC_OBLIQUE;
+    }
+
+    // heuristics to adjust font width
+    if (font_name_lc.indexOf("narrow") != -1)
+    {
+        rDFA.meWidthType = WIDTH_SEMI_CONDENSED;
+    }
+
+    // heuristics for font family type
+    if ( (font_name_lc.indexOf("script") != -1) ||
+        (font_name_lc.indexOf("chancery") != -1) ||
+        (font_name_lc.indexOf("zapfino") != -1))
+    {
+        rDFA.meFamily = FAMILY_SCRIPT;
+    }
+    else if ( (font_name_lc.indexOf("comic") != -1) ||
+             (font_name_lc.indexOf("outline") != -1) ||
+             (font_name_lc.indexOf("pinpoint") != -1) )
+    {
+        rDFA.meFamily = FAMILY_DECORATIVE;
+    }
+    else if ( (font_name_lc.indexOf("sans") != -1) ||
+             (font_name_lc.indexOf("arial") != -1) )
+    {
+        rDFA.meFamily = FAMILY_SWISS;
+    }
+    else if ( (font_name_lc.indexOf("roman") != -1) ||
+             (font_name_lc.indexOf("times") != -1) )
+    {
+        rDFA.meFamily = FAMILY_ROMAN;
+    }
+    return true;
+}
 
 SystemFontList::SystemFontList()
 {
+	CTFontCollectionRef font_collection = CTFontCollectionCreateFromAvailableFonts(NULL);
+    if (font_collection)
+    {
+        CFArrayRef font_descriptors = CTFontCollectionCreateMatchingFontDescriptors(font_collection);
+
+        for(int i = 0; i < CFArrayGetCount(font_descriptors); i++)
+        {
+            CTFontDescriptorRef font_descriptor = (CTFontDescriptorRef)CFArrayGetValueAtIndex(font_descriptors, i);
+            CTFontRef font = CTFontCreateWithFontDescriptor(font_descriptor, 0, NULL);
+            ImplDevFontAttributes devfont_attr;
+            if (GetDevFontAttributes( font_descriptor, devfont_attr ) )
+            {
+                ImplCoreTextFontData* font_data = new ImplCoreTextFontData(devfont_attr, font);
+                if (font_data && font_data->GetCTFont())
+                {
+                    m_aFontContainer [ font_data->GetCTFont() ] = font_data;
+                }
+            }
+            CFRelease(font);
+        }
+        CFRelease(font_descriptors);
+    }
+    CFRelease(font_collection);
 }
 
 SystemFontList::~SystemFontList()
 {
+    CoreTextFontContainer::const_iterator it = m_aFontContainer.begin();
+    for(; it != m_aFontContainer.end(); ++it )
+        delete (*it).second;
+    m_aFontContainer.clear();
 }
 
+ImplCoreTextFontData* SystemFontList::GetFontDataFromRef( CTFontRef font ) const
+{
+    CoreTextFontContainer::const_iterator it = m_aFontContainer.find( font );
+    return it == m_aFontContainer.end() ? NULL : (*it).second;
+}
+
+
 void SystemFontList::AnnounceFonts( ImplDevFontList& rFontList ) const
 {
-    (void) rFontList;
+    CoreTextFontContainer::const_iterator it = m_aFontContainer.begin();
+    for(; it != m_aFontContainer.end(); ++it )
+    {
+        rFontList.Add( (*it).second->Clone() );
+    }
+}
 
-    // Implement...
+ImplCoreTextFontData::ImplCoreTextFontData( const ImplDevFontAttributes& rDFA, CTFontRef font )
+:   ImplFontData( rDFA, 0 )
+,   m_CTFontRef((CTFontRef)CFRetain(font))
+,   m_pCharMap( NULL )
+,   m_bHasOs2Table( false )
+,   m_bOs2TableRead( false )
+,   m_bCmapTableRead( false )
+,   m_bHasCJKSupport( false )
+,   m_bFontCapabilitiesRead( false )
+{
 }
 
-// not all fonts are suitable for glyph fallback => sort them
-struct GfbCompare{ bool operator()(const ImplIosFontData*, const ImplIosFontData*); };
+ImplCoreTextFontData::~ImplCoreTextFontData()
+{
+    if ( m_pCharMap )
+    {
+        m_pCharMap->DeReference();
+    }
+    if ( m_CTFontRef )
+    {
+        CFRelease(m_CTFontRef);
+    }
+}
+
+ImplFontData* ImplCoreTextFontData::Clone() const
+{
+    ImplCoreTextFontData* pClone = new ImplCoreTextFontData(*this);
+    if ( m_pCharMap )
+    {
+        m_pCharMap->AddReference();
+    }
+    if ( m_CTFontRef )
+    {
+        pClone->m_CTFontRef = (CTFontRef)CFRetain(m_CTFontRef);
+    }
+    return pClone;
+}
+
+ImplFontEntry* ImplCoreTextFontData::CreateFontInstance(FontSelectPattern& rFSD) const
+{
+    return new ImplFontEntry(rFSD);
+}
+
+const ImplFontCharMap* ImplCoreTextFontData::GetImplFontCharMap()
+{
+    // return the cached charmap
+    if ( m_pCharMap )
+    {
+        return m_pCharMap;
+    }
+    // set the default charmap
+    m_pCharMap = ImplFontCharMap::GetDefaultMap();
+    m_pCharMap->AddReference();
+
+    // get the CMAP byte size
+    CFDataRef rCmapTable = CTFontCopyTable( m_CTFontRef, kCTFontTableCmap, kCTFontTableOptionNoOptions);
+    if (!rCmapTable)
+    {
+        return m_pCharMap;
+    }
+    if (!m_bCmapTableRead)
+    {
+        m_bCmapTableRead = true;
+        DetermineCJKSupport_cmap(rCmapTable);
+    }
+    // parse the CMAP
+    CmapResult aCmapResult;
+    if (ParseCMAP( CFDataGetBytePtr(rCmapTable), CFDataGetLength(rCmapTable), aCmapResult ) )
+    {
+        m_pCharMap = new ImplFontCharMap( aCmapResult );
+        m_pCharMap->AddReference();
+    }
+    CFRelease(rCmapTable);
+    return m_pCharMap;
+}
+
+bool ImplCoreTextFontData::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities)
+{
+    // read this only once per font
+    if ( m_bFontCapabilitiesRead )
+    {
+        rFontCapabilities = m_aFontCapabilities;
+        return !rFontCapabilities.maUnicodeRange.empty() || !rFontCapabilities.maCodePageRange.empty();
+    }
+    m_bFontCapabilitiesRead = true;
+
+    // get the GSUB table raw data
+    CFDataRef rGSUBTable = CTFontCopyTable( m_CTFontRef, kCTFontTableGSUB, kCTFontTableOptionNoOptions);
+    if (rGSUBTable)
+    {
+
+        vcl::getTTScripts(m_aFontCapabilities.maGSUBScriptTags,
+                          CFDataGetBytePtr(rGSUBTable), CFDataGetLength(rGSUBTable));
+        CFRelease(rGSUBTable);
+    }
+    CFDataRef OS2_Table = CTFontCopyTable( m_CTFontRef, kCTFontTableOS2, kCTFontTableOptionNoOptions);
+    if (OS2_Table)
+    {
+        vcl::getTTCoverage(
+                m_aFontCapabilities.maUnicodeRange,
+                m_aFontCapabilities.maCodePageRange,
+                CFDataGetBytePtr(OS2_Table), CFDataGetLength(OS2_Table));
+        /* while we are at it let's solve HasCJK for the same price */
+        if (!m_bOs2TableRead )
+        {
+            m_bOs2TableRead = true;
+            m_bHasOs2Table = true;
+            DetermineCJKSupport_OS2(OS2_Table);
+        }
+        CFRelease(OS2_Table);
+    }
+    rFontCapabilities = m_aFontCapabilities;
+    return !rFontCapabilities.maUnicodeRange.empty() || !rFontCapabilities.maCodePageRange.empty();
+}
+
+struct font_table
+{
+    unsigned char* table;
+    unsigned char* dir_entry;
+    unsigned char* cursor;
+};
+
+void addTable(struct font_table* table, CTFontTableTag tag, CFDataRef data)
+{
+    if (data && CFDataGetLength(data) > 0)
+    {
+        *(uint32_t*)table->dir_entry = CFSwapInt32HostToBig(tag);
+        table->dir_entry += 4;
+        *(uint32_t*)table->dir_entry = 0; /* TODO: checksum */
+        table->dir_entry += 4;
+        *(uint32_t*)table->dir_entry = CFSwapInt32HostToBig((uint32_t)((uintptr_t)table->cursor - (uintptr_t)table));
+        table->dir_entry += 4;
+        *(uint32_t*)table->dir_entry = CFSwapInt32HostToBig(CFDataGetLength(data));
+        table->dir_entry += 4;
+
+        memcpy(table->cursor, CFDataGetBytePtr(data), CFDataGetLength(data));
+        table->cursor += CFDataGetLength(data);
+    }
+}
+
+bool ImplCoreTextFontData::GetRawFontData( std::vector<unsigned char>& rBuffer, bool* pJustCFF ) const
+{
+    bool rc;
+    int table_count = 0;
+
+    CFDataRef CFF_table = CTFontCopyTable( m_CTFontRef, kCTFontTableCFF, kCTFontTableOptionNoOptions);
+    if (pJustCFF)
+    {
+        if (CFF_table)
+        {
+            *pJustCFF = CFDataGetLength(CFF_table) ? true : false;
+        }
+        if (CFF_table)
+        {
+            CFRelease(CFF_table);
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    size_t total_len = 0;
+    CFDataRef head_table = CTFontCopyTable( m_CTFontRef, kCTFontTableHead, kCTFontTableOptionNoOptions);
+    CFDataRef maxp_table = CTFontCopyTable( m_CTFontRef, kCTFontTableMaxp, kCTFontTableOptionNoOptions);
+    CFDataRef cmap_table = CTFontCopyTable( m_CTFontRef, kCTFontTableHead, kCTFontTableOptionNoOptions);
+    CFDataRef name_table = CTFontCopyTable( m_CTFontRef, kCTFontTableName, kCTFontTableOptionNoOptions);
+    CFDataRef hhea_table = CTFontCopyTable( m_CTFontRef, kCTFontTableHhea, kCTFontTableOptionNoOptions);
+    CFDataRef hmtx_table = CTFontCopyTable( m_CTFontRef, kCTFontTableHmtx, kCTFontTableOptionNoOptions);
+    rc = false;
+    if (head_table && maxp_table && cmap_table && name_table && hhea_table && hmtx_table)
+    {
+        if (CFDataGetLength(head_table) &&
+           CFDataGetLength(maxp_table) &&
+           CFDataGetLength(name_table) &&
+           CFDataGetLength(hhea_table) &&
+           CFDataGetLength(hmtx_table))
+        {
+            table_count += 6;
+            total_len = CFDataGetLength(head_table) +
+                CFDataGetLength(maxp_table) +
+                CFDataGetLength(name_table) +
+                CFDataGetLength(hhea_table) +
+                CFDataGetLength(hmtx_table);
+            rc = true;
+        }
+    }
+
+    CFDataRef loca_table = NULL;
+    CFDataRef glyf_table = NULL;
+    CFDataRef prep_table = NULL;
+    CFDataRef cvt_table = NULL;
+    CFDataRef fpgm_table = NULL;
+    if (rc)
+    {
+        if (!CFF_table || CFDataGetLength(CFF_table) == 0)
+        {
+            loca_table = CTFontCopyTable( m_CTFontRef, kCTFontTableLoca, kCTFontTableOptionNoOptions);
+            glyf_table = CTFontCopyTable( m_CTFontRef, kCTFontTableGlyf, kCTFontTableOptionNoOptions);
+            if (!loca_table  || !glyf_table || !CFDataGetLength(loca_table) || !CFDataGetLength(glyf_table))
+            {
+                rc = false;
+            }
+            else
+            {
+                table_count += 2;
+                total_len += CFDataGetLength(loca_table) + CFDataGetLength(glyf_table);
+                prep_table = CTFontCopyTable( m_CTFontRef, kCTFontTablePrep, kCTFontTableOptionNoOptions);
+                cvt_table = CTFontCopyTable( m_CTFontRef, kCTFontTableCvt, kCTFontTableOptionNoOptions);
+                fpgm_table = CTFontCopyTable( m_CTFontRef, kCTFontTableFpgm, kCTFontTableOptionNoOptions);
+                if (prep_table || CFDataGetLength(prep_table) > 0)
+                {
+                    table_count += 1;
+                    total_len += CFDataGetLength(prep_table);
+                }
+                if (cvt_table || CFDataGetLength(cvt_table) > 0)
+                {
+                    table_count += 1;
+                    total_len += CFDataGetLength(cvt_table);
+                }
+                if (fpgm_table || CFDataGetLength(fpgm_table) > 0)
+                {
+                    table_count += 1;
+                    total_len += CFDataGetLength(fpgm_table);
+                }
+            }
+        }
+        else
+        {
+            table_count += 1;
+            total_len += CFDataGetLength(CFF_table);
+        }
+    }
+    if (rc)
+    {
+        total_len += 12 + 16 * table_count;
+        rBuffer.resize(total_len);
+        struct font_table table;
+        unsigned char* cursor = &rBuffer[0];
+        int nLog2 = 0;
+
+        while( (table_count >> nLog2) > 1 ) ++nLog2;
+
+        table.table = cursor;
+        *(uint16_t*)cursor = CFSwapInt16HostToBig(1);
+        cursor += 2;
+        *(uint16_t*)cursor = 0;
+        cursor += 2;
+        *(uint16_t*)cursor = CFSwapInt16HostToBig(table_count);
+        cursor += 2;
+        *(uint16_t*)cursor = CFSwapInt16HostToBig(nLog2 * 16);
+        cursor += 2;
+        *(uint16_t*)cursor = CFSwapInt16HostToBig(nLog2);
+        cursor += 2;
+        *(uint16_t*)cursor = CFSwapInt16HostToBig((table_count - nLog2) * 16); // rangeShift
+        cursor += 2;
+        table.dir_entry = cursor;
+        cursor += (16 * table_count);
+        table.cursor = cursor;
+        addTable(&table, kCTFontTableCmap, cmap_table);
+        addTable(&table, kCTFontTableCvt, cvt_table);
+        addTable(&table, kCTFontTableFpgm, fpgm_table);
+        addTable(&table, kCTFontTableCFF, CFF_table);
+        addTable(&table, kCTFontTableGlyf, glyf_table);
+        addTable(&table, kCTFontTableLoca, loca_table);
+        addTable(&table, kCTFontTableHead, head_table);
+        addTable(&table, kCTFontTableHhea, hhea_table);
+        addTable(&table, kCTFontTableHmtx, hmtx_table);
+        addTable(&table, kCTFontTableMaxp, maxp_table);
+        addTable(&table, kCTFontTableName, name_table);
+        addTable(&table, kCTFontTablePrep, prep_table);
+    }
+    SafeCFRelease(cmap_table);
+    SafeCFRelease(cvt_table);
+    SafeCFRelease(fpgm_table);
+    SafeCFRelease(CFF_table);
+    SafeCFRelease(glyf_table);
+    SafeCFRelease(loca_table);
+    SafeCFRelease(head_table);
+    SafeCFRelease(hhea_table);
+    SafeCFRelease(hmtx_table);
+    SafeCFRelease(maxp_table);
+    SafeCFRelease(name_table);
+    SafeCFRelease(prep_table);
+
+    return rc;
+}
 
-inline bool GfbCompare::operator()( const ImplIosFontData* pA, const ImplIosFontData* pB )
+void ImplCoreTextFontData::DetermineCJKSupport_OS2(CFDataRef rOS2Table)
 {
-    // use symbol fonts only as last resort
-    bool bPreferA = !pA->IsSymbolFont();
-    bool bPreferB = !pB->IsSymbolFont();
-    if( bPreferA != bPreferB )
-        return bPreferA;
-    // prefer scalable fonts
-    bPreferA = pA->IsScalable();
-    bPreferB = pB->IsScalable();
-    if( bPreferA != bPreferB )
-        return bPreferA;
-    // prefer non-slanted fonts
-    bPreferA = (pA->GetSlant() == ITALIC_NONE);
-    bPreferB = (pB->GetSlant() == ITALIC_NONE);
-    if( bPreferA != bPreferB )
-        return bPreferA;
-    // prefer normal weight fonts
-    bPreferA = (pA->GetWeight() == WEIGHT_NORMAL);
-    bPreferB = (pB->GetWeight() == WEIGHT_NORMAL);
-    if( bPreferA != bPreferB )
-        return bPreferA;
-    // prefer normal width fonts
-    bPreferA = (pA->GetWidthType() == WIDTH_NORMAL);
-    bPreferB = (pB->GetWidthType() == WIDTH_NORMAL);
-    if( bPreferA != bPreferB )
-        return bPreferA;
-    return false;
+    if (CFDataGetLength(rOS2Table) >= 48)
+    {
+        const unsigned short* pOS2buffer = (const unsigned short*)CFDataGetBytePtr(rOS2Table);
+        const unsigned short version = CFSwapInt16BigToHost(pOS2buffer[0]);
+        if ( version >= 1)
+        {
+            const unsigned short unicode_range = CFSwapInt16BigToHost(pOS2buffer[23]);
+            if ( unicode_range & 0x2DF0)
+            {
+                m_bHasCJKSupport = true;
+            }
+        }
+    }
 }
 
-void SystemFontList::InitGlyphFallbacks()
+void ImplCoreTextFontData::DetermineCJKSupport_cmap(CFDataRef rCmapTable)
 {
+    int table_len = CFDataGetLength(rCmapTable) / 2;
+    if (table_len >= 12)
+    {
+        const unsigned short* pCmap = (const unsigned short*)CFDataGetBytePtr(rCmapTable);
+        if (pCmap[0] == 0)
+        {
+            short nb_sub_tables = CFSwapInt16BigToHost(pCmap[1]);
+            for(int i = 2; --nb_sub_tables >= 0 && i < table_len; i += 4)
+            {
+                short platform = CFSwapInt16BigToHost(pCmap[i]);
+                if ( platform == kFontMacintoshPlatform )
+                {
+                    short encoding = CFSwapInt16BigToHost(pCmap[i+1]);
+                    if ( encoding == kFontJapaneseScript ||
+                        encoding == kFontTraditionalChineseScript ||
+                        encoding == kFontKoreanScript ||
+                        encoding == kFontSimpleChineseScript )
+                    {
+                        m_bHasCJKSupport = true;
+                        break;
+                    }
+                }
+            }
+        }
+    }
 }
 
-ImplIosFontData* SystemFontList::GetFontDataFromRef( CTFontRef nFontRef ) const
+bool ImplCoreTextFontData::HasCJKSupport( void )
 {
-    IosFontContainer::const_iterator it = maFontContainer.find( nFontRef );
-    if( it == maFontContainer.end() )
-        return NULL;
-    return (*it).second;
+    // read this only once per font
+    if (!m_bOs2TableRead )
+    {
+        m_bOs2TableRead = true;
+        CFDataRef rOS2Table = CTFontCopyTable( m_CTFontRef, kCTFontTableOS2, kCTFontTableOptionNoOptions);
+        if (rOS2Table)
+        {
+            m_bHasOs2Table = true;
+            DetermineCJKSupport_OS2(rOS2Table);
+            CFRelease(rOS2Table);
+        }
+    }
+    if ( !m_bCmapTableRead && !m_bHasOs2Table && !m_bHasCJKSupport )
+    {
+        m_bCmapTableRead = true;
+        CFDataRef rCmapTable = CTFontCopyTable( m_CTFontRef, kCTFontTableCmap, kCTFontTableOptionNoOptions);
+        if (rCmapTable)
+        {
+            DetermineCJKSupport_cmap(rCmapTable);
+            CFRelease(rCmapTable);
+        }
+    }
+    return m_bHasCJKSupport;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/ios/source/gdi/salcoretextlayout.cxx b/vcl/ios/source/gdi/salcoretextlayout.cxx
index 3ff4c07..4fd1baf 100644
--- a/vcl/ios/source/gdi/salcoretextlayout.cxx
+++ b/vcl/ios/source/gdi/salcoretextlayout.cxx
@@ -26,296 +26,456 @@
  *
 ************************************************************************/
 
-#include "tools/debug.hxx"
-
-#include "ios/saldata.hxx"
+#include "ios/common.h"
+#include "ios/salcoretextstyle.hxx"
+#include "ios/salcoretextlayout.hxx"
 #include "ios/salgdi.h"
-#include "ios/salcoretextfontutils.hxx"
-
-#include "sallayout.hxx"
-#include "salgdi.hxx"
 
-#include <math.h>
 
-class CoreTextLayout : public SalLayout
-{
-public:
-                    CoreTextLayout( CTFontSymbolicTraits&, float fFontScale );
-    virtual         ~CoreTextLayout();
-
-    virtual bool    LayoutText( ImplLayoutArgs& );
-    virtual void    AdjustLayout( ImplLayoutArgs& );
-    virtual void    DrawText( SalGraphics& ) const;
-
-    virtual int     GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos, int&,
-                        sal_Int32* pGlyphAdvances, int* pCharIndexes ) const;
-
-    virtual long    GetTextWidth() const;
-    virtual long    FillDXArray( long* pDXArray ) const;
-    virtual int     GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const;
-    virtual void    GetCaretPositions( int nArraySize, long* pCaretXArray ) const;
-    virtual bool    GetGlyphOutlines( SalGraphics&, PolyPolyVector& ) const;
-    virtual bool    GetBoundRect( SalGraphics&, Rectangle& ) const;
-
-    const ImplFontData* GetFallbackFontData( sal_GlyphId ) const;
-
-    virtual void    InitFont() const;
-    virtual void    MoveGlyph( int nStart, long nNewXPos );
-    virtual void    DropGlyph( int nStart );
-    virtual void    Simplify( bool bIsBase );
-
-private:
-    // ???
-    float               mfFontScale;
-
-private:
-    bool    InitGIA( ImplLayoutArgs* pArgs = NULL ) const;
-    bool    GetIdealX() const;
-    bool    GetDeltaY() const;
-    void    InvalidateMeasurements();
-
-    // cached details about the resulting layout
-    // mutable members since these details are all lazy initialized
-    mutable int         mnGlyphCount;           // glyph count
-    mutable Fixed       mnCachedWidth;          // cached value of resulting typographical width
-    int                 mnTrailingSpaceWidth;   // in Pixels
-
-    mutable CGGlyph*        mpGlyphIds;
-    mutable Fixed*          mpCharWidths;       // map relative charpos to charwidth
-    mutable int*            mpChars2Glyphs;     // map relative charpos to absolute glyphpos
-    mutable int*            mpGlyphs2Chars;     // map absolute glyphpos to absolute charpos
-    mutable bool*           mpGlyphRTLFlags;    // BiDi status for glyphs: true if RTL
-    mutable Fixed*          mpGlyphAdvances;    // contains glyph widths for the justified layout
-    mutable Fixed*          mpGlyphOrigAdvs;    // contains glyph widths for the unjustified layout
-    mutable Fixed*          mpDeltaY;           // vertical offset from the baseline
-
-    struct SubPortion { int mnMinCharPos, mnEndCharPos; Fixed mnXOffset; };
-    typedef std::vector<SubPortion> SubPortionVector;
-    mutable SubPortionVector    maSubPortions;
-
-    // storing details about fonts used in glyph-fallback for this layout
-    mutable class FallbackInfo* mpFallbackInfo;
-
-    // x-offset relative to layout origin
-    // currently only used in RTL-layouts
-    mutable Fixed           mnBaseAdv;
-};
-
-class FallbackInfo
-{
-public:
-    FallbackInfo() : mnMaxLevel(0) {}
-    int AddFallback( CTFontRef );
-    const ImplFontData* GetFallbackFontData( int nLevel ) const;
-
-private:
-    const ImplIosFontData* maFontData[ MAX_FALLBACK ];
-    CTFontRef              maCTFontRef[ MAX_FALLBACK ];
-    int                    mnMaxLevel;
-};
-
-CoreTextLayout::CoreTextLayout( CTFontSymbolicTraits& rCoreTextStyle, float fFontScale )
-:
-    mfFontScale( fFontScale ),
-    mnGlyphCount( -1 ),
-    mnCachedWidth( 0 ),
-    mnTrailingSpaceWidth( 0 ),
-    mpGlyphIds( NULL ),
-    mpCharWidths( NULL ),
-    mpChars2Glyphs( NULL ),
-    mpGlyphs2Chars( NULL ),
-    mpGlyphRTLFlags( NULL ),
-    mpGlyphAdvances( NULL ),
-    mpGlyphOrigAdvs( NULL ),
-    mpDeltaY( NULL ),
-    mpFallbackInfo( NULL ),
-    mnBaseAdv( 0 )
+CoreTextLayout::CoreTextLayout(IosSalGraphics* graphics, CoreTextStyleInfo* style) :
+    m_graphics(graphics),
+    m_style(style),
+    m_glyphs_count(-1),
+    m_chars_count(-1),
+    m_chars2glyphs(NULL),
+    m_glyphs2chars(NULL),
+    m_glyphs(NULL),
+    m_char_widths(NULL),
+    m_glyph_advances(NULL),
+    m_glyph_positions(NULL),
+    m_typesetter(NULL),
+    m_line(NULL),
+    m_has_bound_rec(false),
+    m_base_advance(0),
+    m_cached_width(0.0F),
+    m_current_run_index(0),
+    m_current_glyph_index(0),
+    m_current_glyphrun_index(0),
+    m_runs(NULL)
 {
-    (void) rCoreTextStyle;
 }
 
-// -----------------------------------------------------------------------
-
 CoreTextLayout::~CoreTextLayout()
 {
-    delete[] mpGlyphRTLFlags;
-    delete[] mpGlyphs2Chars;
-    delete[] mpChars2Glyphs;
-    if( mpCharWidths != mpGlyphAdvances )
-        delete[] mpCharWidths;
-    delete[] mpGlyphIds;
-    delete[] mpGlyphOrigAdvs;
-    delete[] mpGlyphAdvances;
-
-    delete mpFallbackInfo;
+    Clean();
 }
 
-bool CoreTextLayout::LayoutText( ImplLayoutArgs& rArgs )
+void CoreTextLayout::AdjustLayout( ImplLayoutArgs& /*rArgs*/ )
 {
-    (void) rArgs;
-    // Implement...
-    return true;
+    msgs_debug(layout,"-->");
+    msgs_debug(layout,"<--");
+    /* TODO */
 }
 
-void CoreTextLayout::AdjustLayout( ImplLayoutArgs& rArgs )
+void CoreTextLayout::Clean()
 {
-    (void) rArgs;
-    // Implement...
+    msgs_debug(layout,"-->");
+    if (m_glyphs)
+    {
+        delete[] m_glyphs;
+        m_glyphs = NULL;
+    }
+    if (m_chars2glyphs)
+    {
+        delete[] m_chars2glyphs;
+        m_chars2glyphs = NULL;
+    }
+    if (m_glyphs2chars)
+    {
+        delete[] m_glyphs2chars;
+        m_glyphs2chars = NULL;
+    }
+    if (m_char_widths)
+    {
+        delete[] m_char_widths;
+        m_char_widths = NULL;
+    }
+    if (m_glyph_advances)
+    {
+        delete[] m_glyph_advances;
+        m_glyph_advances = NULL;
+    }
+    if (m_glyph_positions)
+    {
+        delete[] m_glyph_positions;
+        m_glyph_positions = NULL;
+    }
+    SafeCFRelease(m_typesetter);
+    SafeCFRelease(m_line);
+    m_has_bound_rec = false;
+    msgs_debug(layout,"<--");
 }
 
 void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const
 {
-    (void) rGraphics;
-    // Implement...
-}
-
-int CoreTextLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& nStart,
-    sal_Int32* pGlyphAdvances, int* pCharIndexes ) const
-{
-    (void) nLen;
-    (void) pGlyphIDs;
-    (void) rPos;
-    (void) nStart;
-    (void) pGlyphAdvances;
-    (void) pCharIndexes;
-
-    if( nStart < 0 )                // first glyph requested?
-        nStart = 0;
+    msgs_debug(layout,"-->");
+    IosSalGraphics& gr = static_cast<IosSalGraphics&>(rGraphics);
+    if (m_chars_count <= 0 || !gr.CheckContext())
+    {
+        return;
+    }
+    CGContextSaveGState( gr.mrContext );
+    Point pos = GetDrawPosition(Point(0,0));
+#if 0
+    msgs_debug(layout,"at pos (%ld, %ld)", pos.X(), pos.Y());
+    CGContextSetTextMatrix(gr.mrContext, CGAffineTransformMakeScale(1.0, -1.0));
+    CGContextSetShouldAntialias( gr.mrContext, !gr.mbNonAntialiasedText );
+    CGContextSetTextPosition(gr.mrContext, pos.X(), pos.Y());
+    CTLineDraw(m_line, gr.mrContext);
+#else
+    InitGIA();
+    msgs_debug(layout,"at- pos (%ld, %ld)", pos.X(), pos.Y());
+    CGFontRef cg_font = CTFontCopyGraphicsFont(m_style->GetFont(), NULL);
+    CGContextSetFont(gr.mrContext, cg_font);
+    CGContextSetFontSize(gr.mrContext, CTFontGetSize(m_style->GetFont()));
+    CGContextSetTextDrawingMode(gr.mrContext, kCGTextFill);
+    CGContextSetShouldAntialias( gr.mrContext, true );
+    if (m_style->GetColor())
+    {
+        CGContextSetFillColorWithColor(gr.mrContext, m_style->GetColor());
+        CGContextSetStrokeColorWithColor(gr.mrContext, m_style->GetColor());
+    }
+    else
+    {
+        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);
+//    }
+#endif
+    // restore the original graphic context transformations
+    CGContextRestoreGState( gr.mrContext );
+    msgs_debug(layout,"<--");
 
-    // Implement...
-
-    return 0;
 }
 
-long CoreTextLayout::GetTextWidth() const
-{
-    // Implement...
-
-    return 0;
-}
+// not needed. CoreText manage fallback directly
+void CoreTextLayout::DropGlyph( int /*nStart*/ ) {}
 
 long CoreTextLayout::FillDXArray( long* pDXArray ) const
 {
+    msgs_debug(layout,"-->");
     // short circuit requests which don't need full details
-    if( !pDXArray )
+    if ( !pDXArray )
+    {
         return GetTextWidth();
-
-    // Implement...
-
-    return 0;
+    }
+    // check assumptions
+    DBG_ASSERT( !mnTrailingSpaceWidth, "CoreText::FillDXArray() with nTSW!=0" );
+
+    // initialize details about the resulting layout
+    InitGIA();
+
+    // distribute the widths among the string elements
+    long width = 0;
+    float scale = m_style->GetFontStretchFactor();
+    m_cached_width = 0;
+
+    for( int i = 0; i < m_chars_count; ++i )
+    {
+        // convert and adjust for accumulated rounding errors
+        m_cached_width += m_char_widths[i];
+        const long old_width = width;
+        width = round_to_long(m_cached_width * scale);
+        pDXArray[i] = width - old_width;
+    }
+    msgs_debug(layout," w=%ld <--", width);
+    return width;
 }
 
-int CoreTextLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const
+bool CoreTextLayout::GetBoundRect( SalGraphics &rGraphics, Rectangle& rVCLRect ) const
 {
-    (void) nMaxWidth;
-    (void) nCharExtra;
-    (void) nFactor;
-    // Implement...
-    return 0;
-}
-
-void CoreTextLayout::GetCaretPositions( int nMaxIndex, long* pCaretXArray ) const
-{
-    (void) nMaxIndex;
-    (void) pCaretXArray;
-    // Implement...
-}
-
-bool CoreTextLayout::GetBoundRect( SalGraphics&, Rectangle& rVCLRect ) const
-{
-    (void) rVCLRect;
-    // Implement;
+    msgs_debug(layout,"-->");
+    IosSalGraphics& gr = static_cast<IosSalGraphics&>(rGraphics);
+    if ( !m_has_bound_rec )
+    {
+        CGRect bound_rect = CTLineGetImageBounds( m_line, gr.mrContext );
+        if ( !CGRectIsNull( bound_rect ) )
+        {
+            m_bound_rect = Rectangle(
+                Point( round_to_long(bound_rect.origin.x * m_style->GetFontStretchFactor()),
+                       round_to_long(bound_rect.origin.y - bound_rect.size.height )),
+                Size( round_to_long(bound_rect.size.width * m_style->GetFontStretchFactor()), round_to_long(bound_rect.size.height)));
+            m_bound_rect.Justify();
+        }
+        m_has_bound_rec = true;
+    }
+    rVCLRect = m_bound_rect;
+    msgs_debug(layout,"<--");
     return true;
 }
 
-bool CoreTextLayout::InitGIA( ImplLayoutArgs* pArgs ) const
+void CoreTextLayout::GetCaretPositions( int max_index, long* caret_position) const
 {
-    (void) pArgs;
-    // no need to run InitGIA more than once on the same CoreTextLayout object
-    if( mnGlyphCount >= 0 )
-        return true;
-    mnGlyphCount = 0;
-
-    // Implement...
-
-    return true;
+    msgs_debug(layout,"max_index %d -->", max_index);
+    int local_max = max_index < m_chars_count * 2 ? max_index : m_chars_count;
+    for(int i = 0 ; i < max_index - 1; i+=2)

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list