]> git.lyx.org Git - lyx.git/blobdiff - src/ParagraphMetrics.cpp
SCons: msvc does not need this /TP option any more after we rename .C => .cpp. Also...
[lyx.git] / src / ParagraphMetrics.cpp
index 2d5914644d2f5f9a61c03b11ae9962adf05eb5d1..9e2e7ba74de6b92b412f2afafdc649181dd85fe1 100644 (file)
@@ -179,16 +179,42 @@ int ParagraphMetrics::rightMargin(Buffer const & buffer) const
 {
        BufferParams const & params = buffer.params();
        TextClass const & tclass = params.getTextClass();
-       docstring trmarg = from_utf8(tclass.rightmargin());
-       docstring lrmarg = from_utf8(par_->layout()->rightmargin);
        frontend::FontMetrics const & fm = theFontMetrics(params.getFont());
        int const r_margin =
                lyx::rightMargin()
-               + fm.signedWidth(trmarg)
-               + fm.signedWidth(lrmarg)
+               + fm.signedWidth(tclass.rightmargin())
+               + fm.signedWidth(par_->layout()->rightmargin)
                * 4 / (par_->getDepth() + 4);
 
        return r_margin;
 }
 
+
+int ParagraphMetrics::singleWidth(pos_type pos, Font const & font) const
+{
+       char_type c = par_->getChar(pos);
+
+       // The most special cases are handled first.
+       if (c == Paragraph::META_INSET)
+               return par_->getInset(pos)->width();
+
+       if (!isPrintable(c))
+               return theFontMetrics(font).width(c);
+
+       Language const * language = font.language();
+       if (language->rightToLeft()) {
+               if (language->lang() == "arabic_arabtex" ||
+                       language->lang() == "arabic_arabi" ||
+                       language->lang() == "farsi") {
+                               if (Encodings::isComposeChar_arabic(c))
+                                       return 0;
+                               c = par_->transformChar(c, pos);
+               } else if (language->lang() == "hebrew" &&
+                       Encodings::isComposeChar_hebrew(c))
+                       return 0;
+       }
+       return theFontMetrics(font).width(c);
+}
+
+
 } // namespace lyx