Change font used to copy Cell-Formulas in Calc

Hi there,

sorry, it’s a longer post, but I wanted to include as much information as possible.

I’m currently investigating a strange behavior between Calc and Writer. Say, I’m typing a formula into a cell in Calc, e.g. “=A1+A2”. Alongside Calc, I have Writer open and create a document, so I want to copy the Formula over to Writer. I select it in the formula editor line in calc, hit [Ctrl]-[C] and paste to Writer:

grafik

That works like a charm, Calc even colors the copied formula and I have a nice look in the document:

grafik

But, when working with the document later, I noticed the font is not, as expected, “Liberation Sans” (which is used in both Calc and Writer), but “Lohit Devanagari” - for all cell names/references. Formular names (i.e. “MEAN” or “LOG”) are copied in “Liberation Sans”.

I checked using a clipboard viewer, and the font was indeed selected by Calc (it does not seem to be a font-replacement issue or alike in Writer). Below is an excerpt of what Calc offers the clipboard in GTK as format “application/vnd.oasis.opendocument.text-flat-xml” as well as “application/x-libreoffice-internal[…]”:

<?xml version="1.0" encoding="UTF-8"?>

<office:document-content [snip] office:version="1.3">
<office:automatic-styles>
<style:style style:name="P1" style:family="paragraph">
<style:paragraph-properties fo:text-align="start" style:text-autospace="none" style:line-break="normal" style:writing-mode="page"/>
<style:text-properties style:text-outline="false" style:text-line-through-style="none" style:text-line-through-type="none" fo:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable" fo:font-size="10pt" fo:language="de" fo:country="DE" fo:font-style="normal" fo:text-shadow="none" style:text-underline-style="none" fo:font-weight="normal" style:text-underline-mode="continuous" style:text-overline-mode="continuous" style:text-line-through-mode="continuous" style:font-family-asian="&apos;Noto Sans CJK SC&apos;" style:font-family-generic-asian="system" style:font-pitch-asian="variable" style:font-size-asian="10pt" style:language-asian="zh" style:country-asian="CN" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-family-complex="&apos;Lohit Devanagari&apos;" style:font-family-generic-complex="system" style:font-pitch-complex="variable" style:font-size-complex="10pt" style:language-complex="hi" style:country-complex="IN" style:font-style-complex="normal" style:font-weight-complex="normal" style:text-emphasize="none" style:font-relief="none" style:text-overline-style="none" style:text-overline-color="font-color" fo:hyphenate="false"/></style:style>
</office:automatic-styles><office:body><text:p text:style-name="P1">=B1+A1</text:p></office:body></office:document-content>

(I intentionally didn’t remove any of the style-tags, but change the formatting a little and removed the XML style definition for better reading)

The same is observed in clipboard Format “text/rtf” (in richtext syntax of course) - so it’s also not just the “internal” clipboard format:

{\rtf\ansi
{\fonttbl{\f0\froman\fprq2\fcharset0 Liberation Serif;}{\f1\fprq2\fcharset0 DejaVu Sans;}{\f2\fprq2\fcharset0 DejaVu Sans;}{\f3\fswiss\fprq2\fcharset0 Liberation Sans;}{\f4\fswiss\fprq2\fcharset0 Liberation Sans;}{\f5\fnil\fprq2\fcharset0 Ubuntu;}{\f6\fswiss\fprq2\fcharset0 Liberation Sans;}{\f7\fprq2\fcharset0 Noto Sans CJK SC;}{\f8\fprq2\fcharset0 Lohit Devanagari;}}
{\colortbl;\red255\green0\blue0;\red0\green0\blue255;\red207\green216\blue220;}
{\*\EditEnginePoolDefaults\ltrpar\fi0\li0\ri0\fi0\li0\ri0\sb0\sa0\sl0\slmult0\ql\cf0\f0\fs13\b0\ulnone\strike0\i0\outl0\shad00\kerning0\expndtw0\f1\f1\fs13\fs13\b0\b0\i0\i0\accnone\olnone\scaps0\caps0}
\deftab408
{

\ltrpar\ql\f3\fs20\b0\ulnone\strike0\i0\outl0\shad0\f7\f8\fs20\fs20\b0\b0\i0\i0\accnone\olnone {\f3\fs20\b0\i0 =AVERAGE(}{\cf2 B1}{+}{\cf1 A1}{)}\par\pard\plain

}}

