[Libreoffice-commits] core.git: vcl/coretext vcl/headless vcl/inc
Tor Lillqvist
tml at iki.fi
Tue Jun 4 05:24:27 PDT 2013
vcl/coretext/ctfonts.cxx | 9
vcl/coretext/ctfonts.hxx | 7
vcl/coretext/ctlayout.cxx | 4
vcl/coretext/salcoretextfontutils.cxx | 627 ---------------------------
vcl/coretext/salcoretextlayout.cxx | 684 ------------------------------
vcl/coretext/salcoretextstyle.cxx | 129 -----
vcl/coretext/salgdi.cxx | 341 --------------
vcl/coretext/salgdi2.cxx | 81 +++
vcl/headless/svpgdi.cxx | 24 -
vcl/inc/coretext/salcoretextfontutils.hxx | 82 ---
vcl/inc/coretext/salcoretextstyle.hxx | 60 --
vcl/inc/coretext/salgdi.h | 333 --------------
vcl/inc/coretext/salgdi2.h | 13
vcl/inc/headless/svpframe.hxx | 4
vcl/inc/headless/svpgdi.hxx | 26 -
vcl/inc/headless/svpvd.hxx | 4
vcl/inc/saldatabasic.hxx | 2
17 files changed, 139 insertions(+), 2291 deletions(-)
New commits:
commit ac7d6300c6cf73da473273cfd4d1f6b6fb9eb6a1
Author: Tor Lillqvist <tml at iki.fi>
Date: Tue Jun 4 15:12:06 2013 +0300
Make the iOS vcl CoreText code build again
Some refactoring was needed after the Coretext rework yesterday.
It does crash at run-time, though.
Also, remove the no longer used source files from our older CoreText
attempt.
Change-Id: I54d221ade846866d7a9457acd50219c74c68e8cf
diff --git a/vcl/coretext/ctfonts.cxx b/vcl/coretext/ctfonts.cxx
index 1bd74f6..c7dd57b 100644
--- a/vcl/coretext/ctfonts.cxx
+++ b/vcl/coretext/ctfonts.cxx
@@ -23,8 +23,10 @@
#include "outfont.hxx"
#include "sallayout.hxx"
+#ifdef MACOSX
#include "aqua/salinst.h"
#include "aqua/saldata.hxx"
+#endif
#include "coretext/salgdi2.h"
#include "quartz/utils.h"
#include "ctfonts.hxx"
@@ -307,7 +309,12 @@ int CTFontData::GetFontTable( const char pTagName[5], unsigned char* pResultBuf
// get the raw table length
CTFontDescriptorRef pFontDesc = reinterpret_cast<CTFontDescriptorRef>( GetFontId());
CTFontRef rCTFont = CTFontCreateWithFontDescriptor( pFontDesc, 0.0, NULL);
- CFDataRef pDataRef = CTFontCopyTable( rCTFont, nTagCode, kCTFontTableOptionExcludeSynthetic);
+#ifdef MACOSX
+ const uint32_t opts( kCTFontTableOptionExcludeSynthetic );
+#else
+ const uint32_t opts( kCTFontTableOptionNoOptions );
+#endif
+ CFDataRef pDataRef = CTFontCopyTable( rCTFont, nTagCode, opts);
CFRelease( rCTFont);
if( !pDataRef)
return 0;
diff --git a/vcl/coretext/ctfonts.hxx b/vcl/coretext/ctfonts.hxx
index d9c4e7d..1430c36 100644
--- a/vcl/coretext/ctfonts.hxx
+++ b/vcl/coretext/ctfonts.hxx
@@ -18,12 +18,11 @@
*/
#include "coretext/salgdi2.h"
+#ifdef IOS
+#include "headless/svpgdi.hxx"
+#endif
#include "sallayout.hxx"
-#include <ApplicationServices/ApplicationServices.h>
-
-// =======================================================================
-
class CTTextStyle
: public ImplMacTextStyle
{
diff --git a/vcl/coretext/ctlayout.cxx b/vcl/coretext/ctlayout.cxx
index 03ec1bb..64728fc 100644
--- a/vcl/coretext/ctlayout.cxx
+++ b/vcl/coretext/ctlayout.cxx
@@ -208,7 +208,7 @@ void CTLayout::DrawText( SalGraphics& rGraphics ) const
CGContextSetTextPosition( rAquaGraphics.mrContext, aTextPos.x, aTextPos.y );
CTLineDraw( mpCTLine, rAquaGraphics.mrContext );
-
+#ifndef IOS
// request an update of the changed window area
if( rAquaGraphics.IsWindowGraphics() )
{
@@ -216,7 +216,7 @@ void CTLayout::DrawText( SalGraphics& rGraphics ) const
const CGRect aRefreshRect = CGContextConvertRectToDeviceSpace( rAquaGraphics.mrContext, aInkRect );
rAquaGraphics.RefreshRect( aRefreshRect );
}
-
+#endif
// restore the original graphic context transformations
CGContextRestoreGState( rAquaGraphics.mrContext );
}
diff --git a/vcl/coretext/salcoretextfontutils.cxx b/vcl/coretext/salcoretextfontutils.cxx
deleted file mode 100644
index 8e90557..0000000
--- a/vcl/coretext/salcoretextfontutils.cxx
+++ /dev/null
@@ -1,627 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "coretext/common.h"
-#include "coretext/salcoretextfontutils.hxx"
-#include "quartz/utils.h"
-
-#include "sft.hxx"
-
-#ifdef MACOSX
-#include "coretext/salgdi.h"
-#include "aqua/salinst.h"
-#else // IOS
-#include "headless/svpinst.hxx"
-#endif
-
-static bool GetDevFontAttributes( CTFontDescriptorRef font_descriptor, ImplDevFontAttributes& rDFA )
-{
- int value = 0;
-
- // reset the attributes
- rDFA.SetFamilyType( FAMILY_DONTKNOW );
- rDFA.SetPitch( PITCH_VARIABLE );
- rDFA.SetWidthType( WIDTH_NORMAL );
- rDFA.SetWeight( WEIGHT_NORMAL );
- rDFA.SetItalic( ITALIC_NONE );
- rDFA.SetSymbolFlag( false );
- rDFA.mbOrientation = true;
- rDFA.mbDevice = true;
- rDFA.mnQuality = 0;
-
- CFNumberRef format = (CFNumberRef)CTFontDescriptorCopyAttribute(font_descriptor, kCTFontFormatAttribute);
- 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.SetFamilyName( GetOUString(family_name) );
- CFRelease(family_name);
-
- CFDictionaryRef traits = (CFDictionaryRef)CTFontDescriptorCopyAttribute(font_descriptor, kCTFontTraitsAttribute);
- CFNumberRef symbolics = (CFNumberRef)CFDictionaryGetValue(traits, kCTFontSymbolicTrait);
- CFNumberGetValue(symbolics, kCFNumberIntType, &value);
-
- if(value & kCTFontMonoSpaceTrait)
- {
- rDFA.SetPitch( PITCH_FIXED );
- }
-
- if(value & kCTFontItalicTrait)
- {
- rDFA.SetItalic( ITALIC_NORMAL );
- }
-
- if(value & kCTFontBoldTrait)
- {
- rDFA.SetWeight( WEIGHT_BOLD );
- }
-
- if(value & kCTFontCondensedTrait)
- {
- rDFA.SetWidthType( WIDTH_CONDENSED );
- }
- else if(value & kCTFontExpandedTrait)
- {
- rDFA.SetWidthType( WIDTH_EXPANDED );
- }
- switch(value & kCTFontClassMaskTrait)
- {
- case kCTFontOldStyleSerifsClass:
- rDFA.SetFamilyType( FAMILY_ROMAN );
- break;
- case kCTFontTransitionalSerifsClass:
- case kCTFontModernSerifsClass:
- case kCTFontClarendonSerifsClass:
- case kCTFontSlabSerifsClass:
- case kCTFontFreeformSerifsClass:
- break;
- case kCTFontSansSerifClass:
- rDFA.SetFamilyType( FAMILY_SWISS );
- break;
- case kCTFontOrnamentalsClass:
- rDFA.SetFamilyType( FAMILY_DECORATIVE );
- break;
- case kCTFontScriptsClass:
- rDFA.SetFamilyType( FAMILY_SCRIPT );
- break;
- case kCTFontSymbolicClass:
- rDFA.SetSymbolFlag( true );
- break;
- }
-
- CFNumberRef weight = (CFNumberRef)CFDictionaryGetValue(traits, kCTFontWeightTrait);
- float fdval = 0.0;
- CFNumberGetValue(weight, kCFNumberFloatType, &fdval);
- if(fdval > 0.6)
- {
- rDFA.SetWeight( WEIGHT_BLACK );
- }
- else if(fdval > 0.4)
- {
- rDFA.SetWeight( WEIGHT_ULTRABOLD );
- }
- else if (fdval > 0.3)
- {
- rDFA.SetWeight( WEIGHT_BOLD );
- }
- else if (fdval > 0.0)
- {
- rDFA.SetWeight( WEIGHT_SEMIBOLD );
- }
- else if (fdval <= -0.8)
- {
- rDFA.SetWeight( WEIGHT_ULTRALIGHT );
- }
- else if (fdval <= -0.4)
- {
- rDFA.SetWeight( WEIGHT_LIGHT );
- }
- else if (fdval <= -0.3)
- {
- rDFA.SetWeight( WEIGHT_SEMILIGHT );
- }
- else if (fdval <= -0.2)
- {
- rDFA.SetWeight( WEIGHT_THIN );
- }
- else
- {
- rDFA.SetWeight( WEIGHT_NORMAL );
- }
-
- CFStringRef string_ref = (CFStringRef)CTFontDescriptorCopyAttribute(font_descriptor, kCTFontStyleNameAttribute);
- OUString style(GetOUString(string_ref).toAsciiLowerCase());
- CFRelease(string_ref);
-
- // heuristics to adjust font slant
- if( (style.indexOf("oblique") != -1) ||
- (style.indexOf("inclined") != -1) ||
- (style.indexOf("slanted") != -1) )
- {
- rDFA.SetItalic( ITALIC_OBLIQUE );
- }
-
- // heuristics to adjust font width
- if (style.indexOf("narrow") != -1)
- {
- rDFA.SetWidthType( WIDTH_SEMI_CONDENSED );
- }
-
- // heuristics for font family type
- if( (style.indexOf("script") != -1) ||
- (style.indexOf("chancery") != -1) )
- {
- rDFA.SetFamilyType( FAMILY_SCRIPT );
- }
- else if( (style.indexOf("comic") != -1) ||
- (style.indexOf("outline") != -1) ||
- (style.indexOf("pinpoint") != -1) )
- {
- rDFA.SetFamilyType( FAMILY_DECORATIVE );
- }
- else if( (style.indexOf("sans") != -1) )
- {
- rDFA.SetFamilyType( FAMILY_SWISS );
- }
- else if( (style.indexOf("roman") != -1) )
- {
- rDFA.SetFamilyType( FAMILY_ROMAN );
- }
- return true;
-}
-
-SystemFontList::SystemFontList()
-{
- CTFontCollectionRef font_collection = CTFontCollectionCreateFromAvailableFonts(NULL);
- if(font_collection)
- {
- CFArrayRef font_descriptors = CTFontCollectionCreateMatchingFontDescriptors(font_collection);
-
- if(font_descriptors)
- {
- for(int i = 0; i < CFArrayGetCount(font_descriptors); i++)
- {
- CTFontDescriptorRef font_descriptor = (CTFontDescriptorRef)CFArrayGetValueAtIndex(font_descriptors, i);
- CTFontRef font = CTFontCreateWithFontDescriptor(font_descriptor, 0, NULL);
- if(font)
- {
- ImplDevFontAttributes devfont_attr;
- if(GetDevFontAttributes( font_descriptor, devfont_attr ) )
- {
- CoreTextPhysicalFontFace* font_face = new CoreTextPhysicalFontFace(devfont_attr, font);
- if(font_face && font_face->GetCTFont())
- {
- m_aFontContainer [ font_face->GetCTFont() ] = font_face;
- }
- }
- CFRelease(font);
- }
- }
- CFRelease(font_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();
-}
-
-CoreTextPhysicalFontFace* 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
-{
- CoreTextFontContainer::const_iterator it = m_aFontContainer.begin();
- for(; it != m_aFontContainer.end(); ++it )
- {
- rFontList.Add( (*it).second->Clone() );
- }
-}
-
-CoreTextPhysicalFontFace::CoreTextPhysicalFontFace( const ImplDevFontAttributes& rDFA, CTFontRef font )
-: PhysicalFontFace( 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 )
-{
-}
-
-CoreTextPhysicalFontFace::~CoreTextPhysicalFontFace()
-{
- if( m_pCharMap )
- {
- m_pCharMap->DeReference();
- }
- SafeCFRelease(m_CTFontRef);
-}
-
-PhysicalFontFace* CoreTextPhysicalFontFace::Clone() const
-{
- CoreTextPhysicalFontFace* pClone = new CoreTextPhysicalFontFace(*this);
- if( m_pCharMap )
- {
- m_pCharMap->AddReference();
- }
- if( m_CTFontRef )
- {
- pClone->m_CTFontRef = (CTFontRef)CFRetain(m_CTFontRef);
- }
- return pClone;
-}
-
-ImplFontEntry* CoreTextPhysicalFontFace::CreateFontInstance(FontSelectPattern& rFSD) const
-{
- return new ImplFontEntry(rFSD);
-}
-
-const ImplFontCharMap* CoreTextPhysicalFontFace::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 CoreTextPhysicalFontFace::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 CoreTextPhysicalFontFace::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;
- 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;
-}
-
-void CoreTextPhysicalFontFace::DetermineCJKSupport_OS2(CFDataRef rOS2Table)
-{
- 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 CoreTextPhysicalFontFace::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;
- }
- }
- }
- }
- }
-}
-
-bool CoreTextPhysicalFontFace::HasCJKSupport( void )
-{
- // 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;
-}
-
-std::ostream &operator <<(std::ostream& s, CTFontRef pFont)
-{
-#ifndef SAL_LOG_INFO
- (void) pFont;
-#else
- if (pFont) {
- CFStringRef fontString = CTFontCopyFullName(pFont);
- s << "{" << GetOUString(fontString) << "@" << CTFontGetSize(pFont) << "}";
- CFRelease(fontString);
- } else {
- s << "NULL";
- }
-#endif
- return s;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/coretext/salcoretextlayout.cxx b/vcl/coretext/salcoretextlayout.cxx
deleted file mode 100644
index d2c2d48..0000000
--- a/vcl/coretext/salcoretextlayout.cxx
+++ /dev/null
@@ -1,684 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <iostream>
-#include <iomanip>
-
-#include "quartz/utils.h"
-#include "coretext/common.h"
-#include "coretext/salcoretextstyle.hxx"
-
-#ifdef MACOSX
-#include "coretext/salgdi.h"
-#else
-#include "headless/svpgdi.hxx"
-#endif
-
-class CoreTextLayout SAL_FINAL : public SalLayout
-{
-public:
- CoreTextLayout( CoreTextStyleInfo* style );
- ~CoreTextLayout();
-
- // Overrides in same order as in base class, without "virtual" and
- // with explicit SAL_OVERRIDE. Just a question of taste;)
- bool LayoutText( ImplLayoutArgs& ) SAL_OVERRIDE;
- void AdjustLayout( ImplLayoutArgs& ) SAL_OVERRIDE;
- void DrawText( SalGraphics& ) const SAL_OVERRIDE;
-
- int GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const SAL_OVERRIDE;
- long FillDXArray( sal_Int32* pDXArray ) const SAL_OVERRIDE;
- long GetTextWidth() const SAL_OVERRIDE;
- void GetCaretPositions( int nArraySize, sal_Int32* pCaretXArray ) const SAL_OVERRIDE;
-
- int GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos, int&,
- sal_Int32* pGlyphAdvances, int* pCharIndexes ) const SAL_OVERRIDE;
- bool GetBoundRect( SalGraphics&, Rectangle& ) const SAL_OVERRIDE;
-
- void MoveGlyph( int nStart, long nNewXPos ) SAL_OVERRIDE;
- void DropGlyph( int nStart ) SAL_OVERRIDE;
- void Simplify( bool bIsBase ) SAL_OVERRIDE;
-
-private:
- void GetMeasurements();
- void InvalidateMeasurements();
- void ApplyDXArray( ImplLayoutArgs& );
- void Justify( long );
-
-#ifndef NDEBUG
- int mnSavedMinCharPos;
- int mnSavedEndCharPos;
- sal_Unicode *mpSavedStr;
-#endif
-
- CoreTextStyleInfo* mpStyle;
-
- int mnCharCount; // ==mnEndCharPos-mnMinCharPos
-
- // cached details about the resulting layout
- // mutable members since these details are all lazy initialized
- mutable int mnGlyphCount;
-
- mutable CGGlyph* mpGlyphs;
- mutable CGFloat* mpCharWidths;
- mutable int* mpGlyphs2Chars;
-
- mutable CGSize* mpGlyphAdvances;
-
- mutable CTTypesetterRef mpTypesetter;
- mutable CTLineRef mpLine;
- mutable bool mbHasBoundRectangle;
- mutable Rectangle maBoundRectangle;
-
- // x-offset relative to layout origin
- // currently only used in RTL-layouts
- CGFloat mnBaseAdvance;
-
- mutable CFIndex mnCurrentRunIndex;
- mutable CFIndex mnCurrentGlyphIndex;
- mutable CFIndex mnCurrentGlyphRunIndex;
- mutable CFArrayRef mpRuns;
-};
-
-CoreTextLayout::CoreTextLayout(CoreTextStyleInfo* style) :
-#ifndef NDEBUG
- mpSavedStr(NULL),
-#endif
- mpStyle(style),
- mnCharCount(-1),
- mnGlyphCount(-1),
- mpGlyphs(NULL),
- mpCharWidths(NULL),
- mpGlyphs2Chars(NULL),
- mpGlyphAdvances(NULL),
- mpTypesetter(NULL),
- mpLine(NULL),
- mbHasBoundRectangle(false),
- mnBaseAdvance(0),
- mnCurrentRunIndex(0),
- mnCurrentGlyphIndex(0),
- mnCurrentGlyphRunIndex(0),
- mpRuns(NULL)
-{
- SAL_INFO( "vcl.coretext.layout", "CoreTextLayout::CoreTextLayout() " << this << ", style=" << *style);
-}
-
-CoreTextLayout::~CoreTextLayout()
-{
- InvalidateMeasurements();
- SafeCFRelease(mpTypesetter);
- SafeCFRelease(mpLine);
-#ifndef NDEBUG
- delete[] mpSavedStr;
-#endif
- SAL_INFO( "vcl.coretext.layout", "~CoreTextLayout(" << this << ")" );
-}
-
-void CoreTextLayout::AdjustLayout( ImplLayoutArgs& rArgs )
-{
- SAL_INFO( "vcl.coretext.layout", "AdjustLayout(" << this << ",rArgs=" << rArgs << ")" );
-
-#ifndef NDEBUG
- assert( mnSavedMinCharPos == rArgs.mnMinCharPos );
- assert( mnSavedEndCharPos == rArgs.mnEndCharPos );
- assert( mnCharCount == (mnSavedEndCharPos - mnSavedMinCharPos) );
- assert( memcmp( &mpSavedStr[0],
- &rArgs.mpStr[mnSavedMinCharPos],
- mnCharCount * sizeof( sal_Unicode ) ) == 0 );
-#endif
-
- SalLayout::AdjustLayout( rArgs );
-
- // adjust positions if requested
- if( rArgs.mpDXArray )
- ApplyDXArray( rArgs );
- else if( rArgs.mnLayoutWidth )
- Justify( rArgs.mnLayoutWidth );
- else
- return;
-}
-
-void CoreTextLayout::ApplyDXArray( ImplLayoutArgs& rArgs )
-{
- Justify( rArgs.mpDXArray[mnCharCount-1] );
-}
-
-void CoreTextLayout::Justify( long nNewWidth )
-{
- CTLineRef justifiedLine = CTLineCreateJustifiedLine( mpLine, 1.0, nNewWidth - CTLineGetTrailingWhitespaceWidth( mpLine ) );
- if ( !justifiedLine ) {
- SAL_INFO( "vcl.coretext.layout", "Justify(): CTLineCreateJustifiedLine() failed" );
- } else {
- CFRelease( mpLine );
- mpLine = justifiedLine;
- // Justification can change the number of glyphs!
- int oldGLyphCount = mnGlyphCount;
- mnGlyphCount = CTLineGetGlyphCount( mpLine );
- if ( mnGlyphCount != oldGLyphCount )
- SAL_INFO( "vcl.coretext.layout", " glyph count changed, mnGlyphCount=" << mnGlyphCount );
- GetMeasurements();
- }
-}
-
-void CoreTextLayout::InvalidateMeasurements()
-{
- if( mpGlyphs ) {
- delete[] mpGlyphs;
- mpGlyphs = NULL;
- }
- if( mpGlyphs2Chars ) {
- delete[] mpGlyphs2Chars;
- mpGlyphs2Chars = NULL;
- }
- if( mpCharWidths ) {
- delete[] mpCharWidths;
- mpCharWidths = NULL;
- }
- if( mpGlyphAdvances ) {
- delete[] mpGlyphAdvances;
- mpGlyphAdvances = NULL;
- }
- mbHasBoundRectangle = false;
-}
-
-void CoreTextLayout::DrawText( SalGraphics& rGraphics ) const
-{
- SAL_INFO( "vcl.coretext.layout", "DrawText(" << this << ")" );
-
- QuartzSalGraphics& gr = static_cast<QuartzSalGraphics&>(rGraphics);
- if( mnCharCount <= 0 || !gr.CheckContext() )
- return;
-
- CGContextSaveGState( gr.mrContext );
- CGContextSetTextDrawingMode(gr.mrContext, kCGTextFill);
- CGContextSetShouldAntialias( gr.mrContext, true );
- CGContextSetShouldSubpixelPositionFonts( gr.mrContext, false );
- if( mpStyle->GetColor() ) {
- CGContextSetFillColorWithColor(gr.mrContext, mpStyle->GetColor());
- CGContextSetStrokeColorWithColor(gr.mrContext, mpStyle->GetColor());
- }
- else {
- CGContextSetRGBFillColor(gr.mrContext, 0.0, 0.0, 0.0, 1.0);
- }
-
- CGContextSetTextMatrix(gr.mrContext, CGAffineTransformMakeScale(1.0, -1.0));
- CGContextSetShouldAntialias( gr.mrContext, !gr.mbNonAntialiasedText );
-
- Point pos = GetDrawPosition(Point(0,0));
- CGPoint posDev = CGContextConvertPointToDeviceSpace(gr.mrContext, CGPointMake(pos.X(), pos.Y()));
- SAL_INFO( "vcl.coretext.layout",
- " context=" << gr.mrContext <<
- " pos=(" << pos.X() << "," << pos.Y() <<")" <<
- " posDev=" << posDev <<
- " font=" << mpStyle->GetFont() );
-
- CGContextTranslateCTM(gr.mrContext, pos.X(), pos.Y());
-
- CFArrayRef pRuns = CTLineGetGlyphRuns(mpLine);
- const CFIndex nRuns = CFArrayGetCount(pRuns);
-
- for (CFIndex nRun = 0; nRun < nRuns; nRun++)
- {
- CTRunRef pRun = (CTRunRef)CFArrayGetValueAtIndex(pRuns, nRun);
- if (!pRun)
- continue;
-
- const CFIndex nGlyphs = CTRunGetGlyphCount(pRun);
- if (nGlyphs)
- {
- CGGlyph pGlyphs[nGlyphs];
- CGSize pAdvances[nGlyphs];
- CTRunGetGlyphs(pRun, CFRangeMake(0, 0), pGlyphs);
- CTRunGetAdvances(pRun, CFRangeMake(0, 0), pAdvances);
-
- CFDictionaryRef aAttributes = CTRunGetAttributes(pRun);
- CTFontRef pCTFont = (CTFontRef)CFDictionaryGetValue(aAttributes, kCTFontAttributeName);
- CGFontRef pCGFont = CTFontCopyGraphicsFont(pCTFont, NULL);
- if (!pCGFont) {
- SAL_INFO("vcl.coretext.layout", "Error pCGFont is NULL");
- return;
- }
-
- CGContextSetFont(gr.mrContext, pCGFont);
- CFRelease(pCGFont);
- CGContextSetFontSize(gr.mrContext, CTFontGetSize(pCTFont));
-
- CGContextShowGlyphsWithAdvances(gr.mrContext, pGlyphs, pAdvances, nGlyphs);
- }
- }
-
-#ifndef IOS
- // Request an update of the changed window area. Like in the ATSUI
- // code, I am not sure if this is actually necessary. Once this
- // seems to work fine otherwise, let's try removing this.
- if( gr.IsWindowGraphics() )
- {
- CGRect drawRect = CTLineGetImageBounds( mpLine, gr.mrContext );
- SAL_INFO( "vcl.coretext.layout", "drawRect=" << drawRect );
- if( !CGRectIsNull( drawRect ) ) {
-#if 1
- // For kicks, try the same silly (?) enlarging of the
- // rectangle as in the ATSUI code
- drawRect.origin.y -= drawRect.size.height;
- drawRect.size.height += 2*drawRect.size.height;
- SAL_INFO( "vcl.coretext.layout", "after enlarging drawRect=" << drawRect );
-#endif
- drawRect = CGContextConvertRectToDeviceSpace( gr.mrContext, drawRect );
- SAL_INFO( "vcl.coretext.layout", "after convert: drawRect=" << drawRect );
- gr.RefreshRect( drawRect );
- }
- }
-#endif
-
- // restore the original graphic context transformations
- CGContextRestoreGState( gr.mrContext );
-}
-
-// not needed. CoreText manage fallback directly
-void CoreTextLayout::DropGlyph( int /*nStart*/ )
-{
-}
-
-// Note that the "DX array" here is filled with individual character
-// widths, while ImplLayoutArgs::mpDXArray contains cumulative
-// character positions. Consistency is over-rated.
-
-long CoreTextLayout::FillDXArray( sal_Int32* pDXArray ) const
-{
- if (pDXArray)
- {
- for (int i = 0; i < mnCharCount; i++)
- pDXArray[i] = 0;
-
- CFArrayRef runs = CTLineGetGlyphRuns(mpLine);
- const CFIndex nRuns = CFArrayGetCount(runs);
-
- for (CFIndex runIndex = 0; runIndex < nRuns; runIndex++)
- {
- CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex(runs, runIndex);
- if (!run)
- continue;
-
- const CFIndex runGlyphCount = CTRunGetGlyphCount(run);
- if (runGlyphCount)
- {
- CFIndex runStringIndices[runGlyphCount];
- CGSize runGlyphAdvances[runGlyphCount];
- CTRunGetStringIndices(run, CFRangeMake(0, 0), runStringIndices);
- CTRunGetAdvances(run, CFRangeMake(0, 0), runGlyphAdvances);
- for (int i = 0; i < runGlyphCount; i++)
- {
- const CFIndex charIndex = runStringIndices[i];
- pDXArray[charIndex] += runGlyphAdvances[i].width;
- }
- }
- }
- }
-
- return GetTextWidth();
-}
-
-bool CoreTextLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect ) const
-{
- SAL_INFO( "vcl.coretext.layout", "GetBoundRect(" << this << ")" );
-
- QuartzSalGraphics& gr = static_cast<QuartzSalGraphics&>(rGraphics);
-
- if( !gr.CheckContext() )
- return false;
-
- if ( !mbHasBoundRectangle ) {
- CGRect bound_rect = CTLineGetImageBounds( mpLine, gr.mrContext );
- if ( !CGRectIsNull( bound_rect ) ) {
- maBoundRectangle = Rectangle(
- Point( round_to_long(bound_rect.origin.x * mpStyle->GetFontStretchFactor()),
- round_to_long(bound_rect.origin.y - bound_rect.size.height )),
- Size( round_to_long((bound_rect.size.width + CTLineGetTrailingWhitespaceWidth( mpLine )) * mpStyle->GetFontStretchFactor()),
- round_to_long(bound_rect.size.height)));
- maBoundRectangle.Justify();
- } else {
- maBoundRectangle = Rectangle(
- Point( 0, 0 ),
- Size( round_to_long(CTLineGetTrailingWhitespaceWidth( mpLine ) * mpStyle->GetFontStretchFactor()),
- 0 ) );
- maBoundRectangle.Justify();
- }
- mbHasBoundRectangle = true;
- }
-
- rVCLRect = maBoundRectangle;
- SAL_INFO( "vcl.coretext.layout", "GetBoundRect() returning with rVCLRect={" << rVCLRect << "}" );
-
- return true;
-}
-
-void CoreTextLayout::GetCaretPositions(int nMaxIndex, sal_Int32* pCaretXArray) const
-{
- SAL_INFO( "vcl.coretext.layout", "GetCaretPositions(" << this << ",nMaxIndex=" << nMaxIndex << ")" );
-
- // initialize the caret positions
- for (int i = 0; i < nMaxIndex; ++i)
- pCaretXArray[i] = -1;
-
- for (int i = 0 ; i < mnCharCount; i++)
- {
- CGFloat fPrimary, fSecondary;
- fPrimary = CTLineGetOffsetForStringIndex(mpLine, i, &fSecondary);
- // update previous trailing position
- if (i > 0)
- pCaretXArray[2*i-1] = round_to_long(mnBaseAdvance + fPrimary);
- // update current leading position
- if (2*i >= nMaxIndex)
- break;
- pCaretXArray[2*i+0] = round_to_long(mnBaseAdvance + fPrimary);
- }
-}
-
-int CoreTextLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphIDs, Point& rPos, int& nStart,
- sal_Int32* pGlyphAdvances, int* pCharIndexes ) const
-{
- SAL_INFO( "vcl.coretext.layout", "GetNextGlyphs(" << this << ",nLen=" << nLen << ",nStart=" << nStart << ")" );
-
- if( nStart < 0 ) { // first glyph requested?
- nStart = 0;
- mnCurrentRunIndex = 0;
- mnCurrentGlyphIndex = 0;
- mnCurrentGlyphRunIndex = 0;
- }
- else if( nStart >= mnGlyphCount ) {
- mnCurrentRunIndex = 0;
- mnCurrentGlyphIndex = 0;
- mnCurrentGlyphRunIndex = 0;
- return 0;
- }
- if( !mpRuns ) {
- mpRuns = CTLineGetGlyphRuns(mpLine);
- }
- CFIndex nRuns = CFArrayGetCount( mpRuns );
- CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex( mpRuns, mnCurrentRunIndex );
- CFIndex nb_glyphs = CTRunGetGlyphCount( run );
-
- int i = 0;
- bool first = true;
- while( i < nLen ) {
- if( mnCurrentGlyphRunIndex >= nb_glyphs ) {
- mnCurrentRunIndex += 1;
- if( mnCurrentRunIndex >= nRuns ) {
- break;
- }
- run = (CTRunRef)CFArrayGetValueAtIndex( mpRuns, mnCurrentRunIndex );
- nb_glyphs = CTRunGetGlyphCount( run );
- mnCurrentGlyphRunIndex = 0;
- }
- if( first ) {
- CGPoint first_pos;
- CTRunGetPositions(run, CFRangeMake(mnCurrentGlyphRunIndex,1), &first_pos);
- Point pos(first_pos.x, first_pos.y);
- rPos = GetDrawPosition(pos);
- SAL_INFO( "vcl.coretext.layout", "rPos(" << rPos.X() << "," << rPos.Y() << ")" );
- first = false;
- }
- pGlyphIDs[i] = mpGlyphs[mnCurrentGlyphIndex];
- if( pGlyphAdvances ) {
- pGlyphAdvances[i] = mpGlyphAdvances[mnCurrentGlyphIndex].width;
- }
- if( pCharIndexes ) {
- pCharIndexes[i] = mpGlyphs2Chars[mnCurrentGlyphIndex];
- }
- mnCurrentGlyphIndex += 1;
- mnCurrentGlyphRunIndex += 1;
- i += 1;
- nStart += 1;
- }
-
- SAL_INFO( "vcl.coretext.layout", "GetNextGlyphs() returning " << i );
-
- return i;
-}
-
-int CoreTextLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const
-{
- SAL_INFO( "vcl.coretext.layout", "GetTextBreak(" << this << ",nMaxWidth=" << nMaxWidth << ",nCharExtra=" << nCharExtra << ",nFactor=" << nFactor << ")" );
-
- if( !mpLine ) {
- SAL_INFO( "vcl.coretext.layout", "GetTextBreak() returning STRING_LEN" );
- return STRING_LEN;
- }
-
- // the semantics of the legacy use case (nCharExtra!=0) cannot be mapped to ATSUBreakLine()
- if( nCharExtra != 0 )
- {
-#if 0
- // prepare the measurement by layouting and measuring the un-expanded/un-condensed text
- if( !InitGIA() )
- return STRING_LEN;
-
- // TODO: use a better way than by testing each the char position
- ATSUTextMeasurement nATSUSumWidth = 0;
- const ATSUTextMeasurement nATSUMaxWidth = Vcl2Fixed( nMaxWidth / nFactor );
- const ATSUTextMeasurement nATSUExtraWidth = Vcl2Fixed( nCharExtra ) / nFactor;
- for( int i = 0; i < mnCharCount; ++i ) {
- nATSUSumWidth += mpCharWidths[i];
- if( nATSUSumWidth >= nATSUMaxWidth )
- return (mnMinCharPos + i);
- nATSUSumWidth += nATSUExtraWidth;
- if( nATSUSumWidth >= nATSUMaxWidth )
- if( i+1 < mnCharCount )
- return (mnMinCharPos + i);
- }
-
- return STRING_LEN;
-#endif
- }
-
- // get a quick overview on what could fit
- const CGFloat nPixelWidth = (nMaxWidth - (nCharExtra * mnCharCount)) / nFactor;
- if( nPixelWidth <= 0 ) {
- SAL_INFO( "vcl.coretext.layout", "GetTextBreak(): nPixelWidth=" << nPixelWidth << ", returning mnMinCharPos=" << mnMinCharPos );
- return mnMinCharPos;
- }
-
- CFIndex nBreakPos = CTTypesetterSuggestLineBreak( mpTypesetter, 0, nPixelWidth ) + mnMinCharPos;
-
- // upper layers expect STRING_LEN if everything fits
- if( nBreakPos >= mnEndCharPos ) {
- SAL_INFO( "vcl.coretext.layout", "GetTextBreak(): nBreakPos=" << nBreakPos << " >= mnEndCharPos=" << mnEndCharPos << ", returning STRING_LEN" );
- return STRING_LEN;
- }
-
- SAL_INFO( "vcl.coretext.layout", "GetTextBreak() returning nBreakPos=" << nBreakPos );
-
- return nBreakPos;
-}
-
-long CoreTextLayout::GetTextWidth() const
-{
- double width = CTLineGetTypographicBounds(mpLine, NULL, NULL, NULL);
- long w = round_to_long(width + CTLineGetTrailingWhitespaceWidth(mpLine));
-
- SAL_INFO( "vcl.coretext.layout", "GetTextWidth(" << this << ") returning " << w );
-
- return w;
-}
-
-bool CoreTextLayout::LayoutText( ImplLayoutArgs& rArgs)
-{
- SAL_INFO( "vcl.coretext.layout", "LayoutText(" << this << ",rArgs=" << rArgs << ")" );
-
- mnCharCount = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
-
- /* don't layout empty (or worse negative size) strings */
- if(mnCharCount <= 0)
- return false;
-
-#ifndef NDEBUG
- mnSavedMinCharPos = rArgs.mnMinCharPos;
- mnSavedEndCharPos = rArgs.mnEndCharPos;
- mpSavedStr = new sal_Unicode[mnCharCount];
- memcpy( mpSavedStr, &rArgs.mpStr[mnSavedMinCharPos], mnCharCount * sizeof( sal_Unicode ) );
-#endif
-
- // Note that unlike the ATSUI code, we store only the part of the
- // buffer addressed by mnMinCharPos--mnEndCharPos. Not the whole
- // buffer. I.e. all indexing of the string as referenced to by
- // mpTypesetter should be relative to mnMinCharPos.
- CFStringRef string = CFStringCreateWithCharacters( NULL, &(rArgs.mpStr[rArgs.mnMinCharPos]), mnCharCount );
- if ( !string ) {
- SAL_INFO( "vcl.coretext.layout", " CFStringCreateWithCharacter() returned NULL, returning false" );
- return false;
- }
-
- CFStringRef keys[1];
- CFTypeRef values[1];
-
- keys[0] = kCTFontAttributeName;
- values[0] = CFRetain( mpStyle->GetFont() );
-
- CFDictionaryRef attributes = CFDictionaryCreate( kCFAllocatorDefault,
- (const void**)&keys,
- (const void**)&values,
- 1,
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks );
-
- CFAttributedStringRef attributed_string = CFAttributedStringCreate( NULL, string, attributes );
- CFRelease( string );
- CFRelease( attributes );
- if ( !attributed_string ) {
- SAL_INFO( "vcl.coretext.layout", " CFAttributedStringCreate() returned NULL, returning false" );
- return false;
- }
-
- mpTypesetter = CTTypesetterCreateWithAttributedString( attributed_string );
- CFRelease( attributed_string );
- if ( !mpTypesetter ) {
- SAL_INFO( "vcl.coretext.layout", " CTTypesetterCreateWithAttributedString() returned NULL, returning false" );
- return false;
- }
-
- mpLine = CTTypesetterCreateLine( mpTypesetter, CFRangeMake( 0, 0 ) );
- if ( !mpLine ) {
- SAL_INFO( "vcl.coretext.layout", " CTTypesetterCreateLine() returned NULL, returning false" );
- return false;
- }
-
- mnGlyphCount = CTLineGetGlyphCount( mpLine );
-
- GetMeasurements();
-
- SAL_INFO( "vcl.coretext.layout", "LayoutText() returning, mnGlyphCount=" << mnGlyphCount );
-
- return true;
-}
-
-void CoreTextLayout::GetMeasurements()
-{
- InvalidateMeasurements();
-
- mpGlyphs = new CGGlyph[ mnGlyphCount ];
- mpCharWidths = new CGFloat[ mnCharCount ];
- mpGlyphs2Chars = new int[ mnGlyphCount ];
- mpGlyphAdvances = new CGSize[ mnGlyphCount ];
-
- CFArrayRef runs = CTLineGetGlyphRuns( mpLine );
- const CFIndex nRuns = CFArrayGetCount( runs );
-
- CFIndex lineGlyphIx = 0;
- for ( CFIndex runIx = 0; runIx < nRuns; runIx++ )
- {
- CTRunRef run = (CTRunRef)CFArrayGetValueAtIndex( runs, runIx );
- if ( !run )
- continue;
-
- std::ostringstream glyphPositionInfo;
- std::ostringstream glyphAdvancesInfo;
- std::ostringstream charWidthInfo;
-
- const CFIndex runGlyphCount = CTRunGetGlyphCount( run );
- if ( runGlyphCount )
- {
- assert( lineGlyphIx + runGlyphCount <= mnGlyphCount );
-
- const CFIndex lineRunGlyphStartIx = lineGlyphIx;
- (void) lineRunGlyphStartIx;
-
- CFIndex runStringIndices[ runGlyphCount ];
- CTRunGetStringIndices( run, CFRangeMake( 0, 0 ), runStringIndices );
-
- CTRunGetGlyphs( run, CFRangeMake( 0, 0 ), &mpGlyphs[ lineGlyphIx ] );
-
- CTRunGetAdvances( run, CFRangeMake( 0, 0 ), &mpGlyphAdvances[ lineGlyphIx ] );
-
- for ( CFIndex runGlyphIx = 0 ; runGlyphIx < runGlyphCount; lineGlyphIx++, runGlyphIx++ )
- {
- const CFIndex charIx = runStringIndices[ runGlyphIx ];
- assert( charIx < mnCharCount );
- mpGlyphs2Chars[ lineGlyphIx ] = charIx;
-
- mpCharWidths[ charIx ] = mpGlyphAdvances[ lineGlyphIx ].width;
- }
-#ifdef SAL_LOG_INFO
- for ( int i = 0; i < runGlyphCount; i++ ) {
- const int ix = lineRunGlyphStartIx + i;
- if ( i < 7 ) {
- glyphPositionInfo << " " << mpGlyphs[ ix ];
- glyphAdvancesInfo << " " << mpGlyphAdvances[ ix ];
- } else if (i == 7 ) {
- glyphPositionInfo << "...";
- glyphAdvancesInfo << "...";
- }
- }
- SAL_INFO( "vcl.coretext.layout", " run " << runIx << ": " << runGlyphCount << " glyphs:" << glyphPositionInfo.str() );
- SAL_INFO( "vcl.coretext.layout", " run " << runIx << ": advances:" << glyphAdvancesInfo.str() );
-#endif
- }
- }
-
-#ifdef SAL_LOG_INFO
- std::ostringstream charWidthInfo;
-
- for ( int ix = 0; ix < mnCharCount; ix++ ) {
- if ( ix < 7 )
- charWidthInfo << " " << mpCharWidths[ ix ];
- else if ( ix == 7 )
- charWidthInfo << "...";
- }
- SAL_INFO( "vcl.coretext.layout", " char widths:" << charWidthInfo.str() );
-#endif
-}
-
-
-// not needed. CoreText manage fallback directly
-void CoreTextLayout::MoveGlyph( int /*nStart*/, long /*nNewXPos*/ )
-{
-}
-
-// not needed. CoreText manage fallback directly
-void CoreTextLayout::Simplify( bool /*bIsBase*/ )
-{
-}
-
-SalLayout* QuartzSalGraphics::GetTextLayout( ImplLayoutArgs&, int /*nFallbackLevel*/ )
-{
- CoreTextLayout* layout = new CoreTextLayout( m_style );
-
- return layout;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/coretext/salcoretextstyle.cxx b/vcl/coretext/salcoretextstyle.cxx
deleted file mode 100644
index ca9f278..0000000
--- a/vcl/coretext/salcoretextstyle.cxx
+++ /dev/null
@@ -1,129 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "coretext/common.h"
-#include "outfont.hxx"
-#include "coretext/salcoretextfontutils.hxx"
-#include "coretext/salcoretextstyle.hxx"
-
-CoreTextStyleInfo::CoreTextStyleInfo() :
- m_fake_bold(false),
- m_fake_italic(false),
- m_matrix(CGAffineTransformIdentity),
- m_stretch_factor(1.0),
- m_CTParagraphStyle(NULL),
- m_CTFont(NULL),
- m_color(NULL),
- m_font_face(NULL)
-{
- SAL_INFO( "vcl.coretext.style", "CoreTextStyleInfo::CoreTextStyleInfo() " << this );
-}
-
-CoreTextStyleInfo::~CoreTextStyleInfo()
-{
- SAL_INFO( "vcl.coretext.style", "~CoreTextStyleInfo(" << this << ")" );
-
- SafeCFRelease(m_CTFont);
- SafeCFRelease(m_CTParagraphStyle);
- SafeCFRelease(m_color);
-}
-
-long CoreTextStyleInfo::GetFontStretchedSize() const
-{
- CGFloat size = CTFontGetSize(m_CTFont);
- return static_cast<long>(size * m_stretch_factor + 0.5);
-}
-
-void CoreTextStyleInfo::SetFont(FontSelectPattern* requested_font)
-{
- if(!requested_font)
- {
- SafeCFRelease(m_CTFont);
- m_font_face = NULL;
- return;
- }
- m_font_face = (CoreTextPhysicalFontFace*)(requested_font->mpFontData);
-
- m_matrix = CGAffineTransformIdentity;
- CGFloat font_size = (CGFloat)requested_font->mfExactHeight;
-
- // enable bold-emulation if needed
- if( (requested_font->GetWeight() >= WEIGHT_BOLD) &&
- (m_font_face->GetWeight() < WEIGHT_SEMIBOLD) )
- {
- /* FIXME: add support for fake bold */
- m_fake_bold = true;
- }
- if( ((requested_font->GetSlant() == ITALIC_NORMAL) || (requested_font->GetSlant() == ITALIC_OBLIQUE)) &&
- !((m_font_face->GetSlant() == ITALIC_NORMAL) || (m_font_face->GetSlant() == ITALIC_OBLIQUE)) )
- {
-#define kRotationForItalicText 10
- m_fake_italic = true;
- /* about 6 degree of slant */
- m_matrix = CGAffineTransformMake( 1, 0, -tanf( kRotationForItalicText * acosf(0) / 90 ), 1, 0, 0);
- }
-
- // prepare font stretching
- if( (requested_font->mnWidth != 0) && (requested_font->mnWidth != requested_font->mnHeight) )
- {
- m_stretch_factor = (float)requested_font->mnWidth / requested_font->mnHeight;
- m_matrix = CGAffineTransformScale(m_matrix, m_stretch_factor, 1.0F );
- }
-
- SafeCFRelease(m_CTFont);
-
- /* FIXME: pass attribute to take into accout 'VerticalStyle' */
- /* FIXME: how to deal with 'rendering options' i.e anti-aliasing, does it even matter in CoreText ? */
- m_CTFont = CTFontCreateCopyWithAttributes(m_font_face->GetCTFont(), font_size, &m_matrix, NULL);
-}
-
-void CoreTextStyleInfo::SetColor(SalColor color)
-{
- SafeCFRelease(m_color);
-#ifdef IOS
- // No CGColorCreateGenericRGB on iOS
- CGColorSpaceRef rgb_space = CGColorSpaceCreateDeviceRGB();
- CGFloat c[] = { SALCOLOR_RED(color) / 255.0f, SALCOLOR_GREEN(color) / 255.0f, SALCOLOR_BLUE(color) / 255.0f, 1.0 };
- m_color = CGColorCreate(rgb_space, c);
- CGColorSpaceRelease(rgb_space);
-#else
- m_color = CGColorCreateGenericRGB(SALCOLOR_RED(color) / 255.0, SALCOLOR_GREEN(color) / 255.0, SALCOLOR_BLUE(color) / 255.0, 1.0);
-#endif
-}
-
-void CoreTextStyleInfo::SetColor(void)
-{
- SafeCFRelease(m_color);
-}
-
-std::ostream &operator <<(std::ostream& s, CoreTextStyleInfo &rStyle)
-{
-#ifndef SAL_LOG_INFO
- (void) rStyle;
-#else
- s << "{Font=" << rStyle.GetFont();
- s << ",Color=" << rStyle.GetColor();
- if (rStyle.GetFontStretchFactor() != 1)
- s << ",Stretch=" << rStyle.GetFontStretchFactor();
- s << "}";
-#endif
- return s;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/coretext/salgdi.cxx b/vcl/coretext/salgdi.cxx
deleted file mode 100644
index 58e850d..0000000
--- a/vcl/coretext/salgdi.cxx
+++ /dev/null
@@ -1,341 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "coretext/common.h"
-
-#ifdef MACOSX
-
-#include "aqua/salframe.h"
-#include "coretext/salgdi.h"
-
-#else
-
-#include <premac.h>
-#include <UIKit/UIKit.h>
-#include <postmac.h>
-
-#include <basebmp/scanlineformats.hxx>
-
-#include "saldatabasic.hxx"
-#include "headless/svpframe.hxx"
-#include "headless/svpgdi.hxx"
-
-#endif
-
-#include "coretext/salcoretextstyle.hxx"
-
-#ifdef MACOSX
-
-QuartzSalGraphics::QuartzSalGraphics()
- : mpFrame( NULL )
- , mxLayer( NULL )
- , mrContext( NULL )
- , mpXorEmulation( NULL )
- , mnXorMode( 0 )
- , mnWidth( 0 )
- , mnHeight( 0 )
- , mnBitmapDepth( 0 )
- , mnRealDPIX( 0 )
- , mnRealDPIY( 0 )
- , mfFakeDPIScale( 1.0 )
- , mxClipPath( NULL )
- , maLineColor( COL_WHITE )
- , maFillColor( COL_BLACK )
- , mbNonAntialiasedText( false )
- , mbPrinter( false )
- , mbVirDev( false )
- , mbWindow( false )
-{
- SAL_INFO( "vcl.coretext.gr", "QuartzSalGraphics::QuartzSalGraphics() " << this );
-
- m_style = new CoreTextStyleInfo();
-}
-
-QuartzSalGraphics::~QuartzSalGraphics()
-{
- SAL_INFO( "vcl.coretext.gr", "~QuartzSalGraphics(" << this << ")" );
-
- if(m_style)
- {
- delete m_style;
- m_style = NULL;
- }
-}
-
-#endif
-
-inline bool QuartzSalGraphics::AddTempDevFont( ImplDevFontList*,
- const OUString& ,
- const OUString& )
-{
- OSL_ASSERT( FALSE );
- return false;
-}
-
-void QuartzSalGraphics::DrawServerFontLayout( const ServerFontLayout& )
-{
-}
-
-void QuartzSalGraphics::FreeEmbedFontData( const void* pData, long /*nDataLen*/ )
-{
- // TODO: implementing this only makes sense when the implementation of
- // QuartzSalGraphics::GetEmbedFontData() returns non-NULL
- (void)pData;
- DBG_ASSERT( (pData!=NULL), "QuartzSalGraphics::FreeEmbedFontData() is not implemented\n");
-}
-
-void QuartzSalGraphics::GetDevFontList( ImplDevFontList* pFontList )
-{
- DBG_ASSERT( pFontList, "QuartzSalGraphics::GetDevFontList(NULL) !");
-
- SalData* pSalData = GetSalData();
- if (pSalData->mpFontList == NULL)
- {
- pSalData->mpFontList = new SystemFontList();
- }
- // Copy all PhysicalFontFace objects contained in the SystemFontList
- pSalData->mpFontList->AnnounceFonts( *pFontList );
-}
-
-void QuartzSalGraphics::ClearDevFontCache()
-{
- SalData* pSalData = GetSalData();
- delete pSalData->mpFontList;
- pSalData->mpFontList = NULL;
-}
-
-void QuartzSalGraphics::GetDevFontSubstList( OutputDevice* )
-{
- // nothing to do since there are no device-specific fonts on Aqua
-}
-
-const void* QuartzSalGraphics::GetEmbedFontData( const PhysicalFontFace*,
- const sal_Ucs* /*pUnicodes*/,
- sal_Int32* /*pWidths*/,
- FontSubsetInfo&,
- long* /*pDataLen*/ )
-{
- return NULL;
-}
-
-const Ucs2SIntMap* QuartzSalGraphics::GetFontEncodingVector(const PhysicalFontFace*,
- const Ucs2OStrMap** /*ppNonEncoded*/ )
-{
- return NULL;
-}
-
-void QuartzSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLevel )
-{
- (void)nFallbackLevel; // glyph-fallback on CoreText is done differently -> no fallback level
-
- pMetric->mbScalableFont = true;
- pMetric->mbKernableFont = true;
- CTFontRef font = m_style->GetFont();
- DBG_ASSERT(font, "GetFontMetric without font set in style");
-
- pMetric->mnAscent = static_cast<long>(CTFontGetAscent(font) * mfFakeDPIScale + 0.5);
- pMetric->mnDescent = static_cast<long>(CTFontGetDescent(font) * mfFakeDPIScale + 0.5);
- pMetric->mnExtLeading = static_cast<long>(CTFontGetLeading(font) * mfFakeDPIScale + 0.5);
- pMetric->mnIntLeading = 0;
- pMetric->mnWidth = m_style->GetFontStretchedSize();
-
- SAL_INFO( "vcl.coretext.gr",
- "GetFontMetric(" << this << ") returning: {ascent=" << pMetric->mnAscent <<
- ",descent=" << pMetric->mnDescent <<
- ",extleading=" << pMetric->mnExtLeading <<
- ",intleading=" << pMetric->mnIntLeading <<
- ",width=" << pMetric->mnWidth <<
- "}" );
-}
-
-sal_Bool QuartzSalGraphics::GetGlyphBoundRect( sal_GlyphId /*nGlyphId*/, Rectangle& /*rRect*/ )
-{
- /* TODO: create a Ghyph iterator to keep track ot 'state' between call */
- return false;
-}
-
-sal_Bool QuartzSalGraphics::GetGlyphOutline( sal_GlyphId /*nGlyphId*/, basegfx::B2DPolyPolygon& /*rPolyPoly*/ )
-{
- /* TODO */
- return false;
-}
-
-void QuartzSalGraphics::GetGlyphWidths( const PhysicalFontFace* /*pFontData*/, bool /*bVertical*/,
- Int32Vector& /*rGlyphWidths*/, Ucs2UIntMap& /*rUnicodeEnc*/ )
-{
-}
-
-sal_uLong QuartzSalGraphics::GetKernPairs( sal_uLong, ImplKernPairData* )
-{
- return 0;
-}
-
-bool QuartzSalGraphics::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const
-{
- if( !m_style )
- {
- return false;
- }
- CoreTextPhysicalFontFace* font_face = m_style->GetFontFace();
- if( !font_face)
- {
- return false;
- }
- return font_face->GetImplFontCapabilities(rFontCapabilities);
-}
-
-const ImplFontCharMap* QuartzSalGraphics::GetImplFontCharMap() const
-{
- if( !m_style )
- {
- return NULL;
- }
- CoreTextPhysicalFontFace* font_face = m_style->GetFontFace();
- if( !font_face)
- {
- return ImplFontCharMap::GetDefaultMap();
- }
- return font_face->GetImplFontCharMap();
-}
-
-#ifndef IOS
-
-bool QuartzSalGraphics::GetRawFontData( const PhysicalFontFace* pFontFace,
- std::vector<unsigned char>& rBuffer, bool* pJustCFF )
-{
- const CoreTextPhysicalFontFace* font_face = static_cast<const CoreTextPhysicalFontFace*>(pFontFace);
-
- return font_face->GetRawFontData(rBuffer, pJustCFF);
-}
-
-#endif
-
-SystemFontData QuartzSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) const
-{
- SystemFontData aSysFontData;
- aSysFontData.nSize = sizeof( SystemFontData );
- aSysFontData.bAntialias = true;
-
- CTFontRef font = CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 0.0, NULL);
- font = (CTFontRef)CFRetain(font);
- aSysFontData.rCTFont = font;
-
- CTFontRef italic_font = CTFontCreateCopyWithSymbolicTraits( font,
- 0.0,
- NULL,
- kCTFontItalicTrait,
- kCTFontItalicTrait + kCTFontBoldTrait);
- aSysFontData.bFakeItalic = italic_font ? false : true;
- SafeCFRelease(italic_font);
-
- CTFontRef bold_font = CTFontCreateCopyWithSymbolicTraits( font,
- 0.0,
- NULL,
- kCTFontBoldTrait,
- kCTFontItalicTrait + kCTFontBoldTrait);
- aSysFontData.bFakeBold = bold_font ? false : true;
- SafeCFRelease(bold_font);
-
- CTFontRef vertical_font = CTFontCreateCopyWithSymbolicTraits( font,
- 0.0,
- NULL,
- kCTFontVerticalTrait,
- kCTFontVerticalTrait);
- aSysFontData.bVerticalCharacterType = vertical_font ? true : false;
- SafeCFRelease(vertical_font);
-
- return aSysFontData;
-}
-
-sal_uInt16 QuartzSalGraphics::SetFont( FontSelectPattern* pReqFont, int /*nFallbackLevel*/ )
-{
- m_style->SetFont(pReqFont);
-
- return 0;
-}
-
-void QuartzSalGraphics::SetTextColor( SalColor nSalColor )
-{
- m_style->SetColor(nSalColor);
-}
-
-#ifdef IOS
-
-// Note that "QuartzSalGraphics" *is* SvpSalGraphics for iOS
-
-bool SvpSalGraphics::CheckContext()
-{
- const basegfx::B2IVector size = m_aDevice->getSize();
- const basegfx::B2IVector bufferSize = m_aDevice->getBufferSize();
- const sal_Int32 scanlineStride = m_aDevice->getScanlineStride();
- basebmp::RawMemorySharedArray pixelBuffer = m_aDevice->getBuffer();
-
- SAL_INFO( "vcl.ios",
- "CheckContext: device=" << m_aDevice.get() <<
- " size=" << size.getX() << "x" << size.getY() <<
- (m_aDevice->isTopDown() ? " top-down" : " bottom-up") <<
- " stride=" << scanlineStride <<
- " bufferSize=(" << bufferSize.getX() << "," << bufferSize.getY() << ")" );
-
- switch( m_aDevice->getScanlineFormat() ) {
- case basebmp::Format::EIGHT_BIT_PAL:
- mrContext = CGBitmapContextCreate(pixelBuffer.get(),
- bufferSize.getX(), bufferSize.getY(),
- 8, scanlineStride,
- CGColorSpaceCreateDeviceGray(),
- kCGImageAlphaNone);
- break;
- case basebmp::Format::THIRTYTWO_BIT_TC_MASK_RGBA:
- mrContext = CGBitmapContextCreate(pixelBuffer.get(),
- bufferSize.getX(), bufferSize.getY(),
- 8, scanlineStride,
- CGColorSpaceCreateDeviceRGB(),
- kCGImageAlphaNoneSkipLast);
- break;
- default:
- SAL_INFO( "vcl.ios", "CheckContext: unsupported color format " << basebmp::Format::formatName( m_aDevice->getScanlineFormat() ) );
- }
-
- SAL_WARN_IF( mrContext == NULL, "vcl.ios", "CheckContext() failed" );
-
- // Should we also clip the context? (Then we need to add a
- // getBounds() function to BitmapDevice.)
-
- if( mrContext != NULL && m_aDevice->isTopDown() )
- {
- CGContextTranslateCTM( mrContext, 0, bufferSize.getY() );
- CGContextScaleCTM( mrContext, 1, -1 );
- }
-
- SAL_INFO( "vcl.ios", "CheckContext: context=" << mrContext );
-
- return ( mrContext != NULL );
-}
-
-CGContextRef SvpSalGraphics::GetContext()
-{
- if ( !mrContext )
- CheckContext();
-
- return mrContext;
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/coretext/salgdi2.cxx b/vcl/coretext/salgdi2.cxx
index 8389d2c..0ae7d1f 100644
--- a/vcl/coretext/salgdi2.cxx
+++ b/vcl/coretext/salgdi2.cxx
@@ -37,7 +37,16 @@
#include "vcl/svapp.hxx"
#include "coretext/salgdi2.h"
+
+#ifdef MACOSX
#include "aqua/salframe.h"
+#endif
+
+#ifdef IOS
+#include "saldatabasic.hxx"
+#include <basebmp/scanlineformats.hxx>
+#endif
+
#include "ctfonts.hxx"
#include "fontsubset.hxx"
@@ -258,6 +267,7 @@ void ImplMacFontData::ReadMacCmapEncoding( void ) const
// -----------------------------------------------------------------------
AquaSalGraphics::AquaSalGraphics()
+#ifdef MACOSX
: mpFrame( NULL )
, mxLayer( NULL )
, mrContext( NULL )
@@ -279,12 +289,19 @@ AquaSalGraphics::AquaSalGraphics()
, mbPrinter( false )
, mbVirDev( false )
, mbWindow( false )
+#else
+ : mpMacFontData( NULL )
+ , mpMacTextStyle( NULL )
+ , maTextColor( COL_BLACK )
+ , mbNonAntialiasedText( false )
+#endif
{}
// -----------------------------------------------------------------------
AquaSalGraphics::~AquaSalGraphics()
{
+#ifdef MAXOSX
CGPathRelease( mxClipPath );
delete mpMacTextStyle;
@@ -300,6 +317,7 @@ AquaSalGraphics::~AquaSalGraphics()
mrContext = NULL;
// memory is freed automatically by maOwnContextMemory
}
+#endif
}
// =======================================================================
@@ -806,4 +824,67 @@ SystemFontData AquaSalGraphics::GetSysFontData( int /* nFallbacklevel */ ) const
return aSysFontData;
}
+#ifdef IOS
+
+// Note that "SvpSalGraphics" is actually called AquaSalGraphics for iOS
+
+bool SvpSalGraphics::CheckContext()
+{
+ const basegfx::B2IVector size = m_aDevice->getSize();
+ const basegfx::B2IVector bufferSize = m_aDevice->getBufferSize();
+ const sal_Int32 scanlineStride = m_aDevice->getScanlineStride();
+ basebmp::RawMemorySharedArray pixelBuffer = m_aDevice->getBuffer();
+
+ SAL_INFO( "vcl.ios",
+ "CheckContext: device=" << m_aDevice.get() <<
+ " size=" << size.getX() << "x" << size.getY() <<
+ (m_aDevice->isTopDown() ? " top-down" : " bottom-up") <<
+ " stride=" << scanlineStride <<
+ " bufferSize=(" << bufferSize.getX() << "," << bufferSize.getY() << ")" );
+
+ switch( m_aDevice->getScanlineFormat() ) {
+ case basebmp::Format::EIGHT_BIT_PAL:
+ mrContext = CGBitmapContextCreate(pixelBuffer.get(),
+ bufferSize.getX(), bufferSize.getY(),
+ 8, scanlineStride,
+ CGColorSpaceCreateDeviceGray(),
+ kCGImageAlphaNone);
+ break;
+ case basebmp::Format::THIRTYTWO_BIT_TC_MASK_RGBA:
+ mrContext = CGBitmapContextCreate(pixelBuffer.get(),
+ bufferSize.getX(), bufferSize.getY(),
+ 8, scanlineStride,
+ CGColorSpaceCreateDeviceRGB(),
+ kCGImageAlphaNoneSkipLast);
+ break;
+ default:
+ SAL_INFO( "vcl.ios", "CheckContext: unsupported color format " << basebmp::Format::formatName( m_aDevice->getScanlineFormat() ) );
+ }
+
+ SAL_WARN_IF( mrContext == NULL, "vcl.ios", "CheckContext() failed" );
+
+ // Should we also clip the context? (Then we need to add a
+ // getBounds() function to BitmapDevice.)
+
+ if( mrContext != NULL && m_aDevice->isTopDown() )
+ {
+ CGContextTranslateCTM( mrContext, 0, bufferSize.getY() );
+ CGContextScaleCTM( mrContext, 1, -1 );
+ }
+
+ SAL_INFO( "vcl.ios", "CheckContext: context=" << mrContext );
+
+ return ( mrContext != NULL );
+}
+
+CGContextRef SvpSalGraphics::GetContext()
+{
+ if ( !mrContext )
+ CheckContext();
+
+ return mrContext;
+}
+
+#endif
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 2c4412f..3b9b68e 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -75,44 +75,28 @@ bool SvpSalGraphics::drawAlphaRect( long /*nX*/, long /*nY*/, long /*nWidth*/, l
return false;
}
+#ifdef MACOSX
+
SvpSalGraphics::SvpSalGraphics() :
m_bUseLineColor( true ),
m_aLineColor( COL_BLACK ),
m_bUseFillColor( false ),
m_aFillColor( COL_WHITE ),
m_aDrawMode( basebmp::DrawMode_PAINT ),
-#ifndef IOS
m_aTextColor( COL_BLACK ),
m_eTextFmt( basebmp::Format::EIGHT_BIT_GREY ),
-#endif
m_bClipSetup( false )
{
-#ifndef IOS
for( int i = 0; i < MAX_FALLBACK; ++i )
m_pServerFont[i] = NULL;
-#else
- mrContext = nil;
- mfFakeDPIScale = 1.0;
- m_style = new CoreTextStyleInfo();
-#endif
}
SvpSalGraphics::~SvpSalGraphics()
{
-#ifdef IOS
- if(m_style)
- {
- delete m_style;
- m_style = NULL;
- }
- if(mrContext)
- {
- CGContextRelease( mrContext );
- mrContext = NULL;
- }
-#endif
}
+#endif
+
void SvpSalGraphics::setDevice( basebmp::BitmapDeviceSharedPtr& rDevice )
{
m_aOrigDevice = rDevice;
diff --git a/vcl/inc/coretext/salcoretextfontutils.hxx b/vcl/inc/coretext/salcoretextfontutils.hxx
deleted file mode 100644
index bfd3d76..0000000
--- a/vcl/inc/coretext/salcoretextfontutils.hxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _VCL_CORETEXT_SALCORETEXTFONTUTILS_HXX
-#define _VCL_CORETEXT_SALCORETEXTFONTUTILS_HXX
-
-#include <boost/unordered_map.hpp>
-
-#include <vcl/fontcapabilities.hxx>
-
-#include "coretext/common.h"
-#include "outfont.hxx"
-#include "impfont.hxx"
-
-class CoreTextPhysicalFontFace : public PhysicalFontFace
-{
-public:
- CoreTextPhysicalFontFace(const ImplDevFontAttributes&, CTFontRef font);
- virtual ~CoreTextPhysicalFontFace();
- virtual PhysicalFontFace* 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.
- */
-class SystemFontList
-{
-public:
- SystemFontList();
- ~SystemFontList();
-
- void AnnounceFonts( ImplDevFontList& ) const;
- CoreTextPhysicalFontFace* GetFontDataFromRef( CTFontRef ) const;
-
-private:
- typedef boost::unordered_map<CTFontRef,CoreTextPhysicalFontFace*> CoreTextFontContainer;
- CoreTextFontContainer m_aFontContainer;
-
- void InitGlyphFallbacks();
-};
-
-#endif // _VCL_CORETEXT_SALCORETEXTFONTUTILS_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/coretext/salcoretextstyle.hxx b/vcl/inc/coretext/salcoretextstyle.hxx
deleted file mode 100644
index 84fd574..0000000
--- a/vcl/inc/coretext/salcoretextstyle.hxx
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _VCL_CORETEXT_SALCORETEXTSTYLE_HXX
-#define _VCL_CORETEXT_SALCORETEXTSTYLE_HXX
-
-#include <iostream>
-
-#include "quartz/salgdicommon.hxx"
-
-#include "coretext/salcoretextfontutils.hxx"
-#include "outfont.hxx"
-
-class CoreTextStyleInfo
-{
-public:
- CoreTextStyleInfo();
- ~CoreTextStyleInfo();
- CTFontRef GetFont() const { return m_CTFont; };
- CoreTextPhysicalFontFace* GetFontFace() const { return m_font_face; };
- long GetFontStretchedSize() const;
- float GetFontStretchFactor() const { return m_stretch_factor; };
- CTParagraphStyleRef GetParagraphStyle() const { return m_CTParagraphStyle; } ;
- 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;
- CTParagraphStyleRef m_CTParagraphStyle;
- CTFontRef m_CTFont;
- CGColorRef m_color;
- CoreTextPhysicalFontFace* m_font_face;
-};
-
-std::ostream &operator <<(std::ostream& s, CoreTextStyleInfo &rStyle);
-
-#endif // _VCL_AQUA_CORETEXT_SALCORETEXTSTYLE_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/coretext/salgdi.h b/vcl/inc/coretext/salgdi.h
deleted file mode 100644
index b97d997..0000000
--- a/vcl/inc/coretext/salgdi.h
+++ /dev/null
@@ -1,333 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _VCL_CORETEXT_SALGDI_H
-#define _VCL_CORETEXT_SALGDI_H
-
-#ifndef MACOSX
-#error This file should be included only for OS X
-#endif
-
-#include "premac.h"
-#include <ApplicationServices/ApplicationServices.h>
-#include "postmac.h"
-
-#include "aqua/aquavcltypes.h"
-
-#include "coretext/salcoretextfontutils.hxx"
-
-#include "aqua/salframe.h"
-#include "quartz/salgdicommon.hxx"
-
-#include "salgdi.hxx"
-
-class CoreTextStyleInfo;
-
-// -------------------
-// - QuartzSalGraphics -
-// -------------------
-
-#define QuartzSalGraphics AquaSalGraphics
-
-class QuartzSalGraphics : public SalGraphics
-{
- friend class CoreTextLayout;
-protected:
- AquaSalFrame* 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. AquaSalInfoPrinter) scale
- /// everything down by a factor (see SetupPrinterGraphics for details)
- /// so we have to compensate for it with the inverse factor
- double mfFakeDPIScale;
- double mfFontScale;
-
- CGMutablePathRef mxClipPath; //< path representing current clip region
-
- /// Drawing colors
- RGBAColor maLineColor; //< pen color RGBA
- RGBAColor maFillColor; //< brush color RGBA
-
- bool mbNonAntialiasedText; //< allows text to be rendered without antialiasing
-
- // Graphics types
-
- bool mbPrinter; //< is this a printer graphics
- bool mbVirDev; //< is this a virtual device graphics
- bool mbWindow; //< is this a window graphics
-
- RGBColor m_TextColor;
-
-public:
- QuartzSalGraphics();
- virtual ~QuartzSalGraphics();
-
- bool IsPenVisible() const { return maLineColor.IsVisible(); }
- bool IsBrushVisible() const { return maFillColor.IsVisible(); }
-
- void SetWindowGraphics( AquaSalFrame* pFrame );
- AquaSalFrame* getGraphicsFrame() const { return mpFrame; }
- void setGraphicsFrame( AquaSalFrame* pFrame ) { mpFrame = pFrame; }
- void initResolution( NSWindow* );
-
- void SetPrinterGraphics( CGContextRef, long nRealDPIX, long nRealDPIY, double fFakeScale );
- void SetVirDevGraphics( CGLayerRef, CGContextRef, int nBitDepth = 0 );
-
- void copyResolution( QuartzSalGraphics& );
- void updateResolution();
-
- bool IsWindowGraphics() const { return mbWindow; }
-
- void ImplDrawPixel( long nX, long nY, const RGBAColor& ); // helper to draw single pixels
-
- bool CheckContext();
- CGContextRef GetContext();
-
- void UpdateWindow( NSRect& ); // delivered in NSView coordinates
-
-#if !defined(__LP64__) && !defined(NS_BUILD_32_LIKE_64)
- void RefreshRect( const CGRect& );
-#endif
-
- void RefreshRect( const NSRect& );
- void RefreshRect(float lX, float lY, float lWidth, float lHeight);
-
- void SetState();
- void UnsetState();
- // InvalidateContext does an UnsetState and sets mrContext to 0
- void InvalidateContext();
-
- 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_uInt32 nPoly, const sal_uInt32* 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_uInt32 nPoly, const sal_uInt32* pPoints,
- const SalPoint* const* pPtAry, const sal_uInt8* const* pFlgAry );
- virtual bool drawPolyLine(
- const ::basegfx::B2DPolygon&,
- double fTransparency,
- const ::basegfx::B2DVector& rLineWidths,
- basegfx::B2DLineJoin,
- com::sun::star::drawing::LineCap eLineCap);
-
- // CopyArea --> No RasterOp, but ClipRegion
- 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 );
-
- // 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 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 drawAlphaRect( long nX, long nY, long nWidth,
- long nHeight, sal_uInt8 nTransparency );
-
- 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 OUString& aCaption );
- virtual sal_Bool getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
- ControlState nState, const ImplControlValue& aValue,
- const OUString& aCaption,
- Rectangle &rNativeBoundingRegion,
- Rectangle &rNativeContentRegion );
-
- // get device resolution
- virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY );
- // get the depth of the device
- virtual sal_uInt16 GetBitCount() const;
- // get the width of the device
- virtual long GetGraphicsWidth() const;
-
- // set the clip region to empty
- virtual void ResetClipRegion();
-
- // set the line color to transparent (= don't draw lines)
- virtual void SetLineColor();
- // set the line color to a specific color
- virtual void SetLineColor( SalColor nSalColor );
- // set the fill color to transparent (= don't fill)
- virtual void SetFillColor();
- // set the fill color to a specific color, shapes will be
- // filled accordingly
- virtual void SetFillColor( SalColor nSalColor );
- // enable/disable XOR drawing
- virtual void SetXORMode( bool bSet, bool bInvertOnly );
- // set line color for raster operations
- virtual void SetROPLineColor( SalROPColor nROPColor );
- // set fill color for raster operations
- virtual void SetROPFillColor( SalROPColor nROPColor );
- // set the text color to a specific color
- virtual void SetTextColor( SalColor nSalColor );
- // set the font
- virtual sal_uInt16 SetFont( FontSelectPattern*, int nFallbackLevel );
- // get the current font's etrics
- 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 );
- // 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* );
- // graphics must drop any cached font info
- virtual void ClearDevFontCache();
- // graphics should call ImplAddDevFontSubstitute on supplied
- // OutputDevice for all its device specific preferred font substitutions
- virtual void GetDevFontSubstList( OutputDevice* );
- virtual bool AddTempDevFont( ImplDevFontList*, const OUString& rFileURL,
- const 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 successful
- // parameters: rToFile: contains a osl file URL to write the subset to
- // pFont: describes from which font to create a subset
- // pGlyphIDs: the glyph ids to be extracted
- // pEncoding: the character code corresponding to each glyph
- // pWidths: the advance widths of the correspoding glyphs (in PS font units)
- // nGlyphs: the number of glyphs
- // rInfo: additional outgoing information
- // implementation note: encoding 0 with glyph id 0 should be added implicitly
- // as "undefined character"
- virtual sal_Bool CreateFontSubset( const OUString& rToFile,
- const PhysicalFontFace* pFont,
- sal_Int32* 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
- // may return NULL in case of unknown encoding vector
- // if ppNonEncoded is set and non encoded characters (that is type1
- // glyphs with only a name) exist it is set to the corresponding
- // map for non encoded glyphs; the encoding vector contains -1
- // as encoding for these cases
- virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded );
-
- // GetEmbedFontData: gets the font data for a font marked
- // embeddable by GetDevFontList or NULL in case of error
- // parameters: pFont: describes the font in question
- // pWidths: the widths of all glyphs from char code 0 to 255
- // pWidths MUST support at least 256 members;
- // rInfo: additional outgoing information
- // pDataLen: out parameter, contains the byte length of the returned buffer
- virtual const void* GetEmbedFontData( const PhysicalFontFace*,
- const sal_Ucs* pUnicodes,
- sal_Int32* pWidths,
- FontSubsetInfo& rInfo,
- long* pDataLen );
- // frees the font data again
- virtual void FreeEmbedFontData( const void* pData, long nDataLen );
-
- virtual void GetGlyphWidths( const PhysicalFontFace*,
- bool bVertical,
- Int32Vector& rWidths,
- Ucs2UIntMap& rUnicodeEnc );
-
- 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;
-
- // 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;
-
-private:
- CoreTextStyleInfo* m_style;
-
- // differences between VCL, Quartz and kHiThemeOrientation coordinate systems
- // make some graphics seem to be vertically-mirrored from a VCL perspective
- bool IsFlipped() const { return mbWindow; };
-
- void ApplyXorContext();
- void Pattern50Fill();
- UInt32 getState( ControlState nState );
- UInt32 getTrackState( ControlState nState );
- bool GetRawFontData( const PhysicalFontFace* pFontData,
- std::vector<unsigned char>& rBuffer,
- bool* pJustCFF );
-};
-
-#if !defined(__LP64__) && !defined(NS_BUILD_32_LIKE_64)
-
-inline void QuartzSalGraphics::RefreshRect( const CGRect& rRect )
-{
- RefreshRect( rRect.origin.x, rRect.origin.y, rRect.size.width, rRect.size.height );
-}
-
-#endif
-
-inline void QuartzSalGraphics::RefreshRect( const NSRect& rRect )
-{
- RefreshRect( rRect.origin.x, rRect.origin.y, rRect.size.width, rRect.size.height );
-}
-
-#endif /* _VCL_CORETEXT_SALGDI_H */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/coretext/salgdi2.h b/vcl/inc/coretext/salgdi2.h
index ffe0632..01cf18a 100644
--- a/vcl/inc/coretext/salgdi2.h
+++ b/vcl/inc/coretext/salgdi2.h
@@ -25,14 +25,19 @@
#include "basegfx/polygon/b2dpolypolygon.hxx"
#include "premac.h"
+#ifdef MACOSX
#include <ApplicationServices/ApplicationServices.h>
+#include "aqua/aquavcltypes.h"
+#include "aqua/salframe.h"
+#else
+#include <CoreGraphics/CoreGraphics.h>
+#include <CoreText/CoreText.h>
+#endif
#include "postmac.h"
-#include "aqua/aquavcltypes.h"
#include <vcl/fontcapabilities.hxx>
#include "outfont.hxx"
-#include "aqua/salframe.h"
#include "salgdi.hxx"
#include "quartz/salgdicommon.hxx"
@@ -124,6 +129,8 @@ public:
virtual ImplMacFontData* GetFontDataFromId( sal_IntPtr nFontId ) const = 0;
};
+#ifdef MACOSX
+
// -------------------
// - AquaSalGraphics -
// -------------------
@@ -412,6 +419,8 @@ inline void AquaSalGraphics::RefreshRect( const NSRect& rRect )
RefreshRect( rRect.origin.x, rRect.origin.y, rRect.size.width, rRect.size.height );
}
+#endif
+
#endif // _SV_SALGDI_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/headless/svpframe.hxx b/vcl/inc/headless/svpframe.hxx
index aa3cdd2..112e552 100644
--- a/vcl/inc/headless/svpframe.hxx
+++ b/vcl/inc/headless/svpframe.hxx
@@ -27,6 +27,10 @@
#include <list>
+#ifdef IOS
+#define SvpSalGraphics AquaSalGraphics
+#endif
+
class SvpSalInstance;
class SvpSalGraphics;
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 3cf98ee..be80d29 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -27,13 +27,20 @@
#include "sallayout.hxx"
#ifdef IOS
-#include "coretext/salcoretextstyle.hxx"
+#include "coretext/salgdi2.h"
+#include <premac.h>
+#include <CoreGraphics/CoreGraphics.h>
+#include <postmac.h>
#endif
class ServerFont;
#ifdef IOS
-#define QuartzSalGraphics SvpSalGraphics
+// To keep changes to the CoreText code shared with AOO to a minimum,
+// let's continue calling the SalGraphics subclass "AquaSalGraphics" even if it
+// is used by us also on iOS, where of course the term "Aqua" has no meaning at all.
+// (Note that even on OS X, using the term "Aqua" is a misunderstanding or obsolete.)
+#define SvpSalGraphics AquaSalGraphics
#endif
class SvpSalGraphics : public SalGraphics
@@ -76,12 +83,18 @@ private:
protected:
#ifdef IOS
- friend class CoreTextLayout;
+ friend class CTLayout;
CGContextRef mrContext;
- CoreTextStyleInfo* m_style;
double mfFakeDPIScale;
- bool mbNonAntialiasedText;
+
+ // Device Font settings
+ const ImplMacFontData* mpMacFontData;
+ ImplMacTextStyle* mpMacTextStyle;
+ RGBAColor maTextColor;
+ /// allows text to be rendered without antialiasing
+ bool mbNonAntialiasedText;
+
#endif
virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap );
@@ -204,6 +217,9 @@ public:
#ifdef IOS
bool CheckContext();
CGContextRef GetContext();
+ bool GetRawFontData( const PhysicalFontFace* pFontData,
+ std::vector<unsigned char>& rBuffer,
+ bool* pJustCFF );
#endif
};
diff --git a/vcl/inc/headless/svpvd.hxx b/vcl/inc/headless/svpvd.hxx
index 1785b85..8650a01 100644
--- a/vcl/inc/headless/svpvd.hxx
+++ b/vcl/inc/headless/svpvd.hxx
@@ -25,6 +25,10 @@
#include <list>
+#ifdef IOS
+#define SvpSalGraphics AquaSalGraphics
+#endif
+
class SvpSalGraphics;
class SvpSalVirtualDevice : public SalVirtualDevice, public SvpElement
diff --git a/vcl/inc/saldatabasic.hxx b/vcl/inc/saldatabasic.hxx
index b12415d..42d95d7 100644
--- a/vcl/inc/saldatabasic.hxx
+++ b/vcl/inc/saldatabasic.hxx
@@ -27,7 +27,7 @@
#include "vcl/dllapi.h"
#ifdef IOS
-#include "coretext/salcoretextfontutils.hxx"
+#include "coretext/salgdi2.h"
#endif
namespace psp
More information about the Libreoffice-commits
mailing list