Bug 80276

Summary: OTF files not always recognized
Product: shared-mime-info Reporter: Gioele Barabucci <gioele>
Component: freedesktop.org.xmlAssignee: Shared Mime Info group <shared_mime_info>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: OTF file not recognized by shared-mime-info

Description Gioele Barabucci 2014-06-20 09:50:35 UTC
Created attachment 101422 [details]
OTF file not recognized by shared-mime-info

The attached OTF file is not recognized, although it can be opened in fontforge and gnome-font-viewer.
Comment 1 Bastien Nocera 2014-06-23 12:52:09 UTC
(In reply to comment #0)
> Created attachment 101422 [details]
> OTF file not recognized by shared-mime-info
> 
> The attached OTF file is not recognized, although it can be opened in
> fontforge and gnome-font-viewer.

OpenSans-Bold-webfont.otf:
	name: application/vnd.oasis.opendocument.formula-template
	data: application/x-font-ttf
	file: application/x-font-ttf

It's recognised fine when data is checked. You'll have to give more details about how it's "not recognised".
Comment 2 Gioele Barabucci 2014-06-23 13:02:21 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > Created attachment 101422 [details]
> > OTF file not recognized by shared-mime-info
> > 
> > The attached OTF file is not recognized, although it can be opened in
> > fontforge and gnome-font-viewer.
> 
> OpenSans-Bold-webfont.otf:
> 	name: application/vnd.oasis.opendocument.formula-template
> 	data: application/x-font-ttf
> 	file: application/x-font-ttf
> 
> It's recognised fine when data is checked. You'll have to give more details
> about how it's "not recognised".

I originally reported this bug at <https://bugs.launchpad.net/bugs/1332426>. On Ubuntu 14.04 that file is recognized as "application/vnd.oasis.opendocument.formula-template" so double clicking on it opens a libreoffice window.

One of the commenters on that bug noticed that the root cause for this is 

> nautilus is using the shared-mime-info database
> 
> they use
> 
> " <magic priority="50">
>       <match type="string" value="OTTO" offset="0"/>
>     </magic>"
> 
> it means they expect fonts to start with OTTO, that doesn't seem the case of > that one...

https://bugs.launchpad.net/ubuntu/+source/gnome-font-viewer/+bug/1332426/comments/9

So, is the problem in nautilus because it should not use the "name" field but the "data" field?
Comment 3 Bastien Nocera 2014-06-23 14:33:50 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > (In reply to comment #0)
> > > Created attachment 101422 [details]
> > > OTF file not recognized by shared-mime-info
> > > 
> > > The attached OTF file is not recognized, although it can be opened in
> > > fontforge and gnome-font-viewer.
> > 
> > OpenSans-Bold-webfont.otf:
> > 	name: application/vnd.oasis.opendocument.formula-template
> > 	data: application/x-font-ttf
> > 	file: application/x-font-ttf
> > 
> > It's recognised fine when data is checked. You'll have to give more details
> > about how it's "not recognised".
> 
> I originally reported this bug at <https://bugs.launchpad.net/bugs/1332426>.
> On Ubuntu 14.04 that file is recognized as
> "application/vnd.oasis.opendocument.formula-template" so double clicking on
> it opens a libreoffice window.
> 
> One of the commenters on that bug noticed that the root cause for this is 
> > nautilus is using the shared-mime-info database
> > 
> > they use
> > 
> > " <magic priority="50">
> >       <match type="string" value="OTTO" offset="0"/>
> >     </magic>"
> > 
> > it means they expect fonts to start with OTTO, that doesn't seem the case of > that one...

That's not a problem though. There are 2 file types with the same glob (*.otf, for both OpenType Fonts and OpenDocument Formula Templates) then the file manager should check by data. The data doesn't match the OpenOffice document nor the OpenType Font.

I've fixed this by adding a magic that matches this one particular file.

commit b7154bbd3baa6ae28cd06b7f7b13f4a26b6cc03a
Author: Bastien Nocera <hadess@hadess.net>
Date:   Mon Jun 23 16:32:36 2014 +0200

    Add another magic for OTF fonts
    
    "Version 1.0" as magic, as per:
    http://www.microsoft.com/typography/otspec/otff.htm
    It matches what we use for TTF fonts, but they should be differentiated
    by suffix already.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=80276


> https://bugs.launchpad.net/ubuntu/+source/gnome-font-viewer/+bug/1332426/
> comments/9
> 
> So, is the problem in nautilus because it should not use the "name" field
> but the "data" field?
Comment 4 Ronald Malone 2019-09-26 11:14:12 UTC Comment hidden (spam)

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.