Permalink
Browse files

Finally figured out how to get true DPI from MacOSX

  • Loading branch information...
Pierre Marchand
Pierre Marchand committed Jan 12, 2011
1 parent 696fca4 commit 7049936351baf9df4b7803518150db1605b08b60
Showing with 40 additions and 14 deletions.
  1. +1 −0 src/CMakeLists.txt
  2. +7 −1 src/filterbar.ui
  3. +1 −1 src/remotedir.cpp
  4. +12 −11 src/remotedir.h
  5. +19 −1 src/typotek.cpp
View
@@ -367,6 +367,7 @@ IF(APPLE)
${SHAPERS_LIBRARIES}
${PYTHON_LIBRARIES}
${LIBPODOFO_LIBRARY}
+ "-framework ApplicationServices"
)
# here we’ll poupulate the bundle in order to make it
View
@@ -402,8 +402,14 @@
</property>
<item>
<widget class="QLabel" name="label_6">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="text">
- <string>Current</string>
+ <string>Current filter</string>
</property>
</widget>
</item>
View
@@ -266,7 +266,7 @@ void RemoteDir::slotProgress(int done, int total)
}
/// FontInfo **********************************************
-QString FontInfo::dump()
+QString RemoteDir::FontInfo::dump()
{
QString sep(" | ");
return file + sep + family + sep + variant + sep + type + sep +tags.join(sep);
View
@@ -22,17 +22,6 @@ class QBuffer;
class QByteArray;
class QHttp;
-struct FontInfo
-{
- QString file;
- QString family;
- QString variant;
- QString type;
- QString info;
- QStringList tags;
- QPixmap pix;
- QString dump();
-};
/**
@author Pierre Marchand <pierremarc@oep-h.com>
@@ -41,6 +30,18 @@ class RemoteDir : public QObject
{
Q_OBJECT
public:
+ struct FontInfo
+ {
+ QString file;
+ QString family;
+ QString variant;
+ QString type;
+ QString info;
+ QStringList tags;
+ QPixmap pix;
+ QString dump();
+ };
+
RemoteDir ( const QStringList &dirs );
~RemoteDir();
View
@@ -82,6 +82,9 @@
#define MAX_RECENT_PYSCRIPTS 10
#endif // HAVE_PYTHONQT
+#ifdef Q_WS_MAC
+#include <ApplicationServices/ApplicationServices.h>
+#endif
typotek* typotek::instance = 0;
bool typotek::matrix = false;
@@ -159,6 +162,21 @@ typotek::typotek()
m_dpiX = ( double ) QApplication::desktop()->physicalDpiX();
m_dpiY = ( double ) QApplication::desktop()->physicalDpiY();
+#ifdef Q_WS_MAC
+ CGDirectDisplayID macDId = CGMainDisplayID();
+ CGRect macDRect = CGDisplayBounds(macDId);
+ CGSize macDSize = CGDisplayScreenSize(macDId);
+
+ double macDisplayPxWidth(macDRect.size.width);
+ double macDisplayPxHeight(macDRect.size.height);
+ double macDisplayPhysicalWidth(double(macDSize.width) / 25.4);
+ double macDisplayPhysicalHeight(double(macDSize.height) / 25.4);
+
+ m_dpiX = macDisplayPxWidth / macDisplayPhysicalWidth;
+ m_dpiY = macDisplayPxHeight / macDisplayPhysicalHeight;
+#endif
+
+ qDebug()<< m_dpiX << m_dpiY;
}
void typotek::initMatrix()
@@ -1285,7 +1303,7 @@ void typotek::slotRemoteIsReady()
QStringList tagsList(FMFontDb::DB()->getTags());
// qDebug()<<"typotek::slotRemoteIsReady()";
- QList<FontInfo> listInfo(remoteDir->rFonts());
+ QList<RemoteDir::FontInfo> listInfo(remoteDir->rFonts());
// qDebug()<< "Have got "<< listInfo.count() <<"remote font descriptions";
for(int rf(0) ;rf < listInfo.count(); ++rf)
{

0 comments on commit 7049936

Please sign in to comment.