Profile Picture

Changing font globally

Posted By NeilTurp 7 Years Ago
Author
Message
NeilTurp
Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 0, Visits: 166
I have an app where the user is allowed to change the font name/size of a file completely.  I know all formatting is lost but this is what the users want.  The code I am using is

NRichTextView mmdv = new NRichTextView()
...
mmdv.Content.Selection.SelectAll();
mmdv.Content.Selection.SetFontSizeToSelectedInLines(24.0);
mmdv.Content.Selection.DeselectAll();

but that doesn't work.  I've also tried stepping through the Sections
for (int a = 0; a < mmdv.Content.Sections.Count; a++)
{
  mmdv.Content.Sections[a].FontName = "Cochin";
etc
}
Nothing works.  Obviously I've misunderstood something somewhere but can anyone throw light on it?
Neil


Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,018
Hi Neil,
We weren't able to replicate that - we tried:

   NRichTextView view = (NRichTextView)nRichTextViewWithRibbonControl1.Widget.GetFirstDescendant(NRichTextView.NRichTextViewSchema);

   view.Content.Selection.SelectAll();
   view.Content.Selection.SetFontSizeToSelectedInlines(24.0f);
   view.Content.Selection.SetFontNameToSelectedInlines("Arial");
   view.Content.Selection.DeselectAll();

And it was working correctly - so there must be something else about this problem. Can you post the complete code you use to load the document? Also can you send that document you're testing with?


Best Regards,
Nevron Support Team



NeilTurp
Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 0, Visits: 166
My apologies.  After changing the font, I had included a default formatting in a subsequent routine.
N


NeilTurp
Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 0, Visits: 166
Hi
Here is a follow up on this:
I am using a NFontNameThumbnailComboBox to allow the user to selct a font.  Now I find it all works (to a greater or lesser extent - some fonts like Farisi cut off the top of the line or para) if I choose a font whose name is one word like ApplyMyungjo or Arimo - the selected text all changes to the selected font and the value is saved.  However, if I choose a font whose name is two or more words like Comic Sans MS or Brush Script MT, the stored value is the concatenated string (ComicSansMS or BrushScriptMT) and the font in the NRichTextview is not changed.
What is causing it to cut off the top of the line/paragraph with some fonts (Farisi) and not others?
Is there either a way to stop the problem with the multi-worded fonts or a way to remove the multi-worded fonts from the list of available fonts?
Thanks
Neil


Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,018
Hi Neil,
How do you get the font name from the combo box - we tested with the following code on windows and it was working OK:

using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TestThumbnailCombo
{
 public partial class Form1 : Form
 {
  NFontNameThumbnailComboBox fontThumbnailCombo;

  public Form1()
  {
   InitializeComponent();

   // clear all controls from the form
   
   // Add a NOV widget inside the form
   fontThumbnailCombo = new NFontNameThumbnailComboBox();

   fontThumbnailCombo.SelectedIndexChanged += SayHelloWorld_SelectedIndexChanged;
   Controls.Add(new NNovWidgetHost<NFontNameThumbnailComboBox>(fontThumbnailCombo));

  }

  private void SayHelloWorld_SelectedIndexChanged(Nevron.Nov.Dom.NValueChangeEventArgs arg)
  {
   textBox1.Text = fontThumbnailCombo.SelectedItem.Text;
  }
 }
}
Regarding the cutoff - it is caused by the fact that some font report smaller ascent / descent than the actual ascent descent of the rendered glyphs. On the other hand the paragraph rendering is clipped in order for the paragraph to be cached by the internal render cache of the control which leads to those cutoffs. We have implemented a fix that internally inflates the clip bound of the paragraph with the maximum font ascent/descent metrics from the HHEA font table, which should take care of this and will publish a SP yearly next week for you to try it.




Best Regards,
Nevron Support Team



NeilTurp
Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 0, Visits: 166
This is C# Xamarin on OSX so it may be an OSX thing.  I have a variable NSFont called MMFont which I fill from the NFontNameThumbNailComboBox fpSelect when they choose a new font:

MMFont = NSFont.FromFontName(fpSelect.FontName, 14.0)

then load into the NRichTextView control mmdv:

  mmdv.Content.Selection.SelectAll();
  mmdv.Content.Selection.SetFontSizeToSelectedInlines(MMFont.PointSize);
  mmdv.Content.Selection.SetFontNameToSelectedInlines(MMFont.DisplayName);
  mmdv.Content.Selection.DeselectAll();

Thanks
Neil


Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,018
Hi Neil,

Can you send us a project that replicates that? We checked the font name combo on mac and it appeared to report correct file names without the concatenation.


Best Regards,
Nevron Support Team



NeilTurp
Posted 7 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 0, Visits: 166
I've sorted it.  You need to use FamilyName, not DisplayName

  mmdv.Content.Selection.SelectAll();
  mmdv.Content.Selection.SetFontSizeToSelectedInlines(MMFont.PointSize);
  mmdv.Content.Selection.SetFontNameToSelectedInlines(MMFont.FamilyName);
  mmdv.Content.Selection.DeselectAll();

For example, 'Brush Script MT' has a FamilyName 'Brush Script MT' but a DisplayName 'Brush Script MT Italic' and somehow this was stopping the NRichTextView from changing the font.
Thanks
Neil


Nevron Support
Posted 7 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,018
Hi Neil,
We're glad you fixed it. You can also download the latest SP of NOV which features an update the to the font thumbnail combo box with better font measurement. Also the paragraph clipping for certain fonts should be gone. Let us know if you meet any problems or have any questions.


Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic