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?