Here, the font in the font-table with Lohit Devanagari is defined as font #8 and selected using the \f8 command, which is the last in the line which actually contains the text. So it seems to be the default actually? For the Formula name (AVERAGE in this case) the font is changed specifically to \f3 (Liberation Sans). The cell names then default to the last previous definition, which is \f8.

Result: again, Lohit Devanagari is used as font for A1 and A2. The fact that the font is selected in numerous clipboard formats somehow tells me that the source is actually Calc here.

I purged and reinstalled LibreOffice, deleted my user-profile to force-create a new one. I also did a search (in the config) for the particular font (Lohit Devanagari), and didn’t find that one.

In the XML code above, it seems there’s different fonts selected for different locals, which is reasonable. So maybe it’s a problem with a wrong (default) locale set somewhere?

Can someone reproduce this?

Thanks and
best regards,

Alex

Additional information:
Original system (all the tests above were made with):
Version: 24.2.7.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 8; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: de-DE (de_DE.UTF-8); UI: de-DE
Ubuntu package version: 4:24.2.7-0ubuntu0.24.04.1
Calc: threaded

I additionally checked Lo 24.2 on Windows 11 (also DE locale). It also copies different fonts for cell names and formulas, this time it’s “Lucida Sans” for the cells, though.

Version: 24.2.3.2 (X86_64) / LibreOffice Community
Build ID: 433d9c2ded56988e8a90e6b2e771ee4e6a5ab2ba
CPU threads: 2; OS: Windows 10.0 Build 22631; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: threaded

Same result also with an older Version 7.3 on Linux (Cell references/names use Lohit font).
This time:
Version: 7.3.7.2 / LibreOffice Community
Build ID: 30(Build:2)
CPU threads: 2; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Ubuntu package version: 1:7.3.7-0ubuntu0.22.04.7
Calc: threaded

I cannot edit my post (to many media items).

I realized I forgot to put the actual question: Where does Lo get the font names from? I cannot seem to find an option to change which font to use as “default” for cell references e.g.

What about the font in the Default cell formatting style?

That’s set to “Liberation Sans”.

And what about the language of the source and target? There is a complex text layout involved here?
Sorry, but this time I have not tested before asking.

By language you mean the locale settings of the Application? Both DE in the 1st case, though I tested in a VM using en-US as well.

Both the Calc worksheet and the Writer file can be empty (newly created). But the question about the “target” is what I was trying to pin down by dissecting the clipboard contents after [Ctrl]+[C] - the rich-text formats copied / offered to the clipboard already contain an alternate font selection, which lead me to the conclusion that the change is already done in Calc.

I’ve attached two documents that I just created, where the “magic” can be seen (I hope). I’ll try some things maybe tomorrow (like removing some fonts to see which will be used instead). Let’s see…

MWE-Calc.ods (8.5 KB)
MWE-Writer.odt (9.8 KB)

The cell language.
image

I tested with your documents, and yes, the Font is Lohit Devanagari.
I tested with new documents, and the font is Lucida Sans. I don’t understand why.

I can see the issue in your Writer document but cannot repeat it on my PC. Every time I paste in a new Writer document, save, close and reopen, all characters are Liberation Sans.

