Rebased ref, commits from common ancestor: commit 14979bbb886643a34d48097bfefd0db1efce62e0 Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 07:17:00 2016 +0200
Drop ComplexDisabled flags that does nothing There is no such thing as simple text layout in this brave new world. Change-Id: I641b7efa5ec8fdd9839c291e7f2fdb736361ef1e diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 900cada..b47d09f 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -262,7 +262,7 @@ namespace drawinglayer if(rTextCandidate.getFontAttribute().getRTL()) { - ComplexTextLayoutFlags nRTLLayoutMode(nOldLayoutMode & ~ComplexTextLayoutFlags(ComplexTextLayoutFlags::ComplexDisabled|ComplexTextLayoutFlags::BiDiStrong)); + ComplexTextLayoutFlags nRTLLayoutMode(nOldLayoutMode & ~ComplexTextLayoutFlags(ComplexTextLayoutFlags::BiDiStrong)); nRTLLayoutMode |= ComplexTextLayoutFlags::BiDiRtl|ComplexTextLayoutFlags::TextOriginLeft; mpOutputDevice->SetLayoutMode(nRTLLayoutMode); } diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index 2331fe1..463582b 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -679,8 +679,6 @@ bool ImpEditEngine::CreateLines( sal_Int32 nPara, sal_uInt32 nStartPosY ) } } - // SW disables ComplexTextLayoutFlags::ComplexDisabled, so maybe I have to enable it... - // Saving both layout mode and language (since I'm potentially changing both) GetRefDevice()->Push( PushFlags::TEXTLAYOUTMODE|PushFlags::TEXTLANGUAGE ); @@ -4255,14 +4253,14 @@ void ImpEditEngine::ImplInitLayoutMode( OutputDevice* pOutDev, sal_Int32 nPara, if ( !bCTL && !bR2L) { - // No CTL/Bidi checking necessary - nLayoutMode |= ( ComplexTextLayoutFlags::ComplexDisabled | ComplexTextLayoutFlags::BiDiStrong ); + // No Bidi checking necessary + nLayoutMode |= ComplexTextLayoutFlags::BiDiStrong; } else { - // CTL/Bidi checking necessary + // Bidi checking necessary // Don't use BIDI_STRONG, VCL must do some checks. - nLayoutMode &= ~ComplexTextLayoutFlags( ComplexTextLayoutFlags::ComplexDisabled | ComplexTextLayoutFlags::BiDiStrong ); + nLayoutMode &= ~ComplexTextLayoutFlags( ComplexTextLayoutFlags::BiDiStrong ); if ( bR2L ) nLayoutMode |= ComplexTextLayoutFlags::BiDiRtl|ComplexTextLayoutFlags::TextOriginLeft; diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index a77e881..3e50f60 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -955,7 +955,7 @@ void Outliner::PaintBullet( sal_Int32 nPara, const Point& rStartPos, // VCL will take care of brackets and so on... ComplexTextLayoutFlags nLayoutMode = pOutDev->GetLayoutMode(); - nLayoutMode &= ~ComplexTextLayoutFlags(ComplexTextLayoutFlags::BiDiRtl|ComplexTextLayoutFlags::ComplexDisabled|ComplexTextLayoutFlags::BiDiStrong); + nLayoutMode &= ~ComplexTextLayoutFlags(ComplexTextLayoutFlags::BiDiRtl|ComplexTextLayoutFlags::BiDiStrong); if ( bRightToLeftPara ) nLayoutMode |= ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::TextOriginLeft | ComplexTextLayoutFlags::BiDiStrong; pOutDev->SetLayoutMode( nLayoutMode ); diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 15bdb8f..7cdda54 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -137,7 +137,6 @@ enum class SalLayoutFlags KerningPairs = 0x0010, KerningAsian = 0x0020, Vertical = 0x0040, - ComplexDisabled = 0x0100, EnableLigatures = 0x0200, SubstituteDigits = 0x0400, KashidaJustification = 0x0800, @@ -145,7 +144,7 @@ enum class SalLayoutFlags }; namespace o3tl { - template<> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0x2f77> {}; + template<> struct typed_flags<SalLayoutFlags> : is_typed_flags<SalLayoutFlags, 0x2e77> {}; } typedef std::vector< Rectangle > MetricVector; diff --git a/include/vcl/outdevstate.hxx b/include/vcl/outdevstate.hxx index 4a509a1..c1f42f6 100644 --- a/include/vcl/outdevstate.hxx +++ b/include/vcl/outdevstate.hxx @@ -67,11 +67,10 @@ enum class ComplexTextLayoutFlags BiDiStrong = 0x0002, TextOriginLeft = 0x0004, TextOriginRight = 0x0008, - ComplexDisabled = 0x0100, LigaturesEnabled = 0x0200 }; namespace o3tl { - template<> struct typed_flags<ComplexTextLayoutFlags> : is_typed_flags<ComplexTextLayoutFlags, 0x030f> {}; + template<> struct typed_flags<ComplexTextLayoutFlags> : is_typed_flags<ComplexTextLayoutFlags, 0x020f> {}; } class OutDevState diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 4ba1f23..afaa2bf 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -2938,7 +2938,7 @@ void TextEngine::ImpInitLayoutMode( OutputDevice* pOutDev ) { ComplexTextLayoutFlags nLayoutMode = pOutDev->GetLayoutMode(); - nLayoutMode &= ~ComplexTextLayoutFlags(ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::ComplexDisabled | ComplexTextLayoutFlags::BiDiStrong ); + nLayoutMode &= ~ComplexTextLayoutFlags(ComplexTextLayoutFlags::BiDiRtl | ComplexTextLayoutFlags::BiDiStrong ); pOutDev->SetLayoutMode( nLayoutMode ); } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index a8833b2..da551d7 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -9416,7 +9416,7 @@ void PDFWriterImpl::drawStrikeoutChar( const Point& rPos, long nWidth, FontStrik // strikeout string is left aligned non-CTL text ComplexTextLayoutFlags nOrigTLM = m_pReferenceDevice->GetLayoutMode(); - m_pReferenceDevice->SetLayoutMode( ComplexTextLayoutFlags::BiDiStrong|ComplexTextLayoutFlags::ComplexDisabled ); + m_pReferenceDevice->SetLayoutMode(ComplexTextLayoutFlags::BiDiStrong); push( PushFlags::CLIPREGION ); FontMetric aRefDevFontMetric = m_pReferenceDevice->GetFontMetric(); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 90c0108..7f8ff11 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -71,7 +71,6 @@ std::ostream &operator <<(std::ostream& s, ImplLayoutArgs &rArgs) TEST(KerningPairs); TEST(KerningAsian); TEST(Vertical); - TEST(ComplexDisabled); TEST(EnableLigatures); TEST(SubstituteDigits); TEST(KashidaJustification); diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index c94b21d..73fc0a0 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1209,50 +1209,6 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr, if( mnTextLayoutMode & ComplexTextLayoutFlags::LigaturesEnabled ) nLayoutFlags |= SalLayoutFlags::EnableLigatures; - else if( mnTextLayoutMode & ComplexTextLayoutFlags::ComplexDisabled ) - nLayoutFlags |= SalLayoutFlags::ComplexDisabled; - else - { - // disable CTL for non-CTL text - const sal_Unicode* pStr = rStr.getStr() + nMinIndex; - const sal_Unicode* pEnd = rStr.getStr() + nEndIndex; - bool bIsCJKIdeograph = false; - for( ; pStr < pEnd; ++pStr ) - { - if (pStr + 1 < pEnd && rtl::isHighSurrogate(pStr[0]) && rtl::isLowSurrogate(pStr[1])) - { - sal_uInt32 nCode = rtl::combineSurrogates( pStr[0] , pStr[1] ); - if ( !bIsCJKIdeograph && nCode >= 0xE0100 && nCode < 0xE01F0 ) // Variation Selector Supplements - break; - - if ( nCode >= 0x20000 && nCode <= 0x2CEB0 )// CJK Unified Ideographs Extension B-E - bIsCJKIdeograph = true; - ++pStr; - continue; - } - - if ( ((*pStr >= 0xF900) && (*pStr < 0xFB00)) // CJK Compatibility Ideographs - || ((*pStr >= 0x3400) && (*pStr < 0xA000)) // CJK Unified Ideographs and Extension A - ) - { - bIsCJKIdeograph = true; - continue; - } - - if( ((*pStr >= 0x0300) && (*pStr < 0x0370)) // diacritical marks - || ((*pStr >= 0x0590) && (*pStr < 0x10A0)) // many CTL scripts - || ((*pStr >= 0x1100) && (*pStr < 0x1200)) // hangul jamo - || ((*pStr >= 0x1700) && (*pStr < 0x1900)) // many CTL scripts - || ((*pStr >= 0xFB1D) && (*pStr < 0xFE00)) // middle east presentation - || ((*pStr >= 0xFE70) && (*pStr < 0xFEFF)) // arabic presentation B - || (!bIsCJKIdeograph && (*pStr >= 0xFE00) && (*pStr < 0xFE10)) // variation selectors in BMP - ) - break; - bIsCJKIdeograph = false; - } - if( pStr >= pEnd ) - nLayoutFlags |= SalLayoutFlags::ComplexDisabled; - } if( meTextLanguage ) //TODO: (mnTextLayoutMode & ComplexTextLayoutFlags::SubstituteDigits) { diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index 597e546..9cc84d0 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -630,7 +630,7 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, // strikeout text has to be left aligned ComplexTextLayoutFlags nOrigTLM = mnTextLayoutMode; - mnTextLayoutMode = ComplexTextLayoutFlags::BiDiStrong | ComplexTextLayoutFlags::ComplexDisabled; + mnTextLayoutMode = ComplexTextLayoutFlags::BiDiStrong; pLayout = ImplLayout( aStrikeoutText, 0, aStrikeoutText.getLength() ); mnTextLayoutMode = nOrigTLM; commit 0a670147cc9cb04a638236eea86d6d280ef67890 Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 07:04:27 2016 +0200 Drop a hack for Type 1, the future is here The original issue for reference: https://bz.apache.org/ooo/show_bug.cgi?id=36691 Change-Id: I3b68c2c9f7cb94445875ef5a005e73dcfe65fa3a diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 1f5b83d..a8833b2 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -8621,18 +8621,6 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool } else aUnicodes.push_back(rText[pGlyphs[i]->mnCharPos]); - // #i36691# hack that is needed because currently the pGlyphs[] - // argument is ignored for embeddable fonts and so the layout - // engine's glyph work is ignored (i.e. char mirroring) - // TODO: a real solution would be to map the layout engine's - // glyphid (i.e. FreeType's synthetic glyphid for a Type1 font) - // back to unicode and then to embeddable font's encoding - if( (getReferenceDevice()->GetLayoutMode() & ComplexTextLayoutFlags::BiDiRtl) != ComplexTextLayoutFlags::Default ) - { - size_t nI = aUnicodes.size()-1; - for( int n = 0; n < nChars; n++, nI-- ) - aUnicodes[nI] = static_cast<sal_Ucs>(GetMirroredChar(aUnicodes[nI])); - } } else aUnicodes.push_back( 0 ); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 877d7e5..90c0108 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -133,12 +133,6 @@ std::ostream &operator <<(std::ostream& s, ImplLayoutArgs &rArgs) return s; } -sal_UCS4 GetMirroredChar( sal_UCS4 nChar ) -{ - nChar = u_charMirror( nChar ); - return nChar; -} - sal_UCS4 GetLocalizedChar( sal_UCS4 nChar, LanguageType eLang ) { // currently only conversion from ASCII digits is interesting commit 49f1bade213b4b28788732d3d93e79902d29bfa9 Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 07:00:02 2016 +0200 Drop SalLayout::IsSpacingGlyph() Replace it with a check from ICU that actually makes sense. Change-Id: Ie8789444a967420d58f5575f42bc45677bfa96a1 diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index ee41051..447cc39 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -182,8 +182,6 @@ public: virtual bool GetOutline( SalGraphics&, basegfx::B2DPolyPolygonVector& ) const; virtual bool GetBoundRect( SalGraphics&, Rectangle& ) const; - static bool IsSpacingGlyph( sal_GlyphId ); - // reference counting void Release() const; @@ -321,13 +319,15 @@ public: IS_RTL_GLYPH = 0x002, IS_DIACRITIC = 0x004, IS_VERTICAL = 0x008, - ALLOW_KASHIDA = 0X010 + IS_SPACING = 0x010, + ALLOW_KASHIDA = 0x020 }; bool IsClusterStart() const { return ((mnFlags & IS_IN_CLUSTER) == 0); } bool IsRTLGlyph() const { return ((mnFlags & IS_RTL_GLYPH) != 0); } bool IsDiacritic() const { return ((mnFlags & IS_DIACRITIC) != 0); } bool IsVertical() const { return ((mnFlags & IS_VERTICAL) != 0); } + bool IsSpacing() const { return ((mnFlags & IS_SPACING) != 0); } bool AllowKashida() const { return ((mnFlags & ALLOW_KASHIDA) != 0); } }; diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 27394c7..2c059ef 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -600,10 +600,13 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs) if (u_getIntPropertyValue(aChar, UCHAR_GENERAL_CATEGORY) == U_NON_SPACING_MARK) nGlyphFlags |= GlyphItem::IS_DIACRITIC; + if (u_isUWhiteSpace(aChar)) + nGlyphFlags |= GlyphItem::IS_SPACING; + if ((aSubRun.maScript == HB_SCRIPT_ARABIC || aSubRun.maScript == HB_SCRIPT_SYRIAC) && HB_DIRECTION_IS_BACKWARD(aSubRun.maDirection) && - !u_isUWhiteSpace(aChar)) + (nGlyphFlags & GlyphItem::IS_SPACING) == 0) { nGlyphFlags |= GlyphItem::ALLOW_KASHIDA; rArgs.mnFlags |= SalLayoutFlags::KashidaJustification; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 34bc0d5..1f5b83d 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -8706,7 +8706,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool int nStart = 0; while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart)) { - if (!SalLayout::IsSpacingGlyph(pGlyph->maGlyphId)) + if (!pGlyph->IsSpacing()) { if( !nWidth ) aStartPt = aPos; @@ -8803,7 +8803,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool int nStart = 0; while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart)) { - if (!SalLayout::IsSpacingGlyph(pGlyph->maGlyphId)) + if (pGlyph->IsSpacing()) { Point aAdjOffset = aOffset; aAdjOffset.X() += (pGlyph->mnNewWidth - nEmphWidth) / 2; diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 1567d60..877d7e5 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -722,16 +722,6 @@ bool SalLayout::GetBoundRect( SalGraphics& rSalGraphics, Rectangle& rRect ) cons return bRet; } -// FIXME: This function is just broken, it assumes any glyph at index 3 in the -// font is space, which though common is not a hard requirement and not the -// only glyph for space characters. Fix the call sites and fix them. -bool SalLayout::IsSpacingGlyph( sal_GlyphId nGlyph ) -{ - bool bRet = false; - bRet = (nGlyph == 3); - return bRet; -} - GenericSalLayout::GenericSalLayout() {} diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 3820d42..fe54a3d 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1303,7 +1303,7 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout ) if (!mpGraphics->GetGlyphBoundRect(*pGlyph, aRectangle ) ) continue; - if (!SalLayout::IsSpacingGlyph(pGlyph->maGlyphId)) + if (!pGlyph->IsSpacing()) { Point aAdjPoint = aOffset; aAdjPoint.X() += aRectangle.Left() + (aRectangle.GetWidth() - nEmphasisWidth) / 2; diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index de16c79..597e546 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -757,7 +757,7 @@ void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, FontStrikeout eStri while (!rSalLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart)) { // calculate the boundaries of each word - if (!SalLayout::IsSpacingGlyph(pGlyph->maGlyphId)) + if (!pGlyph->IsSpacing()) { if( !nWidth ) { commit 290d8ac1981f1b7fe2763abde878fe4935d83055 Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 06:37:42 2016 +0200 Remove noop SalLayout::UseCommonLayout() Change-Id: Ifc143f33bc4e087726ada1e3b1b5182bf830b0cb diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index b74e57e..ee41051 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -196,8 +196,6 @@ public: virtual std::shared_ptr<vcl::TextLayoutCache> CreateTextLayoutCache(OUString const&) const; - static bool UseCommonLayout(); - protected: // used by layout engines SalLayout(); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 6593f70..1567d60 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -732,11 +732,6 @@ bool SalLayout::IsSpacingGlyph( sal_GlyphId nGlyph ) return bRet; } -bool SalLayout::UseCommonLayout() -{ - return true; -} - GenericSalLayout::GenericSalLayout() {} diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index c99f569..5563bb9 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -1062,10 +1062,9 @@ int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe, if (nFontType & RASTER_FONTTYPE) return 1; - // Ignore font formats not supported by CommonSalLayout. - if (SalLayout::UseCommonLayout()) - if ((pMetric->ntmTm.ntmFlags & NTM_TYPE1) || (pMetric->ntmTm.ntmFlags & NTM_MULTIPLEMASTER)) - return 1; + // Ignore font formats we donât support. + if ((pMetric->ntmTm.ntmFlags & NTM_TYPE1) || (pMetric->ntmTm.ntmFlags & NTM_MULTIPLEMASTER)) + return 1; WinFontFace* pData = ImplLogMetricToDevFontDataW( pLogFont, &(pMetric->ntmTm), nFontType ); pData->SetFontId( sal_IntPtr( pInfo->mnFontCount++ ) ); commit 7865888d0bad102b6818e3ed5e88b70d08362c6e Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 06:21:23 2016 +0200 GF_VERT is only used once, move it Change-Id: I15289eecfbfb29ee549470a7f752e0c7fd9f811e diff --git a/vcl/inc/salglyphid.hxx b/vcl/inc/salglyphid.hxx index 6d5480e..8047d50 100644 --- a/vcl/inc/salglyphid.hxx +++ b/vcl/inc/salglyphid.hxx @@ -22,14 +22,6 @@ typedef sal_uInt32 sal_GlyphId; // Glyph Flags -#ifdef _WIN32 -// caution !!! -#define GF_VERT 0x02000000 -// GF_VERT is only for windows implementation -// (win/gdi/salgdi3.cxx, win/gdi/winlayout.cxx) -// don't use this elsewhere !!! -#endif - #define GF_FONTMASK 0xF0000000 #define GF_FONTSHIFT 28 diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index d3ad988..565192a 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -296,7 +296,7 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, bGlyphs = true; WORD glyphWStr[] = { pGlyph->maGlyphId }; if (pGlyph->IsVertical()) - glyphWStr[0] |= GF_VERT; + glyphWStr[0] |= 0x02000000; // A (undocumented?) GDI flag for vertical glyphs ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr); } commit 91b60c5f183b4d0d107e7f9b4bf24105e2d14f8c Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 05:57:40 2016 +0200 sal_GlyphId is a simple glyph id now No more cleverness. Change-Id: I760c602802961b37728c6987c4ade14fb02ca034 diff --git a/vcl/inc/salglyphid.hxx b/vcl/inc/salglyphid.hxx index 72cf4fc..6d5480e 100644 --- a/vcl/inc/salglyphid.hxx +++ b/vcl/inc/salglyphid.hxx @@ -19,13 +19,9 @@ #ifndef INCLUDED_VCL_INC_SALGLYPHID_HXX #define INCLUDED_VCL_INC_SALGLYPHID_HXX -// TODO: sal_GlyphId should become a class... typedef sal_uInt32 sal_GlyphId; // Glyph Flags -#define GF_FLAGMASK 0xFF800000 -#define GF_IDXMASK ~GF_FLAGMASK - #ifdef _WIN32 // caution !!! #define GF_VERT 0x02000000 diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index 52062eb..f5ea6db 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -154,7 +154,7 @@ SAL_WNODEPRECATED_DECLARATIONS_POP bool CoreTextStyle::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect ) const { - CGGlyph nCGGlyph = rGlyph.maGlyphId & GF_IDXMASK; + CGGlyph nCGGlyph = rGlyph.maGlyphId; CTFontRef aCTFontRef = static_cast<CTFontRef>(CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName )); SAL_WNODEPRECATED_DECLARATIONS_PUSH //TODO: 10.11 kCTFontDefaultOrientation @@ -229,7 +229,7 @@ bool CoreTextStyle::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPol { rResult.clear(); - CGGlyph nCGGlyph = rGlyph.maGlyphId & GF_IDXMASK; + CGGlyph nCGGlyph = rGlyph.maGlyphId; CTFontRef pCTFont = static_cast<CTFontRef>(CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName )); CGPathRef xPath = CTFontCreatePathForGlyph( pCTFont, nCGGlyph, nullptr ); if (!xPath) diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index 0df8955..e38f5d2 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -442,7 +442,7 @@ void AquaSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout) } } - aGlyphIds.push_back(pGlyph->maGlyphId & GF_IDXMASK); + aGlyphIds.push_back(pGlyph->maGlyphId); aGlyphPos.push_back(aGCPos); aGlyphOrientation.push_back(bUprightGlyph); } diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx index 57a930a..2222e06 100644 --- a/vcl/quartz/salgdicommon.cxx +++ b/vcl/quartz/salgdicommon.cxx @@ -274,7 +274,7 @@ bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile, { aTempEncs[i] = pEncoding[i]; - sal_GlyphId aGlyphId(pGlyphIds[i] & GF_IDXMASK); + sal_GlyphId aGlyphId(pGlyphIds[i]); aShortIDs[i] = static_cast<sal_uInt16>( aGlyphId ); if( !aGlyphId && nNotDef < 0 ) { diff --git a/vcl/source/gdi/pdffontcache.cxx b/vcl/source/gdi/pdffontcache.cxx index 8140db7..67a8614 100644 --- a/vcl/source/gdi/pdffontcache.cxx +++ b/vcl/source/gdi/pdffontcache.cxx @@ -58,10 +58,8 @@ sal_Int32 PDFFontCache::getGlyphWidth( const PhysicalFontFace* pFont, sal_GlyphI } if( ! rFontData.m_nWidths.empty() ) { - sal_GlyphId nIndex = nGlyph; - nIndex &= GF_IDXMASK; - if( nIndex < rFontData.m_nWidths.size() ) - nWidth = rFontData.m_nWidths[ nIndex ]; + if (nGlyph < rFontData.m_nWidths.size()) + nWidth = rFontData.m_nWidths[nGlyph]; } return nWidth; } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 4770644..34bc0d5 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -8144,7 +8144,7 @@ void PDFWriterImpl::registerGlyphs( int nGlyphs, sal_Ucs* pCurUnicode = pUnicodes; for( int i = 0; i < nGlyphs; pCurUnicode += pUnicodesPerGlyph[i] , i++ ) { - const int nFontGlyphId = pGlyphs[i]->maGlyphId & GF_IDXMASK; + const int nFontGlyphId = pGlyphs[i]->maGlyphId; const PhysicalFontFace* pCurrentFont = pFallbackFonts[i] ? pFallbackFonts[i] : pDevFont; FontSubset& rSubset = m_aSubsets[ pCurrentFont ]; diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 3029bc7..6593f70 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -728,7 +728,7 @@ bool SalLayout::GetBoundRect( SalGraphics& rSalGraphics, Rectangle& rRect ) cons bool SalLayout::IsSpacingGlyph( sal_GlyphId nGlyph ) { bool bRet = false; - bRet = ((nGlyph & GF_IDXMASK) == 3); + bRet = (nGlyph == 3); return bRet; } @@ -978,7 +978,6 @@ int GenericSalLayout::GetNextGlyphs(int nLen, const GlyphItem** pGlyphs, // find more glyphs which can be merged into one drawing instruction int nCount = 0; long nYPos = pGlyphIter->maLinearPos.Y(); - long nOldFlags = pGlyphIter->maGlyphId; for(;;) { // update return data with glyph info @@ -1008,12 +1007,6 @@ int GenericSalLayout::GetNextGlyphs(int nLen, const GlyphItem** pGlyphs, int n = pGlyphIter->mnCharPos; if( (n < mnMinCharPos) || (mnEndCharPos <= n) ) break; - - // stop when glyph flags change - if( (nOldFlags ^ pGlyphIter->maGlyphId) & GF_FLAGMASK ) - break; - - nOldFlags = pGlyphIter->maGlyphId; // &GF_FLAGMASK not needed for test above } aRelativePos.X() /= mnUnitsPerPixel; diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 2d66822..c94b21d 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -2394,7 +2394,7 @@ SystemTextLayoutData OutputDevice::GetSysTextLayoutData(const Point& rStartPt, c while (pLayout->GetNextGlyphs(1, &pGlyph, aPos, nStart)) { SystemGlyphData aSystemGlyph; - aSystemGlyph.index = static_cast<unsigned long> (pGlyph->maGlyphId & GF_IDXMASK); + aSystemGlyph.index = static_cast<unsigned long> (pGlyph->maGlyphId); aSystemGlyph.x = aPos.X(); aSystemGlyph.y = aPos.Y(); int nLevel = pGlyph->mnFallbackLevel; diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index ec025b8..b3f6165 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -178,7 +178,7 @@ void CairoTextRender::DrawTextLayout(const CommonSalLayout& rLayout) while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart)) { cairo_glyph_t aGlyph; - aGlyph.index = pGlyph->maGlyphId & GF_IDXMASK; + aGlyph.index = pGlyph->maGlyphId; aGlyph.x = aPos.X(); aGlyph.y = aPos.Y(); cairo_glyphs.push_back(aGlyph); diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index 039ffad..cc5683c 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -685,7 +685,7 @@ void FreetypeFont::InitGlyphData(const GlyphItem& rGlyph, GlyphData& rGD ) const { FT_Activate_Size( maSizeFT ); - FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.maGlyphId & GF_IDXMASK, mnLoadFlags); + FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.maGlyphId, mnLoadFlags); if( rc != FT_Err_Ok ) { @@ -998,7 +998,7 @@ bool FreetypeFont::GetGlyphOutline(const GlyphItem& rGlyph, nLoadFlags |= FT_LOAD_TARGET_LIGHT; #endif - FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.maGlyphId & GF_IDXMASK, nLoadFlags); + FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.maGlyphId, nLoadFlags); if( rc != FT_Err_Ok ) return false; diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx index b41f7c0..103fc54 100644 --- a/vcl/unx/generic/glyphs/glyphcache.cxx +++ b/vcl/unx/generic/glyphs/glyphcache.cxx @@ -307,7 +307,7 @@ long FreetypeFont::Release() const const GlyphMetric& FreetypeFont::GetGlyphMetric(const GlyphItem& rGlyph) { // usually the GlyphData is cached - GlyphList::iterator it = maGlyphList.find(rGlyph.maGlyphId & GF_IDXMASK); + GlyphList::iterator it = maGlyphList.find(rGlyph.maGlyphId); if( it != maGlyphList.end() ) { GlyphData& rGlyphData = it->second; GlyphCache::GetInstance().UsingGlyph( *this, rGlyphData ); @@ -315,7 +315,7 @@ const GlyphMetric& FreetypeFont::GetGlyphMetric(const GlyphItem& rGlyph) } // sometimes not => we need to create and initialize it ourselves - GlyphData& rGlyphData = maGlyphList[rGlyph.maGlyphId & GF_IDXMASK]; + GlyphData& rGlyphData = maGlyphList[rGlyph.maGlyphId]; mnBytesUsed += sizeof( GlyphData ); InitGlyphData(rGlyph, rGlyphData); GlyphCache::GetInstance().AddedGlyph( *this, rGlyphData ); diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 30f22e6..c99f569 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -1369,7 +1369,7 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect GLYPHMETRICS aGM; aGM.gmptGlyphOrigin.x = aGM.gmptGlyphOrigin.y = 0; aGM.gmBlackBoxX = aGM.gmBlackBoxY = 0; - DWORD nSize = ::GetGlyphOutlineW(hDC, rGlyph.maGlyphId & GF_IDXMASK, nGGOFlags, &aGM, 0, nullptr, &aMat); + DWORD nSize = ::GetGlyphOutlineW(hDC, rGlyph.maGlyphId, nGGOFlags, &aGM, 0, nullptr, &aMat); if( nSize == GDI_ERROR ) return false; @@ -1398,14 +1398,14 @@ bool WinSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph, nGGOFlags |= GGO_GLYPH_INDEX; GLYPHMETRICS aGlyphMetrics; - const DWORD nSize1 = ::GetGlyphOutlineW(hDC, rGlyph.maGlyphId & GF_IDXMASK, nGGOFlags, &aGlyphMetrics, 0, nullptr, &aMat); + const DWORD nSize1 = ::GetGlyphOutlineW(hDC, rGlyph.maGlyphId, nGGOFlags, &aGlyphMetrics, 0, nullptr, &aMat); if( !nSize1 ) // blank glyphs are ok return true; else if( nSize1 == GDI_ERROR ) return false; BYTE* pData = new BYTE[ nSize1 ]; - const DWORD nSize2 = ::GetGlyphOutlineW(hDC, rGlyph.maGlyphId & GF_IDXMASK, nGGOFlags, + const DWORD nSize2 = ::GetGlyphOutlineW(hDC, rGlyph.maGlyphId, nGGOFlags, &aGlyphMetrics, nSize1, pData, &aMat ); if( nSize1 != nSize2 ) @@ -1662,23 +1662,13 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, { pWinFontData->UpdateFromHDC( getHDC() ); FontCharMapRef xFontCharMap = pWinFontData->GetFontCharMap(); - - sal_GlyphId aRealGlyphIds[ 256 ]; - for( int i = 0; i < nGlyphCount; ++i ) - { - // TODO: remap notdef glyph if needed - // TODO: use GDI's GetGlyphIndices instead? Does it handle GSUB properly? - sal_GlyphId aGlyphId = pGlyphIds[i] & GF_IDXMASK; - aRealGlyphIds[i] = aGlyphId; - } - xFontCharMap = nullptr; // provide a font subset from the CFF-table FILE* pOutFile = fopen( aToFile.getStr(), "wb" ); rInfo.LoadFont( FontSubsetInfo::CFF_FONT, aRawCffData.get(), aRawCffData.size() ); bool bRC = rInfo.CreateFontSubset( FontSubsetInfo::TYPE1_PFB, pOutFile, nullptr, - aRealGlyphIds, pEncoding, nGlyphCount, pGlyphWidths ); + pGlyphIds, pEncoding, nGlyphCount, pGlyphWidths ); fclose( pOutFile ); return bRC; } @@ -1718,8 +1708,7 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, for( i = 0; i < nGlyphCount; ++i ) { aTempEncs[i] = pEncoding[i]; - sal_GlyphId aGlyphId = pGlyphIds[i] & GF_IDXMASK; - aShortIDs[i] = static_cast<sal_uInt16>( aGlyphId ); + aShortIDs[i] = static_cast<sal_uInt16>(pGlyphIds[i]); if( !aGlyphId ) if( nNotDef < 0 ) nNotDef = i; // first NotDef glyph found diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 2f66709..d3ad988 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -294,7 +294,7 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, while (rLayout.GetNextGlyphs(1, &pGlyph, *pPos, *pGetNextGlypInfo)) { bGlyphs = true; - WORD glyphWStr[] = { pGlyph->maGlyphId & GF_IDXMASK }; + WORD glyphWStr[] = { pGlyph->maGlyphId }; if (pGlyph->IsVertical()) glyphWStr[0] |= GF_VERT; ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr); @@ -391,7 +391,7 @@ bool D2DWriteTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, mpFontFace, mlfEmHeight, 1, - { pGlyph->maGlyphId & GF_IDXMASK }, + { pGlyph->maGlyphId }, { pGlyph->mnNewWidth }, { { 0.0f, 0.0f } }, false, @@ -542,7 +542,7 @@ bool D2DWriteTextOutRenderer::GetDWriteInkBox(SalLayout const &rLayout, Rectangl while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart)) { positions.push_back(aPos); - indices.push_back(pGlyph->maGlyphId & GF_IDXMASK); + indices.push_back(pGlyph->maGlyphId); vertical.push_back(pGlyph->IsVertical()); } commit df163307c75e0f94e135fc542f6d20a628f35a75 Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 05:38:08 2016 +0200 Donât encode font fallback level in the glyph id Change-Id: I747d969c3c1dc42b1a3b5d12d06fed3af9a64675 diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 15e2b6e..b74e57e 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -281,6 +281,8 @@ struct GlyphItem sal_GlyphId maGlyphId; Point maLinearPos; // absolute position of non rotated string + int mnFallbackLevel; + public: GlyphItem() : mnFlags(0) @@ -289,6 +291,7 @@ public: , mnNewWidth(0) , mnXOffset(0) , maGlyphId(0) + , mnFallbackLevel(0) { } GlyphItem( int nCharPos, sal_GlyphId aGlyphId, const Point& rLinearPos, @@ -300,6 +303,7 @@ public: , mnXOffset(0) , maGlyphId(aGlyphId) , maLinearPos(rLinearPos) + , mnFallbackLevel(0) { } GlyphItem( int nCharPos, sal_GlyphId aGlyphId, const Point& rLinearPos, @@ -311,6 +315,7 @@ public: , mnXOffset(nXOffset) , maGlyphId(aGlyphId) , maLinearPos(rLinearPos) + , mnFallbackLevel(0) { } enum { diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index c8f9c75..0df8955 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -384,7 +384,7 @@ bool AquaSalGraphics::AddTempDevFont( PhysicalFontCollection*, bool AquaSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rPolyPoly) { - const int nFallbackLevel = rGlyph.maGlyphId >> GF_FONTSHIFT; + const int nFallbackLevel = rGlyph.mnFallbackLevel; if (nFallbackLevel < MAX_FALLBACK && mpTextStyle[nFallbackLevel]) { const bool bRC = mpTextStyle[nFallbackLevel]->GetGlyphOutline(rGlyph, rPolyPoly); @@ -395,7 +395,7 @@ bool AquaSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyP bool AquaSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect ) { - const int nFallbackLevel = rGlyph.maGlyphId >> GF_FONTSHIFT; + const int nFallbackLevel = rGlyph.mnFallbackLevel; if (nFallbackLevel < MAX_FALLBACK && mpTextStyle[nFallbackLevel]) { const bool bRC = mpTextStyle[nFallbackLevel]->GetGlyphBoundRect(rGlyph, rRect); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 6f3b082..3029bc7 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -1615,8 +1615,8 @@ int MultiSalLayout::GetNextGlyphs(int nLen, const GlyphItem** pGlyphs, nStart |= nFontTag; for( int i = 0; i < nRetVal; ++i ) { - // FIXME: This is ugly! - const_cast<GlyphItem*>(pGlyphs[i])->maGlyphId |= nFontTag; + // FIXME: This cast is ugly! + const_cast<GlyphItem*>(pGlyphs[i])->mnFallbackLevel = nLevel; if( pFallbackFonts ) { pFallbackFonts[ i ] = mpFallbackFonts[ nLevel ]; diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index 93deefe..2d66822 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -2397,7 +2397,7 @@ SystemTextLayoutData OutputDevice::GetSysTextLayoutData(const Point& rStartPt, c aSystemGlyph.index = static_cast<unsigned long> (pGlyph->maGlyphId & GF_IDXMASK); aSystemGlyph.x = aPos.X(); aSystemGlyph.y = aPos.Y(); - int nLevel = (pGlyph->maGlyphId & GF_FONTMASK) >> GF_FONTSHIFT; + int nLevel = pGlyph->mnFallbackLevel; aSystemGlyph.fallbacklevel = nLevel < MAX_FALLBACK ? nLevel : 0; aSysLayoutData.rGlyphData.push_back(aSystemGlyph); } diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index a188ad3..ec025b8 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -427,7 +427,7 @@ void CairoTextRender::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nF bool CairoTextRender::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect) { - const int nLevel = rGlyph.maGlyphId >> GF_FONTSHIFT; + const int nLevel = rGlyph.mnFallbackLevel; if( nLevel >= MAX_FALLBACK ) return false; @@ -457,7 +457,7 @@ bool CairoTextRender::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRec bool CairoTextRender::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rPolyPoly ) { - const int nLevel = rGlyph.maGlyphId >> GF_FONTSHIFT; + const int nLevel = rGlyph.mnFallbackLevel; if( nLevel >= MAX_FALLBACK ) return false; diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index 2c6d106..c2ffe9b 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -760,7 +760,7 @@ void GenPspGraphics::GetFontMetric(ImplFontMetricDataRef& rxFontMetric, int nFal bool GenPspGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect) { - const int nLevel = rGlyph.maGlyphId >> GF_FONTSHIFT; + const int nLevel = rGlyph.mnFallbackLevel; if( nLevel >= MAX_FALLBACK ) return false; @@ -776,7 +776,7 @@ bool GenPspGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect bool GenPspGraphics::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rB2DPolyPoly ) { - const int nLevel = rGlyph.maGlyphId >> GF_FONTSHIFT; + const int nLevel = rGlyph.mnFallbackLevel; if( nLevel >= MAX_FALLBACK ) return false; commit 793b7d22efd93be0a804a4b453cc9b84ea4b6c53 Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 04:46:32 2016 +0200 Minor Change-Id: I5e3480b647ec3851e9125188d9cd04227050dc6d diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 10e625b..15e2b6e 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -283,29 +283,35 @@ struct GlyphItem public: GlyphItem() - : mnFlags(0) - , mnCharPos(0) - , mnOrigWidth(0) - , mnNewWidth(0) - , mnXOffset(0) - , maGlyphId(0) - {} + : mnFlags(0) + , mnCharPos(0) + , mnOrigWidth(0) + , mnNewWidth(0) + , mnXOffset(0) + , maGlyphId(0) + { } GlyphItem( int nCharPos, sal_GlyphId aGlyphId, const Point& rLinearPos, long nFlags, int nOrigWidth ) - : mnFlags(nFlags), mnCharPos(nCharPos), - mnOrigWidth(nOrigWidth), mnNewWidth(nOrigWidth), - mnXOffset(0), - maGlyphId(aGlyphId), maLinearPos(rLinearPos) - {} + : mnFlags(nFlags) + , mnCharPos(nCharPos) + , mnOrigWidth(nOrigWidth) + , mnNewWidth(nOrigWidth) + , mnXOffset(0) + , maGlyphId(aGlyphId) + , maLinearPos(rLinearPos) + { } GlyphItem( int nCharPos, sal_GlyphId aGlyphId, const Point& rLinearPos, long nFlags, int nOrigWidth, int nXOffset ) - : mnFlags(nFlags), mnCharPos(nCharPos), - mnOrigWidth(nOrigWidth), mnNewWidth(nOrigWidth), - mnXOffset(nXOffset), - maGlyphId(aGlyphId), maLinearPos(rLinearPos) - {} + : mnFlags(nFlags) + , mnCharPos(nCharPos) + , mnOrigWidth(nOrigWidth) + , mnNewWidth(nOrigWidth) + , mnXOffset(nXOffset) + , maGlyphId(aGlyphId) + , maLinearPos(rLinearPos) + { } enum { IS_IN_CLUSTER = 0x001, commit 09c3abb360d7044a63056732f6e7da1c95d0f651 Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 04:39:16 2016 +0200 Donât encode the vertical flag in the glyph id Change-Id: I00485dd4d42004e4eaa163a9e6ad0a43cf98a30a diff --git a/vcl/inc/salglyphid.hxx b/vcl/inc/salglyphid.hxx index dbfd95e..72cf4fc 100644 --- a/vcl/inc/salglyphid.hxx +++ b/vcl/inc/salglyphid.hxx @@ -23,10 +23,8 @@ typedef sal_uInt32 sal_GlyphId; // Glyph Flags -#define GF_NONE 0x00000000 #define GF_FLAGMASK 0xFF800000 #define GF_IDXMASK ~GF_FLAGMASK -#define GF_ROTL 0x01000000 #ifdef _WIN32 // caution !!! @@ -36,8 +34,6 @@ typedef sal_uInt32 sal_GlyphId; // don't use this elsewhere !!! #endif -#define GF_ROTR 0x03000000 -#define GF_ROTMASK 0x03000000 #define GF_FONTMASK 0xF0000000 #define GF_FONTSHIFT 28 diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 21a1e0b..10e625b 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -311,12 +311,14 @@ public: IS_IN_CLUSTER = 0x001, IS_RTL_GLYPH = 0x002, IS_DIACRITIC = 0x004, + IS_VERTICAL = 0x008, ALLOW_KASHIDA = 0X010 }; bool IsClusterStart() const { return ((mnFlags & IS_IN_CLUSTER) == 0); } bool IsRTLGlyph() const { return ((mnFlags & IS_RTL_GLYPH) != 0); } bool IsDiacritic() const { return ((mnFlags & IS_DIACRITIC) != 0); } + bool IsVertical() const { return ((mnFlags & IS_VERTICAL) != 0); } bool AllowKashida() const { return ((mnFlags & ALLOW_KASHIDA) != 0); } }; diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx index bf9cf3c..36155d7 100644 --- a/vcl/inc/unx/glyphcache.hxx +++ b/vcl/inc/unx/glyphcache.hxx @@ -179,7 +179,7 @@ private: void GarbageCollect( long ); void ReleaseFromGarbageCollect(); - void ApplyGlyphTransform( int nGlyphFlags, FT_GlyphRec_* ) const; + void ApplyGlyphTransform(bool bVertical, FT_Glyph) const; typedef std::unordered_map<int,GlyphData> GlyphList; mutable GlyphList maGlyphList; diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index 300ee4d..52062eb 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -162,8 +162,8 @@ bool CoreTextStyle::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect SAL_WNODEPRECATED_DECLARATIONS_POP CGRect aCGRect = CTFontGetBoundingRectsForGlyphs(aCTFontRef, aFontOrientation, &nCGGlyph, nullptr, 1); - // Apply font rotation to non-upright glyphs. - if (mfFontRotation && !(rGlyph.maGlyphId & GF_ROTMASK)) + // Apply font rotation to non-vertical glyphs. + if (mfFontRotation && !rGlyph.IsVertical()) aCGRect = CGRectApplyAffineTransform(aCGRect, CGAffineTransformMakeRotation(mfFontRotation)); rRect.Left() = lrint( aCGRect.origin.x ); diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index c593b88..c8f9c75 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -429,7 +429,7 @@ void AquaSalGraphics::DrawTextLayout(const CommonSalLayout& rLayout) if (rStyle.mfFontRotation) { - if ((pGlyph->maGlyphId & GF_ROTMASK) == GF_ROTL) + if (pGlyph->IsVertical()) { bUprightGlyph = true; // Adjust the position of upright (vertical) glyphs. diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index eda090f..27394c7 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -618,7 +618,7 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs) // See http://unicode.org/reports/tr50/#vo if (vcl::GetVerticalOrientation(aChar) != VerticalOrientation::TransformedRotated || IsVerticalAlternate(pHbGlyphInfos[i].codepoint)) - nGlyphIndex |= GF_ROTL; + nGlyphFlags |= GlyphItem::IS_VERTICAL; nAdvance = -pHbPositions[i].y_advance; nXOffset = pHbPositions[i].y_offset; diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index d5d454a..4770644 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -8183,10 +8183,9 @@ void PDFWriterImpl::registerGlyphs( int nGlyphs, } if (!getReferenceDevice()->AcquireGraphics()) return; - const bool bVertical = ((pGlyphs[i]->maGlyphId & GF_ROTMASK) != 0); pGlyphWidths[i] = m_aFontCache.getGlyphWidth( pCurrentFont, nFontGlyphId, - bVertical, + pGlyphs[i]->IsVertical(), pGraphics ); } } @@ -8293,7 +8292,7 @@ void PDFWriterImpl::drawVerticalGlyphs( double fSkewA = 0.0; Point aDeltaPos; - if( ( rGlyphs[i].m_nGlyphId & GF_ROTMASK ) == GF_ROTL ) + if (rGlyphs[i].m_bVertical) { fDeltaAngle = M_PI/2.0; aDeltaPos.X() = m_pReferenceDevice->GetFontMetric().GetAscent(); @@ -8303,16 +8302,6 @@ void PDFWriterImpl::drawVerticalGlyphs( fSkewA = -fSkewB; fSkewB = 0.0; } - else if( ( rGlyphs[i].m_nGlyphId & GF_ROTMASK ) == GF_ROTR ) - { - fDeltaAngle = -M_PI/2.0; - aDeltaPos.X() = (int)((double)m_pReferenceDevice->GetFontMetric().GetDescent()*fXScale); - aDeltaPos.Y() = -m_pReferenceDevice->GetFontMetric().GetAscent(); - fYScale = fXScale; - fTempXScale = 1.0; - fSkewA = fSkewB; - fSkewB = 0.0; - } aDeltaPos += (m_pReferenceDevice->PixelToLogic( Point( (int)((double)nXOffset/fXScale), 0 ) ) - m_pReferenceDevice->PixelToLogic( Point() ) ); if( i < rGlyphs.size()-1 ) // #i120627# the text on the Y axis is reversed when export ppt file to PDF format @@ -8661,7 +8650,8 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool pGlyphWidths[i], pGlyphs[i]->maGlyphId, pMappedFontObjects[i], - pMappedGlyphs[i] ) ); + pMappedGlyphs[i], + pGlyphs[i]->IsVertical() ) ); if( bVertical ) aGNGlyphPos.Y() += pGlyphs[i]->mnNewWidth/rLayout.GetUnitsPerPixel(); else diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index 1219089..d0b1188 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -552,14 +552,17 @@ public: sal_Int32 m_nGlyphId; sal_Int32 m_nMappedFontId; sal_uInt8 m_nMappedGlyphId; + bool m_bVertical; PDFGlyph( const Point& rPos, sal_Int32 nNativeWidth, sal_Int32 nGlyphId, sal_Int32 nFontId, - sal_uInt8 nMappedGlyphId ) + sal_uInt8 nMappedGlyphId, + bool bVertical ) : m_aPos( rPos ), m_nNativeWidth( nNativeWidth ), m_nGlyphId( nGlyphId ), - m_nMappedFontId( nFontId ), m_nMappedGlyphId( nMappedGlyphId ) + m_nMappedFontId( nFontId ), m_nMappedGlyphId( nMappedGlyphId ), + m_bVertical(bVertical) {} }; diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index 3d7ca15..a188ad3 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -183,15 +183,10 @@ void CairoTextRender::DrawTextLayout(const CommonSalLayout& rLayout) aGlyph.y = aPos.Y(); cairo_glyphs.push_back(aGlyph); - switch (pGlyph->maGlyphId & GF_ROTMASK) - { - case GF_ROTL: // left - glyph_extrarotation.push_back(1); - break; - default: - glyph_extrarotation.push_back(0); - break; - } + if (pGlyph->IsVertical()) + glyph_extrarotation.push_back(1); + else + glyph_extrarotation.push_back(0); } if (cairo_glyphs.empty()) diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index 2e62abe..039ffad 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -627,10 +627,10 @@ void FreetypeFont::GetFontMetric(ImplFontMetricDataRef& rxTo) const } -void FreetypeFont::ApplyGlyphTransform( int nGlyphFlags, FT_Glyph pGlyphFT ) const +void FreetypeFont::ApplyGlyphTransform(bool bVertical, FT_Glyph pGlyphFT ) const { // shortcut most common case - if (!GetFontSelData().mnOrientation && !nGlyphFlags) + if (!GetFontSelData().mnOrientation && !bVertical) return; const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics; @@ -639,17 +639,19 @@ void FreetypeFont::ApplyGlyphTransform( int nGlyphFlags, FT_Glyph pGlyphFT ) con bool bStretched = false; - switch( nGlyphFlags & GF_ROTMASK ) + if (!bVertical) { - default: // straight + // straight aVector.x = 0; aVector.y = 0; aMatrix.xx = +mnCos; aMatrix.yy = +mnCos; aMatrix.xy = -mnSin; aMatrix.yx = +mnSin; - break; - case GF_ROTL: // left + } + else + { + // left bStretched = (mfStretch != 1.0); aVector.x = (FT_Pos)(+rMetrics.descender * mfStretch); aVector.y = -rMetrics.ascender; @@ -657,17 +659,6 @@ void FreetypeFont::ApplyGlyphTransform( int nGlyphFlags, FT_Glyph pGlyphFT ) con aMatrix.yy = (FT_Pos)(-mnSin * mfStretch); aMatrix.xy = (FT_Pos)(-mnCos * mfStretch); aMatrix.yx = (FT_Pos)(+mnCos / mfStretch); - break; - case GF_ROTR: // right - bStretched = (mfStretch != 1.0); - aVector.x = -maFaceFT->glyph->metrics.horiAdvance; - aVector.x += (FT_Pos)(rMetrics.descender * mnSin/65536.0); - aVector.y = (FT_Pos)(-rMetrics.descender * mfStretch * mnCos/65536.0); - aMatrix.xx = (FT_Pos)(+mnSin / mfStretch); - aMatrix.yy = (FT_Pos)(+mnSin * mfStretch); - aMatrix.xy = (FT_Pos)(+mnCos * mfStretch); - aMatrix.yx = (FT_Pos)(-mnCos / mfStretch); - break; } if( pGlyphFT->format != FT_GLYPH_FORMAT_BITMAP ) @@ -694,8 +685,6 @@ void FreetypeFont::InitGlyphData(const GlyphItem& rGlyph, GlyphData& rGD ) const { FT_Activate_Size( maSizeFT ); - int nGlyphFlags = rGlyph.maGlyphId & GF_FLAGMASK;; - FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.maGlyphId & GF_IDXMASK, mnLoadFlags); if( rc != FT_Err_Ok ) @@ -712,7 +701,7 @@ void FreetypeFont::InitGlyphData(const GlyphItem& rGlyph, GlyphData& rGD ) const FT_Glyph pGlyphFT; FT_Get_Glyph( maFaceFT->glyph, &pGlyphFT ); - ApplyGlyphTransform( nGlyphFlags, pGlyphFT ); + ApplyGlyphTransform(rGlyph.IsVertical(), pGlyphFT); FT_BBox aBbox; FT_Glyph_Get_CBox( pGlyphFT, FT_GLYPH_BBOX_PIXELS, &aBbox ); @@ -1002,8 +991,6 @@ bool FreetypeFont::GetGlyphOutline(const GlyphItem& rGlyph, rB2DPolyPoly.clear(); - int nGlyphFlags = rGlyph.maGlyphId & GF_FLAGMASK;; - FT_Int nLoadFlags = FT_LOAD_DEFAULT | FT_LOAD_IGNORE_TRANSFORM; #ifdef FT_LOAD_TARGET_LIGHT @@ -1049,7 +1036,7 @@ bool FreetypeFont::GetGlyphOutline(const GlyphItem& rGlyph, tools::PolyPolygon aToolPolyPolygon; PolyArgs aPolyArg( aToolPolyPolygon, nMaxPoints ); - /*int nAngle =*/ ApplyGlyphTransform( nGlyphFlags, pGlyphFT ); + ApplyGlyphTransform(rGlyph.IsVertical(), pGlyphFT); FT_Outline_Funcs aFuncs; aFuncs.move_to = &FT_move_to; diff --git a/vcl/unx/generic/print/text_gfx.cxx b/vcl/unx/generic/print/text_gfx.cxx index 2f04c72..36f1776 100644 --- a/vcl/unx/generic/print/text_gfx.cxx +++ b/vcl/unx/generic/print/text_gfx.cxx @@ -102,7 +102,7 @@ void PrinterGfx::DrawGlyph(const Point& rPoint, aPoint = Point( 0, 0 ); } - if (mbTextVertical && (rGlyph.maGlyphId & GF_ROTMASK) != GF_NONE) + if (mbTextVertical && rGlyph.IsVertical()) { sal_Int32 nTextHeight = maVirtualStatus.mnTextHeight; sal_Int32 nTextWidth = maVirtualStatus.mnTextWidth ? maVirtualStatus.mnTextWidth : maVirtualStatus.mnTextHeight; diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 3f9dcaa..2f66709 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -295,7 +295,7 @@ bool ExTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, { bGlyphs = true; WORD glyphWStr[] = { pGlyph->maGlyphId & GF_IDXMASK }; - if ((pGlyph->maGlyphId & GF_ROTMASK) == GF_ROTL) + if (pGlyph->IsVertical()) glyphWStr[0] |= GF_VERT; ExtTextOutW(hDC, pPos->X(), pPos->Y(), ETO_GLYPH_INDEX, nullptr, LPCWSTR(&glyphWStr), 1, nullptr); } @@ -398,7 +398,7 @@ bool D2DWriteTextOutRenderer::operator ()(SalLayout const &rLayout, HDC hDC, 0 }; - if (bVertical && (pGlyph->maGlyphId & GF_ROTMASK) != GF_ROTL) + if (bVertical && !pGlyph->IsVertical()) { D2D1MakeRotateMatrix(90.0f, baseline, &aRotTrans); mpRT->SetTransform(aOrigTrans * aRotTrans); @@ -543,7 +543,7 @@ bool D2DWriteTextOutRenderer::GetDWriteInkBox(SalLayout const &rLayout, Rectangl { positions.push_back(aPos); indices.push_back(pGlyph->maGlyphId & GF_IDXMASK); - vertical.push_back((pGlyph->maGlyphId & GF_ROTMASK) == GF_ROTL); + vertical.push_back(pGlyph->IsVertical()); } auto aBoxes = GetGlyphInkBoxes(indices.data(), indices.data() + indices.size()); commit 7324e9f51370092eb59d16f2ca17a00dcef5734c Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 04:13:26 2016 +0200 Use GlyphItem in more places Also simplify code to what is actually being used. Change-Id: Ic640ea7f3e426e3f5f4f9fef30d774fe5ac111ff diff --git a/vcl/inc/unx/printergfx.hxx b/vcl/inc/unx/printergfx.hxx index 871469e8..cb9a6c8 100644 --- a/vcl/inc/unx/printergfx.hxx +++ b/vcl/inc/unx/printergfx.hxx @@ -249,21 +249,16 @@ public: void PSLineTo(const Point& rPoint ); void PSPointOp (const Point& rPoint, const sal_Char* pOperator); void PSHexString (const unsigned char* pString, sal_Int16 nLen); - void PSDeltaArray (const sal_Int32 *pArray, sal_Int16 nEntries); - void PSShowText (const unsigned char* pString, - sal_Int16 nGlyphs, sal_Int16 nBytes, - const sal_Int32* pDeltaArray = nullptr); + void PSShowGlyph (const unsigned char nGlyphId); void PSComment (const sal_Char* pComment ); void OnEndJob (); void writeResources( osl::File* pFile, std::list< OString >& rSuppliedFonts ); PrintFontManager& GetFontMgr () { return mrFontMgr; } - void drawGlyphs( const Point& rPoint, - sal_GlyphId* pGlyphIds, - sal_Unicode* pUnicodes, - sal_Int16 nLen, - sal_Int32* pDeltaArray ); + void drawGlyph(const Point& rPoint, + sal_GlyphId aGlyphId, + sal_Int32 nDelta); public: PrinterGfx(); ~PrinterGfx(); @@ -343,12 +338,9 @@ public: void SetTextColor (PrinterColor& rTextColor) { maTextColor = rTextColor; } - // for CTL - void DrawGlyphs( const Point& rPoint, - sal_GlyphId* pGlyphIds, - sal_Unicode* pUnicodes, - sal_Int16 nLen, - sal_Int32* pDeltaArray ); + void DrawGlyph(const Point& rPoint, + const GlyphItem& rGlyph, + sal_Int32 nDelta); }; diff --git a/vcl/unx/generic/print/common_gfx.cxx b/vcl/unx/generic/print/common_gfx.cxx index 793bd3c..d8b199b 100644 --- a/vcl/unx/generic/print/common_gfx.cxx +++ b/vcl/unx/generic/print/common_gfx.cxx @@ -1012,39 +1012,8 @@ PrinterGfx::PSHexString (const unsigned char* pString, sal_Int16 nLen) WritePS (mpPageBody, pHexString, nChar); } -/* psshowtext helper routines: draw an array for xshow ps operator */ void -PrinterGfx::PSDeltaArray (const sal_Int32 *pArray, sal_Int16 nEntries) -{ - sal_Char pPSArray [128]; - sal_Int32 nChar = 0; - - nChar = psp::appendStr ("[", pPSArray + nChar); - nChar += psp::getValueOf (pArray[0], pPSArray + nChar); - - for (int i = 1; i < nEntries; i++) - { - if (nChar >= (nMaxTextColumn - 1)) - { - nChar += psp::appendStr ("\n", pPSArray + nChar); - WritePS (mpPageBody, pPSArray, nChar); - nChar = 0; - } - - nChar += psp::appendStr (" ", pPSArray + nChar); - nChar += psp::getValueOf (pArray[i] - pArray[i-1], pPSArray + nChar); - } - - nChar += psp::appendStr (" 0]\n", pPSArray + nChar); - WritePS (mpPageBody, pPSArray, nChar); -} - -/* the DrawText equivalent, pDeltaArray may be NULL. For Type1 fonts or single byte - * fonts in general nBytes and nGlyphs is the same. For printer resident Composite - * fonts it may be different (these fonts may be SJIS encoded for example) */ -void -PrinterGfx::PSShowText (const unsigned char* pStr, sal_Int16 nGlyphs, sal_Int16 nBytes, - const sal_Int32* pDeltaArray) +PrinterGfx::PSShowGlyph (const unsigned char nGlyphId) { PSSetColor (maTextColor); PSSetColor (); @@ -1066,31 +1035,17 @@ PrinterGfx::PSShowText (const unsigned char* pStr, sal_Int16 nGlyphs, sal_Int16 nLW = nLW < maVirtualStatus.mnTextHeight ? nLW : maVirtualStatus.mnTextHeight; psp::getValueOfDouble( pBuffer, (double)nLW / 30.0 ); } + // dispatch to the drawing method - if (pDeltaArray == nullptr) - { - PSHexString (pStr, nBytes); + PSHexString (&nGlyphId, 1); - if( maVirtualStatus.mbArtBold ) - { - WritePS( mpPageBody, pBuffer ); - WritePS( mpPageBody, " bshow\n" ); - } - else - WritePS (mpPageBody, "show\n"); - } - else + if( maVirtualStatus.mbArtBold ) { - PSHexString (pStr, nBytes); - PSDeltaArray (pDeltaArray, nGlyphs - 1); - if( maVirtualStatus.mbArtBold ) - { - WritePS( mpPageBody, pBuffer ); - WritePS( mpPageBody, " bxshow\n" ); - } - else - WritePS (mpPageBody, "xshow\n"); + WritePS( mpPageBody, pBuffer ); + WritePS( mpPageBody, " bshow\n" ); } + else + WritePS (mpPageBody, "show\n"); // restore the user coordinate system if (mnTextAngle != 0) diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index ee0ecb2..2c6d106 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -596,9 +596,8 @@ void GenPspGraphics::DrawTextLayout(const CommonSalLayout& rLayout) int nStart = 0; while (rLayout.GetNextGlyphs(1, &pGlyph, aPos, nStart)) { - sal_GlyphId aGlyphId = pGlyph->maGlyphId & (GF_IDXMASK | GF_ROTMASK); sal_Int32 aIdx = pGlyph->mnNewWidth / rLayout.GetUnitsPerPixel(); - m_pPrinterGfx->DrawGlyphs(aPos, &aGlyphId, { 0 }, 1, &aIdx); + m_pPrinterGfx->DrawGlyph(aPos, *pGlyph, aIdx); } } diff --git a/vcl/unx/generic/print/glyphset.cxx b/vcl/unx/generic/print/glyphset.cxx index 7d8ee2e..3641fe1 100644 --- a/vcl/unx/generic/print/glyphset.cxx +++ b/vcl/unx/generic/print/glyphset.cxx @@ -62,13 +62,12 @@ GlyphSet::~GlyphSet () bool GlyphSet::GetGlyphID ( sal_GlyphId nGlyph, - sal_Unicode nUnicode, unsigned char* nOutGlyphID, sal_Int32* nOutGlyphSetID ) { return LookupGlyphID (nGlyph, nOutGlyphID, nOutGlyphSetID) - || AddGlyphID (nGlyph, nUnicode, nOutGlyphID, nOutGlyphSetID); + || AddGlyphID (nGlyph, nOutGlyphID, nOutGlyphSetID); } bool @@ -102,17 +101,6 @@ GlyphSet::LookupGlyphID ( return false; } -unsigned char -GlyphSet::GetSymbolMapping (sal_Unicode nUnicodeChar) -{ - if (0x0000 < nUnicodeChar && nUnicodeChar < 0x0100) - return (unsigned char)nUnicodeChar; - if (0xf000 < nUnicodeChar && nUnicodeChar < 0xf100) - return (unsigned char)nUnicodeChar; - - return 0; -} - void GlyphSet::AddNotdef (glyph_map_t &rGlyphMap) { @@ -123,17 +111,10 @@ GlyphSet::AddNotdef (glyph_map_t &rGlyphMap) bool GlyphSet::AddGlyphID ( sal_GlyphId nGlyph, - sal_Unicode nUnicode, unsigned char* nOutGlyphID, sal_Int32* nOutGlyphSetID ) { - unsigned char nMappedChar = 0; - - // XXX important: avoid to reencode type1 symbol fonts - if (mnBaseEncoding == RTL_TEXTENCODING_SYMBOL) - nMappedChar = GetSymbolMapping (nUnicode); - // create an empty glyphmap that is reserved for unencoded symbol glyphs, // and a second map that takes any other if (maGlyphList.empty()) @@ -144,35 +125,20 @@ GlyphSet::AddGlyphID ( maGlyphList.push_back (aMapp); } // if the last map is full, create a new one - if ((!nMappedChar) && (maGlyphList.back().size() == 255)) + if (maGlyphList.back().size() == 255) { glyph_map_t aMap; maGlyphList.push_back (aMap); } - // insert a new glyph in the font subset - if (nMappedChar) - { - // always put symbol glyphs into the first map, map them on itself - glyph_map_t& aGlyphSet = maGlyphList.front(); - AddNotdef (aGlyphSet); + glyph_map_t& aGlyphSet = maGlyphList.back(); + AddNotdef (aGlyphSet); - aGlyphSet [nGlyph] = nMappedChar; - *nOutGlyphSetID = 1; - *nOutGlyphID = nMappedChar; - } - else - { - // other glyphs are just appended to the list - glyph_map_t& aGlyphSet = maGlyphList.back(); - AddNotdef (aGlyphSet); + int nSize = aGlyphSet.size(); - int nSize = aGlyphSet.size(); - - aGlyphSet [nGlyph] = nSize; - *nOutGlyphSetID = maGlyphList.size(); - *nOutGlyphID = aGlyphSet [nGlyph]; - } + aGlyphSet [nGlyph] = nSize; + *nOutGlyphSetID = maGlyphList.size(); + *nOutGlyphID = aGlyphSet [nGlyph]; return true; } @@ -211,76 +177,26 @@ GlyphSet::GetReencodedFontName (rtl_TextEncoding nEnc, const OString &rFontName) } } -void GlyphSet::DrawGlyphs( - PrinterGfx& rGfx, - const Point& rPoint, - const sal_GlyphId* pGlyphIds, - const sal_Unicode* pUnicodes, - sal_Int16 nLen, - const sal_Int32* pDeltaArray) +void GlyphSet::DrawGlyph(PrinterGfx& rGfx, + const Point& rPoint, + const sal_GlyphId nGlyphId, + const sal_Int32 nDelta) { - unsigned char *pGlyphID = static_cast<unsigned char*>(alloca (nLen * sizeof(unsigned char))); - sal_Int32 *pGlyphSetID = static_cast<sal_Int32*>(alloca (nLen * sizeof(sal_Int32))); - std::set< sal_Int32 > aGlyphSet; - - // convert unicode to font glyph id and font subset - for (int nChar = 0; nChar < nLen; nChar++) - { - GetGlyphID (pGlyphIds[nChar], pUnicodes[nChar], pGlyphID + nChar, pGlyphSetID + nChar); - aGlyphSet.insert (pGlyphSetID[nChar]); - } - - // loop over all glyph sets to detect substrings that can be shown together - // without changing the postscript font - sal_Int32 *pDeltaSubset = static_cast<sal_Int32*>(alloca (nLen * sizeof(sal_Int32))); - unsigned char *pGlyphSubset = static_cast<unsigned char*>(alloca (nLen * sizeof(unsigned char))); - - std::set< sal_Int32 >::iterator aSet; - for (aSet = aGlyphSet.begin(); aSet != aGlyphSet.end(); ++aSet) - { - Point aPoint = rPoint; - sal_Int32 nOffset = 0; - sal_Int32 nGlyphs = 0; - sal_Int32 nChar; - - // get offset to first glyph - for (nChar = 0; (nChar < nLen) && (pGlyphSetID[nChar] != *aSet); nChar++) - { - nOffset = pDeltaArray [nChar]; - } + unsigned char nGlyphID; + sal_Int32 nGlyphSetID; - // loop over all chars to extract those that share the current glyph set - for (nChar = 0; nChar < nLen; nChar++) - { - if (pGlyphSetID[nChar] == *aSet) - { - pGlyphSubset [nGlyphs] = pGlyphID [nChar]; - // the offset to the next glyph is determined by the glyph in - // front of the next glyph with the same glyphset id - // most often, this will be the current glyph - while ((nChar + 1) < nLen) - { - if (pGlyphSetID[nChar + 1] == *aSet) - break; - else - nChar += 1; - } - pDeltaSubset [nGlyphs] = pDeltaArray[nChar] - nOffset; - - nGlyphs += 1; - } - } + // convert to font glyph id and font subset + GetGlyphID (nGlyphId, &nGlyphID, &nGlyphSetID); - // show the text using the PrinterGfx text api - aPoint.Move (nOffset, 0); + // show the text using the PrinterGfx text api + Point aPoint = rPoint; + aPoint.Move (nDelta, 0); - OString aGlyphSetName; - aGlyphSetName = GetGlyphSetName(*aSet); + OString aGlyphSetName = GetGlyphSetName(nGlyphSetID); - rGfx.PSSetFont (aGlyphSetName, RTL_TEXTENCODING_DONTKNOW); - rGfx.PSMoveTo (aPoint); - rGfx.PSShowText (pGlyphSubset, nGlyphs, nGlyphs, nGlyphs > 1 ? pDeltaSubset : nullptr); - } + rGfx.PSSetFont (aGlyphSetName, RTL_TEXTENCODING_DONTKNOW); + rGfx.PSMoveTo (rPoint); + rGfx.PSShowGlyph(nGlyphID); } struct EncEntry diff --git a/vcl/unx/generic/print/glyphset.hxx b/vcl/unx/generic/print/glyphset.hxx index fccaacc..01ae348 100644 --- a/vcl/unx/generic/print/glyphset.hxx +++ b/vcl/unx/generic/print/glyphset.hxx @@ -52,15 +52,14 @@ private: OString GetGlyphSetName (sal_Int32 nGlyphSetID); - bool GetGlyphID (sal_GlyphId nGlyphId, sal_Unicode nUnicode, + bool GetGlyphID (sal_GlyphId nGlyphId, unsigned char* nOutGlyphID, sal_Int32* nOutGlyphSetID); bool LookupGlyphID (sal_GlyphId nGlyphId, unsigned char* nOutGlyphID, sal_Int32* nOutGlyphSetID); - bool AddGlyphID (sal_GlyphId nGlyphId, sal_Unicode nUnicode, + bool AddGlyphID (sal_GlyphId nGlyphId, unsigned char* nOutGlyphID, sal_Int32* nOutGlyphSetID); static void AddNotdef (glyph_map_t &rGlyphMap); - static unsigned char GetSymbolMapping (sal_Unicode nUnicodeChar); public: @@ -76,12 +75,10 @@ public: const OString &rFontName); bool IsVertical () { return mbVertical;} - void DrawGlyphs (PrinterGfx& rGfx, - const Point& rPoint, - const sal_GlyphId* pGlyphIds, - const sal_Unicode* pUnicodes, - sal_Int16 nLen, - const sal_Int32* pDeltaArray); + void DrawGlyph (PrinterGfx& rGfx, + const Point& rPoint, + const sal_GlyphId nGlyphId, + const sal_Int32 nDelta); void PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42, std::list< OString >& rSuppliedFonts ); }; diff --git a/vcl/unx/generic/print/text_gfx.cxx b/vcl/unx/generic/print/text_gfx.cxx index bff561a..2f04c72 100644 --- a/vcl/unx/generic/print/text_gfx.cxx +++ b/vcl/unx/generic/print/text_gfx.cxx @@ -59,13 +59,9 @@ void PrinterGfx::SetFont( mbTextVertical = bVertical; } -void PrinterGfx::drawGlyphs( - const Point& rPoint, - sal_GlyphId* pGlyphIds, - sal_Unicode* pUnicodes, - sal_Int16 nLen, - sal_Int32* pDeltaArray - ) +void PrinterGfx::drawGlyph(const Point& rPoint, + sal_GlyphId aGlyphId, + sal_Int32 nDelta) { // draw the string @@ -75,7 +71,7 @@ void PrinterGfx::drawGlyphs( if ( ((*aIter).GetFontID() == mnFontID) && ((*aIter).IsVertical() == mbTextVertical)) { - (*aIter).DrawGlyphs (*this, rPoint, pGlyphIds, pUnicodes, nLen, pDeltaArray); + (*aIter).DrawGlyph (*this, rPoint, aGlyphId, nDelta); break; } @@ -83,21 +79,14 @@ void PrinterGfx::drawGlyphs( if (aIter == maPS3Font.end()) { maPS3Font.push_back (GlyphSet(mnFontID, mbTextVertical)); - maPS3Font.back().DrawGlyphs (*this, rPoint, pGlyphIds, pUnicodes, nLen, pDeltaArray); + maPS3Font.back().DrawGlyph (*this, rPoint, aGlyphId, nDelta); } } -void PrinterGfx::DrawGlyphs( - const Point& rPoint, - sal_GlyphId* pGlyphIds, - sal_Unicode* pUnicodes, - sal_Int16 nLen, - sal_Int32* pDeltaArray - ) +void PrinterGfx::DrawGlyph(const Point& rPoint, + const GlyphItem& rGlyph, + sal_Int32 nDelta) { - if( nLen <= 0 ) - return; - // move and rotate the user coordinate system // avoid the gsave/grestore for the simple cases since it allows // reuse of the current font if it hasn't changed @@ -113,17 +102,8 @@ void PrinterGfx::DrawGlyphs( aPoint = Point( 0, 0 ); } - if( mbTextVertical ) + if (mbTextVertical && (rGlyph.maGlyphId & GF_ROTMASK) != GF_NONE) { - // vertical glyphs can have an additional rotation ... sigh. - // so break up text in chunks of normal glyphs and print out - // specially rotated glyphs extra - sal_GlyphId* pTempGlyphIds = static_cast<sal_GlyphId*>(alloca(sizeof(sal_Int32)*nLen)); - sal_Int32* pTempDelta = static_cast<sal_Int32*>(alloca(sizeof(sal_Int32)*nLen)); - sal_Unicode* pTempUnicodes = static_cast<sal_Unicode*>(alloca(sizeof(sal_Unicode)*nLen)); - sal_Int16 nTempLen = 0; - sal_Int32 nTempFirstDelta = 0; - Point aRotPoint; sal_Int32 nTextHeight = maVirtualStatus.mnTextHeight; sal_Int32 nTextWidth = maVirtualStatus.mnTextWidth ? maVirtualStatus.mnTextWidth : maVirtualStatus.mnTextHeight; sal_Int32 nAscend = mrFontMgr.getFontAscend( mnFontID ); @@ -132,77 +112,26 @@ void PrinterGfx::DrawGlyphs( nDescend = nDescend * nTextHeight / 1000; nAscend = nAscend * nTextHeight / 1000; - for( sal_Int16 i = 0; i < nLen; i++ ) - { - const sal_GlyphId nRot = pGlyphIds[i] & GF_ROTMASK; - if( nRot == GF_NONE ) - { - pTempUnicodes[nTempLen] = pUnicodes[i]; - pTempGlyphIds[nTempLen] = pGlyphIds[i]; - if( nTempLen > 0 ) - pTempDelta[nTempLen-1] = pDeltaArray[i-1]-nTempFirstDelta; - else - { - // the first element in pDeltaArray shows - // the offset of the second character - // so if the first glyph is normal - // then we do not need to move the delta indices - // else we have to move them down by one and - // recalculate aPoint and all deltas - if( i != 0 ) - nTempFirstDelta = pDeltaArray[ i-1 ]; - } - nTempLen++; - } - else - { - sal_Int32 nOffset = i > 0 ? pDeltaArray[i-1] : 0; - sal_Int32 nRotAngle = 0; - switch( nRot ) - { - case GF_ROTR: - nRotAngle = 2700; - aRotPoint = Point( -nAscend*nTextWidth/nTextHeight, -nDescend*nTextWidth/nTextHeight - nOffset ); - break; - case GF_ROTL: - nRotAngle = 900; - aRotPoint = Point( -nDescend*nTextWidth/nTextHeight, nOffset + nAscend*nTextWidth/nTextHeight ); - break; - } - sal_GlyphId nRotGlyphId = pGlyphIds[i]; - sal_Unicode nRotUnicode = pUnicodes[i]; - sal_Int32 nRotDelta = 0; - - // transform matrix to new individual direction - PSGSave (); - GraphicsStatus aSaveStatus = maVirtualStatus; - if( nRot != 2 ) // switch font aspect - { - maVirtualStatus.mnTextWidth = nTextHeight; - maVirtualStatus.mnTextHeight = nTextWidth; - } - if( aPoint.X() || aPoint.Y() ) - PSTranslate( aPoint ); - PSRotate (nRotAngle); - // draw the rotated glyph - drawGlyphs( aRotPoint, &nRotGlyphId, &nRotUnicode, 1, &nRotDelta ); - - // restore previous state - maVirtualStatus = aSaveStatus; - PSGRestore(); - } - } - - pGlyphIds = pTempGlyphIds; - pUnicodes = pTempUnicodes; - pDeltaArray = pTempDelta; - nLen = nTempLen; + Point aRotPoint = Point( -nDescend*nTextWidth/nTextHeight, nAscend*nTextWidth/nTextHeight ); - aPoint.X() += nTempFirstDelta; + // transform matrix to new individual direction + PSGSave (); + GraphicsStatus aSaveStatus = maVirtualStatus; + // switch font aspect + maVirtualStatus.mnTextWidth = nTextHeight; + maVirtualStatus.mnTextHeight = nTextWidth; + if( aPoint.X() || aPoint.Y() ) + PSTranslate( aPoint ); + PSRotate (900); + // draw the rotated glyph + drawGlyph(aRotPoint, rGlyph.maGlyphId, 0); + + // restore previous state + maVirtualStatus = aSaveStatus; + PSGRestore(); } - - if( nLen > 0 ) - drawGlyphs( aPoint, pGlyphIds, pUnicodes, nLen, pDeltaArray ); + else + drawGlyph(aPoint, rGlyph.maGlyphId, nDelta); // restore the user coordinate system if (nCurrentTextAngle != 0) commit cb6a1ed243f166f6ce10adbb723bb09afa6be227 Author: Khaled Hosny <khaledho...@eglug.org> Date: Thu Dec 8 03:01:14 2016 +0200 Use GlyphItem in more places Change-Id: Ic0dd8c0311161271817eb9a3f454d00a319e43a8 diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx index 63a10f5..bdb97a9 100644 --- a/vcl/headless/svptext.cxx +++ b/vcl/headless/svptext.cxx @@ -91,14 +91,14 @@ void SvpSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont, m_aTextRenderImpl.GetGlyphWidths(pFont, bVertical, rWidths, rUnicodeEnc); } -bool SvpSalGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect ) +bool SvpSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect) { - return m_aTextRenderImpl.GetGlyphBoundRect(aGlyphId, rRect); + return m_aTextRenderImpl.GetGlyphBoundRect(rGlyph, rRect); } -bool SvpSalGraphics::GetGlyphOutline( sal_GlyphId aGlyphId, basegfx::B2DPolyPolygon& rPolyPoly ) +bool SvpSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rPolyPoly) { - return m_aTextRenderImpl.GetGlyphOutline(aGlyphId, rPolyPoly); + return m_aTextRenderImpl.GetGlyphOutline(rGlyph, rPolyPoly); } SalLayout* SvpSalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ) diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index a8f3362..8083474 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -159,8 +159,8 @@ public: bool bVertical, std::vector< sal_Int32 >& rWidths, Ucs2UIntMap& rUnicodeEnc ) override; - virtual bool GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& ) override; - virtual bool GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& ) override; + virtual bool GetGlyphBoundRect(const GlyphItem&, Rectangle&) override; + virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override; virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override; virtual void DrawTextLayout( const CommonSalLayout& ) override; virtual bool supportsOperation( OutDevSupportType ) const override; diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 6ea5bf3..086266d 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -89,8 +89,8 @@ public: ~CoreTextStyle( void ); void GetFontMetric( ImplFontMetricDataRef& ) const; - bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) const; - bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) const; + bool GetGlyphBoundRect(const GlyphItem&, Rectangle&) const; + bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) const; hb_font_t* GetHbFont() const { return mpHbFont; } void SetHbFont(hb_font_t* pHbFont) const { mpHbFont = pHbFont; } @@ -375,8 +375,8 @@ public: std::vector< sal_Int32 >& rWidths, Ucs2UIntMap& rUnicodeEnc ) override; - virtual bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) override; - virtual bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) override; + virtual bool GetGlyphBoundRect(const GlyphItem&, Rectangle&) override; + virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override; virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override; virtual void DrawTextLayout( const CommonSalLayout& ) override; diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index ef228fa..9ca2433 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -191,8 +191,8 @@ public: std::vector< sal_Int32 >& rWidths, Ucs2UIntMap& rUnicodeEnc ) = 0; - virtual bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) = 0; - virtual bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) = 0; + virtual bool GetGlyphBoundRect(const GlyphItem&, Rectangle&) = 0; + virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) = 0; virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) = 0; virtual void DrawTextLayout( const CommonSalLayout& ) = 0; diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx index 9417345..1b04725 100644 --- a/vcl/inc/textrender.hxx +++ b/vcl/inc/textrender.hxx @@ -59,8 +59,8 @@ public: std::vector< sal_Int32 >& rWidths, Ucs2UIntMap& rUnicodeEnc ) = 0; - virtual bool GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& ) = 0; - virtual bool GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& ) = 0; + virtual bool GetGlyphBoundRect(const GlyphItem&, Rectangle&) = 0; + virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) = 0; virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) = 0; virtual void DrawTextLayout(const CommonSalLayout&) = 0; #if ENABLE_CAIRO_CANVAS diff --git a/vcl/inc/unx/cairotextrender.hxx b/vcl/inc/unx/cairotextrender.hxx index 5fab64a..1cdf405 100644 --- a/vcl/inc/unx/cairotextrender.hxx +++ b/vcl/inc/unx/cairotextrender.hxx @@ -75,8 +75,8 @@ public: std::vector< sal_Int32 >& rWidths, Ucs2UIntMap& rUnicodeEnc ) override; - virtual bool GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& ) override; - virtual bool GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& ) override; + virtual bool GetGlyphBoundRect(const GlyphItem&, Rectangle&) override; + virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override; virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override; virtual void DrawTextLayout(const CommonSalLayout&) override; #if ENABLE_CAIRO_CANVAS diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h index 1dcb7ab..721efd5 100644 --- a/vcl/inc/unx/genpspgraphics.h +++ b/vcl/inc/unx/genpspgraphics.h @@ -115,8 +115,8 @@ public: bool bVertical, std::vector< sal_Int32 >& rWidths, Ucs2UIntMap& rUnicodeEnc ) override; - virtual bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) override; - virtual bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) override; + virtual bool GetGlyphBoundRect(const GlyphItem&, Rectangle&) override; + virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override; virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override; virtual void DrawTextLayout( const CommonSalLayout& ) override; virtual bool supportsOperation( OutDevSupportType ) const override; diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx index 65afd4b..bf9cf3c 100644 --- a/vcl/inc/unx/glyphcache.hxx +++ b/vcl/inc/unx/glyphcache.hxx @@ -157,9 +157,9 @@ public: const FontCharMapRef GetFontCharMap() const; bool GetFontCapabilities(vcl::FontCapabilities &) const; - const GlyphMetric& GetGlyphMetric(sal_GlyphId aGlyphId); + const GlyphMetric& GetGlyphMetric(const GlyphItem& rGlyph); - bool GetGlyphOutline( sal_GlyphId aGlyphId, basegfx::B2DPolyPolygon& ) const; + bool GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon&) const; bool GetAntialiasAdvice() const; hb_font_t* GetHbFont() { return mpHbFont; } void SetHbFont( hb_font_t* pHbFont ) { mpHbFont = pHbFont; } @@ -175,7 +175,7 @@ private: long Release() const; sal_uLong GetByteCount() const { return mnBytesUsed; } - void InitGlyphData( sal_GlyphId, GlyphData& ) const; + void InitGlyphData(const GlyphItem&, GlyphData&) const; void GarbageCollect( long ); void ReleaseFromGarbageCollect(); diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index b3de804..5eb9172 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -140,8 +140,8 @@ public: std::vector< sal_Int32 >& rWidths, Ucs2UIntMap& rUnicodeEnc ) override; - virtual bool GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& ) override; - virtual bool GetGlyphOutline( sal_GlyphId nIndex, basegfx::B2DPolyPolygon& ) override; + virtual bool GetGlyphBoundRect(const GlyphItem&, Rectangle&) override; + virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override; virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override; virtual void DrawTextLayout( const CommonSalLayout& ) override; diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 198c61c..8a493d7 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -377,8 +377,8 @@ public: Ucs2UIntMap& rUnicodeEnc ) override; int GetMinKashidaWidth(); - virtual bool GetGlyphBoundRect( sal_GlyphId, Rectangle& ) override; - virtual bool GetGlyphOutline( sal_GlyphId, basegfx::B2DPolyPolygon& ) override; + virtual bool GetGlyphBoundRect(const GlyphItem&, Rectangle&) override; + virtual bool GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) override; virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ) override; virtual void DrawTextLayout( const CommonSalLayout& ) override; diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index 7677a04..300ee4d 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -152,9 +152,9 @@ SAL_WNODEPRECATED_DECLARATIONS_POP } } -bool CoreTextStyle::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect ) const +bool CoreTextStyle::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect ) const { - CGGlyph nCGGlyph = aGlyphId & GF_IDXMASK; + CGGlyph nCGGlyph = rGlyph.maGlyphId & GF_IDXMASK; CTFontRef aCTFontRef = static_cast<CTFontRef>(CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName )); SAL_WNODEPRECATED_DECLARATIONS_PUSH //TODO: 10.11 kCTFontDefaultOrientation @@ -163,7 +163,7 @@ bool CoreTextStyle::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect ) CGRect aCGRect = CTFontGetBoundingRectsForGlyphs(aCTFontRef, aFontOrientation, &nCGGlyph, nullptr, 1); // Apply font rotation to non-upright glyphs. - if (mfFontRotation && !(aGlyphId & GF_ROTMASK)) + if (mfFontRotation && !(rGlyph.maGlyphId & GF_ROTMASK)) aCGRect = CGRectApplyAffineTransform(aCGRect, CGAffineTransformMakeRotation(mfFontRotation)); rRect.Left() = lrint( aCGRect.origin.x ); @@ -225,11 +225,11 @@ static void MyCGPathApplierFunc( void* pData, const CGPathElement* pElement ) } } -bool CoreTextStyle::GetGlyphOutline( sal_GlyphId aGlyphId, basegfx::B2DPolyPolygon& rResult ) const +bool CoreTextStyle::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rResult) const { rResult.clear(); - CGGlyph nCGGlyph = aGlyphId & GF_IDXMASK; + CGGlyph nCGGlyph = rGlyph.maGlyphId & GF_IDXMASK; CTFontRef pCTFont = static_cast<CTFontRef>(CFDictionaryGetValue( mpStyleDict, kCTFontAttributeName )); CGPathRef xPath = CTFontCreatePathForGlyph( pCTFont, nCGGlyph, nullptr ); if (!xPath) diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index 4b3a63a..c593b88 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -382,23 +382,23 @@ bool AquaSalGraphics::AddTempDevFont( PhysicalFontCollection*, return ::AddTempDevFont(rFontFileURL); } -bool AquaSalGraphics::GetGlyphOutline( sal_GlyphId aGlyphId, basegfx::B2DPolyPolygon& rPolyPoly ) +bool AquaSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rPolyPoly) { - const int nFallbackLevel = aGlyphId >> GF_FONTSHIFT; + const int nFallbackLevel = rGlyph.maGlyphId >> GF_FONTSHIFT; if (nFallbackLevel < MAX_FALLBACK && mpTextStyle[nFallbackLevel]) { - const bool bRC = mpTextStyle[nFallbackLevel]->GetGlyphOutline(aGlyphId, rPolyPoly); + const bool bRC = mpTextStyle[nFallbackLevel]->GetGlyphOutline(rGlyph, rPolyPoly); return bRC; } return false; } -bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect ) +bool AquaSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect ) { - const int nFallbackLevel = aGlyphId >> GF_FONTSHIFT; + const int nFallbackLevel = rGlyph.maGlyphId >> GF_FONTSHIFT; if (nFallbackLevel < MAX_FALLBACK && mpTextStyle[nFallbackLevel]) { - const bool bRC = mpTextStyle[nFallbackLevel]->GetGlyphBoundRect(aGlyphId, rRect); + const bool bRC = mpTextStyle[nFallbackLevel]->GetGlyphBoundRect(rGlyph, rRect); return bRC; } return false; diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 25c1600..6f3b082 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -675,7 +675,7 @@ bool SalLayout::GetOutline( SalGraphics& rSalGraphics, while (GetNextGlyphs(1, &pGlyph, aPos, nStart)) { // get outline of individual glyph, ignoring "empty" glyphs - bool bSuccess = rSalGraphics.GetGlyphOutline(pGlyph->maGlyphId, aGlyphOutline); + bool bSuccess = rSalGraphics.GetGlyphOutline(*pGlyph, aGlyphOutline); bAllOk &= bSuccess; bOneOk |= bSuccess; // only add non-empty outlines @@ -707,7 +707,7 @@ bool SalLayout::GetBoundRect( SalGraphics& rSalGraphics, Rectangle& rRect ) cons while (GetNextGlyphs(1, &pGlyph, aPos, nStart)) { // get bounding rectangle of individual glyph - if (rSalGraphics.GetGlyphBoundRect(pGlyph->maGlyphId, aRectangle)) + if (rSalGraphics.GetGlyphBoundRect(*pGlyph, aRectangle)) { // merge rectangle aRectangle += aPos; diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 71d3f21..3820d42 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1300,7 +1300,7 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout ) int nStart = 0; while (rSalLayout.GetNextGlyphs(1, &pGlyph, aOutPoint, nStart)) { - if (!mpGraphics->GetGlyphBoundRect(pGlyph->maGlyphId, aRectangle ) ) + if (!mpGraphics->GetGlyphBoundRect(*pGlyph, aRectangle ) ) continue; if (!SalLayout::IsSpacingGlyph(pGlyph->maGlyphId)) diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index 501d399..3d7ca15 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -430,9 +430,9 @@ void CairoTextRender::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nF mpFreetypeFont[nFallbackLevel]->GetFontMetric(rxFontMetric); } -bool CairoTextRender::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect ) +bool CairoTextRender::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect) { - const int nLevel = aGlyphId >> GF_FONTSHIFT; + const int nLevel = rGlyph.maGlyphId >> GF_FONTSHIFT; if( nLevel >= MAX_FALLBACK ) return false; @@ -440,8 +440,7 @@ bool CairoTextRender::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect if( !pSF ) return false; - aGlyphId &= GF_IDXMASK; - const GlyphMetric& rGM = pSF->GetGlyphMetric(aGlyphId); + const GlyphMetric& rGM = pSF->GetGlyphMetric(rGlyph); Rectangle aRect( rGM.GetOffset(), rGM.GetSize() ); if ( pSF->mnCos != 0x10000 && pSF->mnSin != 0 ) @@ -460,10 +459,10 @@ bool CairoTextRender::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect return true; } -bool CairoTextRender::GetGlyphOutline( sal_GlyphId aGlyphId, +bool CairoTextRender::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rPolyPoly ) { - const int nLevel = aGlyphId >> GF_FONTSHIFT; + const int nLevel = rGlyph.maGlyphId >> GF_FONTSHIFT; if( nLevel >= MAX_FALLBACK ) return false; @@ -471,8 +470,7 @@ bool CairoTextRender::GetGlyphOutline( sal_GlyphId aGlyphId, if( !pSF ) return false; - aGlyphId &= GF_IDXMASK; - if( pSF->GetGlyphOutline( aGlyphId, rPolyPoly ) ) + if( pSF->GetGlyphOutline(rGlyph, rPolyPoly)) return true; return false; diff --git a/vcl/unx/generic/gdi/font.cxx b/vcl/unx/generic/gdi/font.cxx index 8379c0c..37a3846 100644 --- a/vcl/unx/generic/gdi/font.cxx +++ b/vcl/unx/generic/gdi/font.cxx @@ -106,15 +106,15 @@ X11SalGraphics::GetFontMetric( ImplFontMetricDataRef &rxFontMetric, int nFallbac mxTextRenderImpl->GetFontMetric(rxFontMetric, nFallbackLevel); } -bool X11SalGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect ) +bool X11SalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect) { - return mxTextRenderImpl->GetGlyphBoundRect(aGlyphId, rRect); + return mxTextRenderImpl->GetGlyphBoundRect(rGlyph, rRect); } -bool X11SalGraphics::GetGlyphOutline( sal_GlyphId aGlyphId, +bool X11SalGraphics::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rPolyPoly ) { - return mxTextRenderImpl->GetGlyphOutline(aGlyphId, rPolyPoly); + return mxTextRenderImpl->GetGlyphOutline(rGlyph, rPolyPoly); } SalLayout* X11SalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ) diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index 36b262f..2e62abe 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -627,12 +627,6 @@ void FreetypeFont::GetFontMetric(ImplFontMetricDataRef& rxTo) const } -static inline void SplitGlyphFlags(sal_GlyphId& rGlyphId, int& nGlyphFlags) -{ - nGlyphFlags = rGlyphId & GF_FLAGMASK; - rGlyphId &= GF_IDXMASK; -} - void FreetypeFont::ApplyGlyphTransform( int nGlyphFlags, FT_Glyph pGlyphFT ) const { // shortcut most common case @@ -696,14 +690,13 @@ void FreetypeFont::ApplyGlyphTransform( int nGlyphFlags, FT_Glyph pGlyphFT ) con } } -void FreetypeFont::InitGlyphData( sal_GlyphId aGlyphId, GlyphData& rGD ) const +void FreetypeFont::InitGlyphData(const GlyphItem& rGlyph, GlyphData& rGD ) const { FT_Activate_Size( maSizeFT ); - int nGlyphFlags; - SplitGlyphFlags(aGlyphId, nGlyphFlags ); + int nGlyphFlags = rGlyph.maGlyphId & GF_FLAGMASK;; - FT_Error rc = FT_Load_Glyph(maFaceFT, aGlyphId, mnLoadFlags); + FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.maGlyphId & GF_IDXMASK, mnLoadFlags); if( rc != FT_Err_Ok ) { @@ -1001,7 +994,7 @@ static int FT_cubic_to( const FT_Vector* p1, const FT_Vector* p2, const FT_Vecto } // extern "C" -bool FreetypeFont::GetGlyphOutline( sal_GlyphId aGlyphId, +bool FreetypeFont::GetGlyphOutline(const GlyphItem& rGlyph, basegfx::B2DPolyPolygon& rB2DPolyPoly ) const { if( maSizeFT ) @@ -1009,8 +1002,7 @@ bool FreetypeFont::GetGlyphOutline( sal_GlyphId aGlyphId, rB2DPolyPoly.clear(); - int nGlyphFlags; - SplitGlyphFlags(aGlyphId, nGlyphFlags); + int nGlyphFlags = rGlyph.maGlyphId & GF_FLAGMASK;; FT_Int nLoadFlags = FT_LOAD_DEFAULT | FT_LOAD_IGNORE_TRANSFORM; @@ -1019,7 +1011,7 @@ bool FreetypeFont::GetGlyphOutline( sal_GlyphId aGlyphId, nLoadFlags |= FT_LOAD_TARGET_LIGHT; #endif - FT_Error rc = FT_Load_Glyph( maFaceFT, aGlyphId, nLoadFlags ); + FT_Error rc = FT_Load_Glyph(maFaceFT, rGlyph.maGlyphId & GF_IDXMASK, nLoadFlags); if( rc != FT_Err_Ok ) return false; diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx index 3cece78..b41f7c0 100644 --- a/vcl/unx/generic/glyphs/glyphcache.cxx +++ b/vcl/unx/generic/glyphs/glyphcache.cxx @@ -304,10 +304,10 @@ long FreetypeFont::Release() const return --mnRefCount; } -const GlyphMetric& FreetypeFont::GetGlyphMetric(sal_GlyphId aGlyphId) +const GlyphMetric& FreetypeFont::GetGlyphMetric(const GlyphItem& rGlyph) { // usually the GlyphData is cached - GlyphList::iterator it = maGlyphList.find( aGlyphId ); + GlyphList::iterator it = maGlyphList.find(rGlyph.maGlyphId & GF_IDXMASK); if( it != maGlyphList.end() ) { GlyphData& rGlyphData = it->second; GlyphCache::GetInstance().UsingGlyph( *this, rGlyphData ); @@ -315,9 +315,9 @@ const GlyphMetric& FreetypeFont::GetGlyphMetric(sal_GlyphId aGlyphId) } // sometimes not => we need to create and initialize it ourselves - GlyphData& rGlyphData = maGlyphList[ aGlyphId ]; + GlyphData& rGlyphData = maGlyphList[rGlyph.maGlyphId & GF_IDXMASK]; mnBytesUsed += sizeof( GlyphData ); - InitGlyphData( aGlyphId, rGlyphData ); + InitGlyphData(rGlyph, rGlyphData); GlyphCache::GetInstance().AddedGlyph( *this, rGlyphData ); return rGlyphData.GetMetric(); } ... etc. - the rest is truncated
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits