summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-01-12 20:44:37 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-01-13 20:26:25 +0100
commit935761709fb7629c8d23aa5dc8bfcbd2988f5bbf (patch)
treedbfae022795b658cec532fe31933cc7c2976e954
parent711cc3278ffc256a9d1782da1bc157498e82e1a6 (diff)
tdf#144862 adjust positioning experimental options
drop GlyphPositioningMode::ClassicInspired as that just demos the tradeoffs of the original GlyphPositioningMode::Classic vs the chaos of GlyphPositioningMode::PreferReadability where hinting at small sizes pushes the text outside its layout bounds. add GlyphPositioningMode::LayoutAndMatchRender to demo the next option. so: GlyphPositioningMode::Classic This is as it ~always was, using the technique documented at https://wiki.openoffice.org/wiki/Writer/WYSIWYG GlyphPositioningMode::Layout This is just taking the high resolution layout positions, dropping the "Classic" technique and let vcl do its default scaling and rendering of the glyph positions as happens in editeng. GlyphPositioningMode::LayoutAndMatchRender same as Layout, but during text render preserve the scaled glyph positions as floating point positions and pass through to the various platform text renderers configured as best to handle that. Change-Id: Ic37bb8f3cf4472bdc3c48f02b1f9057a0f80cbd9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128360 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/inc/viewopt.hxx5
-rw-r--r--sw/source/core/txtnode/fntcache.cxx59
-rw-r--r--sw/uiconfig/swriter/ui/viewoptionspage.ui3
3 files changed, 23 insertions, 44 deletions
diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx
index 6c93602a85ae..a6ac48b31581 100644
--- a/sw/inc/viewopt.hxx
+++ b/sw/inc/viewopt.hxx
@@ -128,9 +128,8 @@ namespace o3tl {
enum class GlyphPositioningMode {
Classic,
- ClassicInspired,
- PreferLayout,
- PreferReadability
+ Layout,
+ LayoutAndMatchRender
};
class SW_DLLPUBLIC SwViewOption
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index b56672460afb..698ddd6051bf 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -865,21 +865,17 @@ namespace
tools::Long nScr = rScrArray[i] - rScrArray[i - 1];
switch (eGlyphPositioningMode)
{
- case GlyphPositioningMode::PreferLayout:
+ case GlyphPositioningMode::Layout: // <- glyph positioning stable during editing,
+ // but at ~90% screen zoom rendering will
+ // start to show kerning problems
+ case GlyphPositioningMode::LayoutAndMatchRender: // <- glyph positioning stable during editing,
+ // and should render nicely at sane zoom levels
rScrPos = rKernArray[i - 1] + nScr;
// just accept the print layout positions, this is what editeng does
// https://freddie.witherden.org/pages/font-rasterisation/#application-requirements
break;
- case GlyphPositioningMode::PreferReadability:
- {
- // Overwrite KernArray with the screen-optimized glyph positions
- // these will generally be too wide at small sizes and text will spill out
- // of its designated zones
- rKernArray[i - 1] = rScrPos;
- rScrPos += nScr;
- break;
- }
- case GlyphPositioningMode::Classic:
+ case GlyphPositioningMode::Classic: // <- layout unstable during editing, fairly arbitrary glyph
+ // positioning depends on zoom
{
// https://wiki.openoffice.org/wiki/Writer/WYSIWYG
if (nCh == CH_BLANK)
@@ -899,27 +895,6 @@ namespace
rKernArray[i - 1] = rScrPos - nScr;
break;
}
- case GlyphPositioningMode::ClassicInspired:
- {
- // use the print layout positions for blanks and the first glyph after a blank or -
- // and use screen layout within a run of glyphs
- const bool bSyncWithPrintLayout = nCh == CH_BLANK || cChPrev == CH_BLANK || cChPrev == '-';
- if (bSyncWithPrintLayout)
- {
- // Leave KernArray untouched at its print layout position in this case
- // sync ScreenPos to print layout position
- rScrPos = rKernArray[i - 1] + nScr;
- }
- else
- {
- // Overwrite KernArray within the run to use screen-optimized glyph positions
- rKernArray[i - 1] = rScrPos;
- rScrPos += nScr;
- }
- // at small sizes the screen positions tend to get wider, and the text begins to
- // overlap the next word. http://people.redhat.com/otaylor/grid-fitting/
- break;
- }
}
}
}
@@ -1547,6 +1522,12 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
else
{
+ GlyphPositioningMode eGlyphPositioningMode = rInf.GetShell()->GetViewOptions()->GetGlyphPositioningMode();
+ const bool bOrigTextRenderModeForResolutionIndependentLayout(rInf.GetOut().GetTextRenderModeForResolutionIndependentLayout());
+
+ // set text render mode to suit use of resolution independent text layout
+ rInf.GetOut().SetTextRenderModeForResolutionIndependentLayout(eGlyphPositioningMode == GlyphPositioningMode::LayoutAndMatchRender);
+
const OUString* pStr = &rInf.GetText();
OUString aStr;
@@ -1733,8 +1714,6 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
}
else
{
- GlyphPositioningMode eGlyphPositioningMode = rInf.GetShell()->GetViewOptions()->GetGlyphPositioningMode();
-
// In case of Pair Kerning the printer influence on the positioning
// grows
const int nMul = m_pPrtFont->GetKerning() != FontKerning::NONE ? 1 : 3;
@@ -1948,6 +1927,8 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
}
}
}
+
+ rInf.GetOut().SetTextRenderModeForResolutionIndependentLayout(bOrigTextRenderModeForResolutionIndependentLayout);
}
}
@@ -2075,11 +2056,7 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
else
{
GlyphPositioningMode eGlyphPositioningMode = rInf.GetShell()->GetViewOptions()->GetGlyphPositioningMode();
- if (eGlyphPositioningMode == GlyphPositioningMode::PreferLayout)
- {
- aTextSize.setWidth(aKernArray[sal_Int32(nLn) - 1]);
- }
- else
+ if (eGlyphPositioningMode == GlyphPositioningMode::Classic)
{
std::vector<sal_Int32> aScrArray;
rInf.GetOut().GetTextArray( rInf.GetText(), &aScrArray,
@@ -2106,6 +2083,10 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
aTextSize.setWidth( nScrPos );
}
+ else
+ {
+ aTextSize.setWidth(aKernArray[sal_Int32(nLn) - 1]);
+ }
}
}
else
diff --git a/sw/uiconfig/swriter/ui/viewoptionspage.ui b/sw/uiconfig/swriter/ui/viewoptionspage.ui
index 749a06abd3b3..e74d9d270b39 100644
--- a/sw/uiconfig/swriter/ui/viewoptionspage.ui
+++ b/sw/uiconfig/swriter/ui/viewoptionspage.ui
@@ -521,9 +521,8 @@
<property name="active">0</property>
<items>
<item translatable="yes" context="viewoptionspage|glyphposmode">Classic</item>
- <item translatable="yes" context="viewoptionspage|glyphposmode">ClassicInspired</item>
<item translatable="yes" context="viewoptionspage|glyphposmode">Layout</item>
- <item translatable="yes" context="viewoptionspage|glyphposmode">Readability</item>
+ <item translatable="yes" context="viewoptionspage|glyphposmode">Layout &amp; Match Render</item>
</items>
</object>
<packing>