[PySide] conforming fonts between platforms
Frank Rueter | OHUfx
frank at ohufx.com
Tue Nov 12 20:45:24 CET 2013
Thanks for confirming
Sent with AquaMail for Android
http://www.aqua-mail.com
On 12 November 2013 8:00:10 PM anatoly techtonik <techtonik at gmail.com> wrote:
> From my own experience with playing with TTF fonts on Windows (the
> experiment is made with pyglet and checked into its codebase, so it
> may be pyglet bug), there is no guarantee that all symbols in
> monospace font have the same pixel size. It may disrupt layout easily.
> So this setPixelSize looks like the stuff that allows to force proper
> dimensions, and it is the only logical way to do for me.
> --
> anatoly t.
>
>
> On Tue, Nov 12, 2013 at 2:28 AM, Frank Rueter | OHUfx <frank at ohufx.com> wrote:
> > Actually, simply using setPixelSize and letting QT take care of the font
> > family does the job in my case even as a standalone, i.e.:
> >
> > font = QApplication.font()
> > self.fontTitle = font
> > self.fontTitle.setPixelSize(12)
> > self.fontTitle.setBold(True)
> >
> > self.fontSubTitle = QApplication.font()
> > self.fontSubTitle.setPixelSize(10)
> > self.fontSubTitle.setBold(False)
> >
> >
> >
> >
> >
> > On 12/11/13 12:05, Frank Rueter | OHUfx wrote:
> >
> > Actually I realised that in my case I can simply inherit the system font,
> > because my app is meant to run inside of another host app which is already
> > doing the hard work with fonts.
> > So in my case working with QApplication.font() magically solves all my
> > troubles (inside the host app, not as a standalone).
> >
> > I will check in with the guys who wrote the host app to see if they can
> > share the magic solution.
> >
> > Cheers,
> > frank
> >
> >
> > On 12/11/13 09:20, Frank Rueter | OHUfx wrote:
> >
> > thanks Sean,
> >
> > I will give it a go (I'm on Ubunto as well at home)
> >
> > On 11/11/13 20:48, Sean Fisk wrote:
> >
> > Hi Frank,
> >
> > I struggled with this a while ago and have it working on Windows and Mac OS
> > X. Still having some problems on GNU/Linux (specifically targeting Ubuntu)
> > but my team is working on it. We first compile some TTF files into our
> > resources, then import them in our program, then call this:
> >
> > # fonts.py
> >
> > from PySide import QtCore, QtGui
> >
> > def init():
> > """Initialize embedded fonts."""
> > font_dir_resource = QtCore.QResource(':/fonts')
> > font_resource_path = font_dir_resource.absoluteFilePath()
> > for ttf_filename in font_dir_resource.children():
> > # DON'T use `os.path.join()' here because Qt always uses UNIX-style
> > # paths. On Windows `os.sep' is '\\'.
> > res_file = QtCore.QFile('/'.join([font_resource_path,
> > ttf_filename]))
> > # Must re-open the file in read-only mode to read the contents
> > # correctly.
> > res_file.open(QtCore.QIODevice.ReadOnly)
> > byte_array = res_file.readAll()
> > QtGui.QFontDatabase.addApplicationFontFromData(byte_array)
> >
> > And to use it (snippet):
> >
> > class LoginView(QtGui.QDialog):
> > def __init__(self, parent=None):
> > super(LoginView, self).__init__(parent)
> >
> > # ...
> > self.title_font = QtGui.QFont('YourFontName', 46)
> > self.title_font.setStyleStrategy(QtGui.QFont.PreferAntialias)
> > self.title_label = QtGui.QLabel('Your text in your font')
> > self.title_label.setFont(self.title_font)
> >
> > Hope this helps. And if you get it working on GNU/Linux, let me know what
> > you did!
> >
> > Cheers,
> >
> > --
> > Sean Fisk
> >
> >
> > On Mon, Nov 11, 2013 at 2:24 AM, Frank Rueter | OHUfx <frank at ohufx.com>
> > wrote:
> >>
> >> Hi all,
> >>
> >> I am facing the challenge I'm sure many of you have had to deal with
> >> before:
> >>
> >> I need to make sure that the font used in my application looks as
> >> similar as posisble between windows, linux and osx.
> >>
> >> I am currently using 12 point Helvetica, which turns into a 16 pixel
> >> high Sans Nimbus L on my linux box messing up my custom widget's layouts.
> >>
> >> What is the best practise here?
> >> Supposedly it is possible to compile a font into a resource which would
> >> ensure almost identical results, right?! Has anybody ever done this
> >> before?
> >>
> >> Cheers,
> >> frank
> >> _______________________________________________
> >> PySide mailing list
> >> PySide at qt-project.org
> >> http://lists.qt-project.org/mailman/listinfo/pyside
> >
> >
> >
> >
> >
> > _______________________________________________
> > PySide mailing list
> > PySide at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/pyside
> >
> >
> >
> >
> > _______________________________________________
> > PySide mailing list
> > PySide at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/pyside
> >
> >
> >
> > _______________________________________________
> > PySide mailing list
> > PySide at qt-project.org
> > http://lists.qt-project.org/mailman/listinfo/pyside
> >
More information about the PySide
mailing list