commit f9bff2d9b1e34a82e77e7f1041755b71045c7006
Author: Stephan Witt <[email protected]>
Date:   Sat Oct 18 15:30:58 2014 +0200

     #9130 Text in main work area isn't rendered with high resolution
    Add display_pixel_ratio to buffer params to use it for displays with high 
resolution.
    It holds the highest ratio between physical pixels and device-independent 
pixels of the LyX application.
    Preview snippets will be generated using this value to get high resolution 
preview.

diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index cde0419..bfd1676 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -659,6 +659,13 @@ BufferParams const & Buffer::masterParams() const
 }
 
 
+double Buffer::fontScalingFactor() const
+{
+       return isExporting() ? 75.0 * params().html_math_img_scale
+               : 0.01 * lyxrc.dpi * lyxrc.zoom * lyxrc.preview_scale_factor * 
params().display_pixel_ratio;
+}
+
+
 ParagraphList & Buffer::paragraphs()
 {
        return text().paragraphs();
diff --git a/src/Buffer.h b/src/Buffer.h
index 29992f9..ad6aeb8 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -236,6 +236,8 @@ public:
        /// read the header, returns number of unknown tokens
        int readHeader(Lexer & lex);
 
+       double fontScalingFactor() const;
+
 private:
        ///
        typedef std::map<Buffer const *, Buffer *> BufferMap;
diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp
index 8ae249e..01927a7 100644
--- a/src/BufferParams.cpp
+++ b/src/BufferParams.cpp
@@ -417,6 +417,7 @@ BufferParams::BufferParams()
        html_math_output = MathML;
        html_math_img_scale = 1.0;
        html_css_as_file = false;
+       display_pixel_ratio = 1.0;
 
        output_sync = false;
        use_refstyle = true;
diff --git a/src/BufferParams.h b/src/BufferParams.h
index 2d7c749..a3836a8 100644
--- a/src/BufferParams.h
+++ b/src/BufferParams.h
@@ -465,6 +465,8 @@ public:
        ///
        double html_math_img_scale;
        ///
+       double display_pixel_ratio;
+       ///
        std::string html_latex_start;
        ///
        std::string html_latex_end;
diff --git a/src/graphics/PreviewImage.cpp b/src/graphics/PreviewImage.cpp
index 3185365..5eecfcc 100644
--- a/src/graphics/PreviewImage.cpp
+++ b/src/graphics/PreviewImage.cpp
@@ -105,6 +105,7 @@ PreviewImage::Impl::Impl(PreviewImage & p, PreviewLoader & 
l,
        : parent_(p), ploader_(l), iloader_(bf),
          snippet_(s), ascent_frac_(af)
 {
+       iloader_.setDisplayPixelRatio(l.displayPixelRatio());
        iloader_.connect(bind(&Impl::statusChanged, this));
 }
 
diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp
index f39bd8e..6e392e5 100644
--- a/src/graphics/PreviewLoader.cpp
+++ b/src/graphics/PreviewLoader.cpp
@@ -581,9 +581,7 @@ void PreviewLoader::Impl::startLoading(bool wait)
                return;
        }
 
-       double const font_scaling_factor = 
-               buffer_.isExporting() ? 75.0 * 
buffer_.params().html_math_img_scale 
-                       : 0.01 * lyxrc.dpi * lyxrc.zoom * 
lyxrc.preview_scale_factor;
+       double const font_scaling_factor = buffer_.fontScalingFactor();
        
        // The conversion command.
        ostringstream cs;
@@ -650,6 +648,11 @@ void PreviewLoader::Impl::startLoading(bool wait)
 }
 
 
+double PreviewLoader::displayPixelRatio() const
+{
+       return buffer().params().display_pixel_ratio;
+}
+
 void PreviewLoader::Impl::finishedGenerating(pid_t pid, int retval)
 {
        // Paranoia check!
diff --git a/src/graphics/PreviewLoader.h b/src/graphics/PreviewLoader.h
index 6910984..23af013 100644
--- a/src/graphics/PreviewLoader.h
+++ b/src/graphics/PreviewLoader.h
@@ -91,6 +91,8 @@ public:
        /// The foreground color used
        static ColorCode foregroundColor() { return Color_preview; }
 
+       double displayPixelRatio() const ;
+
 private:
        /// noncopyable
        PreviewLoader(PreviewLoader const &);

Reply via email to