lyx_mirror/src/tex2lyx/dummy_impl.cpp
Jean-Marc Lasgouttes 66fa801e74 Improve support for on screen length calculation
The computation of length on screen depend in particular of the computation of the size of an em. Many places of the code used to rely on the width of the M character, which is not really correct:
http://en.wikipedia.org/wiki/Em_%28typography%29

In digital typography, the best value to use is the point size of the font.

* Implement FontMetrics::em(), which returns the value in pixels of the EM unit.
 Convert code to use it.

* Introduce Length::inPixel(MetricsBase const &), which takes the textwidth and em information from the MetricsBase object. Convert code to use it.

* Fix several places where Length::inPixel is used without a proper em value.

* add mathed_font_em() helper function. It should eventually be removed like some other functions in MathSupport.

* Add dummy implementation of FontMetrics to tex2lyx for linking purposes.
2015-03-26 17:10:15 +01:00

148 lines
2.1 KiB
C++

/**
* \file dummy_impl.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Jean-Marc Lasgouttes
*
* Full author contact details are available in file CREDITS.
*/
/**
* This file contains dummy implementation of some methods that are
* needed byclasses used by tex2lyx. This allows to reduce the number
* of classes we have to link against.
*/
// {[(
#include <config.h>
#include "Format.h"
#include "LaTeXFeatures.h"
#include "LyXRC.h"
#include "output_xhtml.h"
#include "support/Messages.h"
#include <iostream>
using namespace std;
namespace lyx {
//
// Dummy Alert support (needed by TextClass)
//
namespace frontend {
namespace Alert {
void warning(docstring const & title, docstring const & message,
bool const &)
{
cerr << to_utf8(title) << "\n" << to_utf8(message) << endl;
}
}
}
//
// Dummy TexRow support (needed by docstream)
//
void TexRow::newline()
{}
void TexRow::newlines(int)
{}
//
// Dummy LyXRC support
//
LyXRC lyxrc;
/** Note that some variables are not initialized correctly. Hopefully
* they are not used in our code (currently valgrind does not complain).
* Linking against the full LyXRC.cpp forces us to pull too much
* stuff.
*/
LyXRC::LyXRC()
{}
//
// Dummy translation support (needed at many places)
//
Messages messages_;
Messages const & getMessages(string const &)
{
return messages_;
}
Messages const & getGuiMessages()
{
return messages_;
}
//
// Dummy formats support (needed by Lexer)
//
Formats formats;
bool Formats::isZippedFile(support::FileName const&) const
{
return false;
}
//
// Dummy features support (needed by ModuleList)
//
bool LaTeXFeatures::isAvailable(string const &)
{
return true;
}
string alignmentToCSS(LyXAlignment)
{
return string();
}
//
// Dummy FontMetrics (needed by Length)
//
class FontMetrics {
int em() const { return 0; };
};
class FontInfo;
FontMetrics const & theFontMetrics(FontInfo const &) {
static FontMetrics dummy;
return dummy;
}
//
// Keep the linker happy on Windows
//
void lyx_exit(int)
{}
}