diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2016-12-08 04:39:16 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2016-12-11 00:21:15 +0000 |
commit | 57d248bcec3c6ae3fa1a943a9fd92c566239787f (patch) | |
tree | 1bcd3c6e4a4f4799bfb0442f2877a3e06d61cee6 | |
parent | 9fb706f9fe216f6157b9052bc42a0601d8ae52d5 (diff) |
Don’t encode the vertical flag in the glyph id
Change-Id: I00485dd4d42004e4eaa163a9e6ad0a43cf98a30a
Reviewed-on: https://gerrit.libreoffice.org/31816
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
-rw-r--r-- | vcl/inc/salglyphid.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/sallayout.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/glyphcache.hxx | 2 | ||||
-rw-r--r-- | vcl/quartz/ctfonts.cxx | 4 | ||||
-rw-r--r-- | vcl/quartz/salgdi.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 18 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.hxx | 7 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/cairotextrender.cxx | 13 | ||||
-rw-r--r-- | vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 33 | ||||
-rw-r--r-- | vcl/unx/generic/print/text_gfx.cxx | 2 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 6 |
12 files changed, 34 insertions, 61 deletions
diff --git a/vcl/inc/salglyphid.hxx b/vcl/inc/salglyphid.hxx index dbfd95ebafd2..72cf4fc2fe4e 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 2703f2d9b765..9e7f8ab44e4a 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -315,12 +315,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 bf9cf3c43b93..36155d72a485 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 300ee4dafe3d..52062eb86e21 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 c593b8887de0..c8f9c75b52f8 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 eda090fd24fb..27394c76a6de 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 b67cb4fa3f07..ab0559403c4d 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 378801bb0a38..f658533d8625 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 3d7ca1547eb5..a188ad398212 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 2e62abe6cbce..039ffad52b5a 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 2f04c72bc570..36f17761f684 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 f78e71f13cdf..8b218630d531 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); } @@ -401,7 +401,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); @@ -546,7 +546,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()); |