.
Version: 24.8.4.2 (X86_64) / LibreOffice Community
Build ID: bb3cfa12c7b1bf994ecc5649a80400d06cd71002
CPU threads: 8; OS: Windows 11 X86_64 (10.0 build 22631); UI render: Skia/Raster; VCL: win
Locale: en-NZ (en_NZ); UI: en-GB
Calc: CL threaded
&
Version: 7.3.1.3 (x64) / LibreOffice Community
&
Version: 24.2.4.2 (X86_64) / LibreOffice Community

But two out of three could be worth a bug report, How to Report Bugs in LibreOffice - The Document Foundation Wiki

In my installation i.e. 24.2.7.2 & 24.8.4.2 on Windows 11, Lucida Sans is set as default for Complex languages (the Default cell style).

The recording below shows the result for two fonts (file: tf_116604.ods (10.0 KB)).


rec_24842

⠀⠀
File MWE-Calc.ods provided by @a21347 indicates Lohit Devanagari for Complex languages.

You must select from the input line, not from the cell itself. EDIT: I could reproduce what you do. I can edit the cell with F2 or with double click, but the selection of the cell content must be with triple click or with Ctrl+A (select all), not with click and drag. Any way, I get Lohit Dev., from the sample file.


I can’t see Lohit Dev., Where do you look for that? Thanks.

Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 60(Build:1)
CPU threads: 4; OS: Linux 5.14; UI render: default; VCL: gtk3
Locale: es-MX (en_US.UTF-8); UI: en-US
Calc: threaded

You first have to enable Complex Text Layout in Tools > Options > Language Settings > Languages

Now I can reproduce it, all the way back to 6.4.7.2. I guess it is deliberate so that CTL can also be pasted retaining direction.

1 Like

Yes, the screenshot by a21347 shows it. I checked both ways before posting.

That’s right.

The Complex tab




Version: 24.8.4.2 (X86_64) / LibreOffice Community
Build ID: bb3cfa12c7b1bf994ecc5649a80400d06cd71002
CPU threads: 8; OS: Windows 11 X86_64 (10.0 build 22631); UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 56f7684011345957bbf33a7ee678afaf4d2ba333
CPU threads: 8; OS: Windows 10.0 Build 22631; UI render: Skia/Raster; VCL: win
Locale: en-US (en_US); UI: en-US
Calc: threaded

1 Like

I had overlooked enabling Complex Text Layout. I see it now. Many thanks.
Now I also get Lohit Devanagari.

First of all, thanks for testing and sorry for not answering for so long, I didn’t have the time to investigate further til now.

So:

Yes, that’s what I initially did. Select from the input line, either [Ctrl]-[A] or by mouse.

I just tried that as well. This time on Windows (version see below). And I saw (I guess) the same difference as pointed out in the animations and screenshots both of you posted:

  • with a document created earlier (Linux / Ubuntu / Mint) I get Lohit Dev. when selecting cell code
  • with a new document created on Windows (I saw that earlier as well I recall) I get Lucida Sans

in both cases, the “surrounding” font is Liberation Sans.

And yes, when enabling “Complex Text Layout” in LOs Options, I can see that font beeing selected in the Language-Tab for the cell. Interestingly though, I did not have Complex Text Layout enabled by default (on any machine) - but I guess that’s the case in your cases as well?

Old document and newly created one below (had to combine into one image, after my 1st post I somehow cannot add more than one picture any more):
Unbenannt

So, as I unserstand, the fact that a different font is selected is somehow related to LO (Calc) - which one, though, depends on the system (and that selection is them stored and retained in the document)?

Inside a document I find reference to those font names only a few times, in styles.xml and content.xml: for default font selection in case of complex text (style:font-name-complex, e.g. for default cell-text or some of the text / paragraph styles) and the (IMHO) more general <office:font-face-decls> tag. So, nothing specific except the already mentioned Complext Text settings?

Version: 24.8.4.2 (X86_64) / LibreOffice Community
Build ID: bb3cfa12c7b1bf994ecc5649a80400d06cd71002
CPU threads: 8; OS: Windows 11 X86_64 (10.0 build 22631); UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: threaded