-
-
Notifications
You must be signed in to change notification settings - Fork 41
LT-22351: Offer Graphite features in Styles and refresh after font changes #1165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f3ac5e3
a145300
a0070f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ public partial class FwFontTab : UserControl, IStylesTab | |
| private bool m_fIgnoreWsSelectedIndexChange = false; | ||
| private StyleInfo m_currentStyleInfo; | ||
| private int m_currentWs = -1; | ||
| private ILgWritingSystemFactory m_wsf; | ||
|
|
||
| private bool m_fFontListIncludesRealNames = false; | ||
|
|
||
|
|
@@ -81,7 +82,12 @@ public void CheckDisposed() | |
| /// ------------------------------------------------------------------------------------ | ||
| public ILgWritingSystemFactory WritingSystemFactory | ||
| { | ||
| set { CheckDisposed(); m_FontAttributes.WritingSystemFactory = value; } | ||
| set | ||
| { | ||
| CheckDisposed(); | ||
| m_wsf = value; | ||
| m_FontAttributes.WritingSystemFactory = value; | ||
| } | ||
| } | ||
| #endregion | ||
|
|
||
|
|
@@ -302,6 +308,8 @@ public void UpdateForStyle(StyleInfo styleInfo, int ws) | |
| // only include the magic font names, not the real ones. | ||
| FillFontNames(ws > -1); | ||
|
|
||
| m_FontAttributes.UseGraphiteFeatures = IsGraphiteEnabled(ws); | ||
|
|
||
| m_FontAttributes.ShowingInheritedProperties = true; // Always allow re-setting to unspecified for font attributes | ||
|
|
||
| // Initialize controls based on whether or not this style inherits from another style. | ||
|
|
@@ -418,6 +426,18 @@ internal ComboBox FontNamesComboBox | |
| } | ||
|
|
||
| #region private methods | ||
| /// <summary> | ||
| /// Returns whether Graphite rendering is enabled for the given writing system. The | ||
| /// default row (-1) covers every writing system, so it reports false. | ||
| /// </summary> | ||
| private bool IsGraphiteEnabled(int ws) | ||
| { | ||
| if (ws <= 0 || m_wsf == null) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With I follow why the default row can't assume Graphite (feature codes are font-specific, and that row spans writing systems that may use different fonts), so I'm not suggesting it should. I'm just trying to work out whether the reported case ends up covered.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ken's report has the answer: he says the list "showed the open type list instead of the graphite list even though Charis SIL was selected in the style", and that to set features from the Font tab "you must also set the font and not rely on inheritance". Selecting a font in the Font tab is only possible on a writing-system row. The Default settings row lists only the magic names in a |
||
| return false; | ||
| var writingSystem = m_wsf.get_EngineOrNull(ws); | ||
| return writingSystem != null && writingSystem.IsGraphiteEnabled; | ||
| } | ||
|
|
||
| /// ------------------------------------------------------------------------------------ | ||
| /// <summary> | ||
| /// Fills the font names. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -760,6 +760,160 @@ public void Model_WritingSystemChanged_NotCalledOnIrrelevantChange() | |
| Assert.That(writingSystemChanged, Is.False, "WritingSystemUpdated should not have been called after this change"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Model_WritingSystemChanged_CalledOnDefaultFontFeaturesChange() | ||
| { | ||
| var writingSystemChanged = false; | ||
| var mockWsManager = new Mock<IWritingSystemManager>(); | ||
|
|
||
| var container = new TestWSContainer(new[] { "fr" }); | ||
| var testModel = new FwWritingSystemSetupModel(container, | ||
| FwWritingSystemSetupModel.ListType.Vernacular, mockWsManager.Object); | ||
| testModel.CurrentDefaultFont = new FontDefinition("Charis SIL"); | ||
| testModel.Save(); | ||
| testModel.WritingSystemUpdated += (sender, args) => | ||
| { | ||
| writingSystemChanged = true; | ||
| }; | ||
| // Changing only the font features must refresh views that cache rendered output. | ||
| testModel.CurrentDefaultFont = new FontDefinition("Charis SIL") { Features = "cv43=1,smcp=1" }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A question about what this pins down: this test (and the Graphite-toggle and reorder ones below) swaps in a whole new Would one test that mutates
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, worth adding, and it is in a0070f8: |
||
| testModel.Save(); | ||
| Assert.That(writingSystemChanged, Is.True, "WritingSystemUpdated should have been called after this change"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Model_WritingSystemChanged_CalledOnInPlaceFontFeaturesChange() | ||
| { | ||
| var writingSystemChanged = false; | ||
| var mockWsManager = new Mock<IWritingSystemManager>(); | ||
|
|
||
| var container = new TestWSContainer(new[] { "fr" }); | ||
| var testModel = new FwWritingSystemSetupModel(container, | ||
| FwWritingSystemSetupModel.ListType.Vernacular, mockWsManager.Object); | ||
| testModel.CurrentDefaultFont = new FontDefinition("Charis SIL"); | ||
| testModel.Save(); | ||
| testModel.WritingSystemUpdated += (sender, args) => | ||
| { | ||
| writingSystemChanged = true; | ||
| }; | ||
| // The font dialog edits the existing definition rather than replacing it. | ||
| testModel.CurrentDefaultFont.Features = "cv43=1"; | ||
| testModel.Save(); | ||
| Assert.That(writingSystemChanged, Is.True, "WritingSystemUpdated should have been called after this change"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Model_WritingSystemChanged_CalledOnGraphiteToggle() | ||
| { | ||
| var writingSystemChanged = false; | ||
| var mockWsManager = new Mock<IWritingSystemManager>(); | ||
|
|
||
| var container = new TestWSContainer(new[] { "fr" }); | ||
| var testModel = new FwWritingSystemSetupModel(container, | ||
| FwWritingSystemSetupModel.ListType.Vernacular, mockWsManager.Object); | ||
| testModel.CurrentDefaultFont = new FontDefinition("Charis SIL"); | ||
| testModel.IsGraphiteEnabled = false; | ||
| testModel.Save(); | ||
| testModel.WritingSystemUpdated += (sender, args) => | ||
| { | ||
| writingSystemChanged = true; | ||
| }; | ||
| testModel.IsGraphiteEnabled = true; | ||
| testModel.Save(); | ||
| Assert.That(writingSystemChanged, Is.True, "WritingSystemUpdated should have been called after this change"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Model_WritingSystemChanged_CalledOnRightToLeftChange() | ||
| { | ||
| var writingSystemChanged = false; | ||
| var mockWsManager = new Mock<IWritingSystemManager>(); | ||
|
|
||
| var container = new TestWSContainer(new[] { "fr" }); | ||
| var testModel = new FwWritingSystemSetupModel(container, | ||
| FwWritingSystemSetupModel.ListType.Vernacular, mockWsManager.Object); | ||
| testModel.WritingSystemUpdated += (sender, args) => | ||
| { | ||
| writingSystemChanged = true; | ||
| }; | ||
| testModel.CurrentWsSetupModel.CurrentRightToLeftScript = true; | ||
| testModel.Save(); | ||
| Assert.That(writingSystemChanged, Is.True, "WritingSystemUpdated should have been called after this change"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Model_WritingSystemChanged_CalledOnNumberingSystemChange() | ||
| { | ||
| var writingSystemChanged = false; | ||
| var mockWsManager = new Mock<IWritingSystemManager>(); | ||
|
|
||
| var container = new TestWSContainer(new[] { "fr" }); | ||
| var testModel = new FwWritingSystemSetupModel(container, | ||
| FwWritingSystemSetupModel.ListType.Vernacular, mockWsManager.Object); | ||
| testModel.WritingSystemUpdated += (sender, args) => | ||
| { | ||
| writingSystemChanged = true; | ||
| }; | ||
| testModel.CurrentWsSetupModel.CurrentNumberingSystemDefinition = NumberingSystemDefinition.CreateCustomSystem("abcdefghij"); | ||
| testModel.Save(); | ||
| Assert.That(writingSystemChanged, Is.True, "WritingSystemUpdated should have been called after this change"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Model_WritingSystemChanged_NotCalledOnReorderedFontFeatures() | ||
| { | ||
| var writingSystemChanged = false; | ||
| var mockWsManager = new Mock<IWritingSystemManager>(); | ||
|
|
||
| var container = new TestWSContainer(new[] { "fr" }); | ||
| var testModel = new FwWritingSystemSetupModel(container, | ||
| FwWritingSystemSetupModel.ListType.Vernacular, mockWsManager.Object); | ||
| testModel.CurrentDefaultFont = new FontDefinition("Charis SIL") { Features = "smcp=1,cv43=1" }; | ||
| testModel.Save(); | ||
| testModel.WritingSystemUpdated += (sender, args) => | ||
| { | ||
| writingSystemChanged = true; | ||
| }; | ||
| testModel.CurrentDefaultFont = new FontDefinition("Charis SIL") { Features = "cv43=1,smcp=1" }; | ||
| testModel.Save(); | ||
| Assert.That(writingSystemChanged, Is.False, "Reordering the same features is not a rendering change"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Model_WritingSystemChanged_NotCalledWhenListAlsoChanged() | ||
| { | ||
| var writingSystemChanged = false; | ||
| var listChanged = false; | ||
| var mockWsManager = new Mock<IWritingSystemManager>(); | ||
|
|
||
| var container = new TestWSContainer(new[] { "fr", "en" }); | ||
| var testModel = new FwWritingSystemSetupModel(container, | ||
| FwWritingSystemSetupModel.ListType.Vernacular, mockWsManager.Object); | ||
| testModel.WritingSystemUpdated += (sender, args) => { writingSystemChanged = true; }; | ||
| testModel.WritingSystemListUpdated += (sender, args) => { listChanged = true; }; | ||
| testModel.CurrentDefaultFont = new FontDefinition("Charis SIL"); | ||
| testModel.MoveDown(); | ||
| testModel.Save(); | ||
| Assert.That(listChanged, Is.True, "WritingSystemListUpdated should have been called after this change"); | ||
| Assert.That(writingSystemChanged, Is.False, "One refresh is enough when the list update already refreshes"); | ||
| } | ||
|
|
||
| [Test] | ||
| public void Model_WritingSystemChanged_RaisedAfterUnitOfWorkCloses() | ||
| { | ||
| Cache.ActionHandlerAccessor.EndUndoTask(); | ||
| var testModel = new FwWritingSystemSetupModel(Cache.LangProject, FwWritingSystemSetupModel.ListType.Vernacular, | ||
| Cache.ServiceLocator.WritingSystemManager, Cache); | ||
| var depthWhenRaised = -1; | ||
| testModel.WritingSystemUpdated += (sender, args) => | ||
| { | ||
| depthWhenRaised = Cache.ActionHandlerAccessor.CurrentDepth; | ||
| }; | ||
| testModel.CurrentDefaultFont = new FontDefinition("Charis SIL") { Features = "cv43=1,smcp=1" }; | ||
| testModel.Save(); | ||
| Assert.That(depthWhenRaised, Is.EqualTo(0), "Listeners refresh views, which must not run inside the save's unit of work"); | ||
| } | ||
|
|
||
| [TestCase(FwWritingSystemSetupModel.ListType.Vernacular)] | ||
| [TestCase(FwWritingSystemSetupModel.ListType.Analysis)] | ||
| public void WritingSystemTitle_ChangesByType(FwWritingSystemSetupModel.ListType type) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason the Styles-dialog half of this landed without tests?
FwFontTabTestsalready has a cache-backed fixture that callsFillFontInfo(Cache), andFwFontTabalready exposesinternal ComboBox FontNamesComboBox, so an internal accessor for the attributes control would be in keeping with what's there.Two tests — one that sets a writing system's
IsGraphiteEnabledand asserts the flag reaches the button afterUpdateForStyle(styleInfo, ws.Handle), and one for the -1 row — would pin both this line and the default-row rule below. Happy to be told the accessor isn't worth it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That test existed and was dropped before the PR went up (
UpdateForStyle_GraphiteWritingSystem_PrefersGraphiteFeatures): it setIsGraphiteEnabledon the vernacular writing system, calledUpdateForStylefor that row and for -1, and asserted the flag on the attributes control. The only observable the fixture can reach is that flag, so the test restatedIsGraphiteEnabled(ws)in test form; the thing that matters, which list the button shows, needs a Graphite font and a device context the fixture does not have. Not worth the accessor for that reason, though I am open to it if you see something it would catch.