riuson / lcd-image-converter

Tool to create bitmaps and fonts for embedded applications, v.2
https://lcd-image-converter.riuson.com/
GNU General Public License v3.0
337 stars 80 forks source link

Font Setup->Style selectin doesn't display all the weights of the OpenType fonts. #27

Closed riuson closed 9 years ago

riuson commented 10 years ago

From kurt.ozc...@gmail.com on May 14, 2014 03:12:30

Here is the repro:

  1. Download Anonymous Pro font,
  2. Start the tool and select New Font,
  3. Select Anonymous Pro as source

I expect to see at least Normal but only shows Bold and Italic.

LCD Image Converter version is 6998b5e, Qt 5.1.1.

OS is Windows 7 64 bit.

Does the tool implements filter for certain OpenType weights and only displays those that corresponds to TrueType fonts?

Original issue: http://code.google.com/p/lcd-image-converter/issues/detail?id=27

riuson commented 10 years ago

From riu...@gmail.com on May 21, 2014 21:48:45

Status: Accepted
Owner: riu...@gmail.com

riuson commented 10 years ago

From riu...@gmail.com on June 03, 2014 10:44:46

Something changed or broken between Qt 4.8.6 and Qt 5.1.1 ...

riuson commented 10 years ago

From riu...@gmail.com on June 07, 2014 23:45:12

Try this: http://sourceforge.net/projects/lcd-image-converter/files/beta/lcd-image-converter-20140608-beta.zip/download -----------------------------------------------

Test source:

include "mainwindow.h"

include "ui_mainwindow.h"

include

include

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this);

QString family = "Anonymous Pro";
QFontDatabase fonts;

QStringList styles = fonts.styles(family);
qDebug() << styles;

}

MainWindow::~MainWindow() { delete ui; }

Qt 4.8.6 output: ("Bold", "Bold Italic", "Italic", "Normal")

Qt 5.1.1 output: ("Bold", "Bold Italic")

Status: Started

riuson commented 10 years ago

From kurt.ozc...@gmail.com on June 17, 2014 11:06:32

It works, thanks. Still the project team might think about how to create font files for the OpenType fonts with specified weights, instead of their TrueType corresponding versions, which in many cases there might be any. I have confirmed at least lcd-image-converter recognizes the fonts windows platform supports.

riuson commented 10 years ago

From riu...@gmail.com on June 18, 2014 05:08:33

Hmm... Give me example, please. I have installed first found OpenType ( http://www.fontspace.com/gluk/foglihtenno07 ) and it works, as i can see.

Attachment: foglihten.png

riuson commented 10 years ago

From riu...@gmail.com on August 16, 2014 11:09:17

Archive with Anonymous Pro font contains 4 files:

Anonymous Pro "Bold Italic", Anonymous Pro "Bold", Anonymous Pro "Italic", Anonymous Pro "Regular".

If you install "Bold", 2 styles will be accessible: ("Bold", "Bold Italic"). "Italic" -> ("Italic", "Bold Italic"). "Bold Italic" -> ("Bold Italic"). "Regular" -> ("Normal", "Bold", "Italic", "Bold Italic").

"Regular", "Italic" -> ("Normal", "Bold", "Italic", "Bold Italic"). "Regular", "Italic", "Bold" -> ("Normal", "Bold", "Italic", "Bold Italic"). "Regular", "Italic", "Bold", "Bold Italic" -> ("Normal", "Bold", "Italic", "Bold Italic"). "Regular", "Bold", "Bold Italic", "Italic" -> ("Normal", "Bold", "Italic", "Bold Italic").

"Bold", "Bold Italic", "Italic" and "Regular" -> ("Bold", "Bold Italic"). "Italic", "Bold", "Bold Italic" and "Regular" -> ("Italic", "Bold Italic"). "Italic", "Bold", "Bold Italic" -> ("Italic", "Bold Italic"). ...

So, just install only "Regular" font (Anonymous Pro.ttf) or change order of files installation. I think there is a bug in Qt font database filling.

riuson commented 10 years ago

From riu...@gmail.com on August 17, 2014 01:09:18

Qt on Windows enumerates fonts using WinAPI function EnumFontFamiliesEx ( http://msdn.microsoft.com/en-us/library/dd162620%28VS.85%29.aspx ). "If there are two fonts with the same name, only one is enumerated".

When font added to database:

add original font; // add fonts windows can generate for us: if (fontWeight <= DemiBold) { add original font with Bold weight; } if (fontStyle not Italic) { add original font with Italic style; } if ((fontWeight <= DemiBold) and (fontStyle not Italic)) { add original font with Bold weight + Italic style; }

If first registered font in family has Regular style, then added Regular, Bold, Italic and Bold Italic. If first registered font in family has Italic style, then added Italic and Bold Italic. ...

Enumarating fonts with same name don't solve problem.

Attachment: windows notepad.png original.png patched.png

riuson commented 10 years ago

From riu...@gmail.com on August 17, 2014 03:15:10

I do not know this is a bug or normal behavior. I have created a query in the bug tracker on qt-project... https://bugreports.qt-project.org/browse/QTBUG-40828

riuson commented 9 years ago

Fixed with Qt 5.4 release. Downloads: http://sourceforge.net/projects/lcd-image-converter/files/lcd-image-converter-20141214.zip/download Sources: https://github.com/riuson/lcd-image-converter/commit/ff449e0c73a0ed4c77e835441f7593daca6e3da1