octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Update - LaTeX markup project


From: Patrick Noffke
Subject: Re: Update - LaTeX markup project
Date: Mon, 15 Jul 2013 13:41:30 -0500

On Sun, Jul 14, 2013 at 3:02 PM, Michael Goffioul
<address@hidden> wrote:
> On Sat, Jul 13, 2013 at 11:10 AM, Patrick Noffke <address@hidden>
> wrote:
>>
>> Andrej,
>>
>> On Thu, Jul 11, 2013 at 3:18 PM, Andrej Lojdl <address@hidden>
>> wrote:
>
> class base_text_renderer
> {
>   ...
> };
>
> class ft_text_renderer : public base_text_renderer
> {
>   ...
> };
>
> class latex_text_renderer : public base_text_renderer
> {
>   ...
> };
>
> class text_renderer
> {
> public:
>   text_renderer (const caseless_str& interpreter = caseless_str ())
>     : rep (0)
>     {
>       if (interpreter.compare ("latex"))
>         rep = new latex_text_renderer ();
>       else
>         rep = new ft_text_renderer ();
>     }
>
>   ~text_renderer (void) { delete rep; }
>
>   void set_font (...) { rep->set_font (...); }
>   void set_color (...) { rep->set_color (...); }
>
>   void text_to_pixel (...) { rep->text_to_pixel (...); }
>   ...
>
> private:
>   base_text_renderer *rep;
> };
>
> void
> text::properties::update_text_extent (void)
> {
>   ...
>   text_renderer r (get_interpreter ());
>
>   r.set _font (...);
>   r.set_color (...);
>   r.text_to_pixel (...);
>   ...
> }
>
> The above code is not highly efficient, because it re-renders the text on
> every update_text_extent call (that's also the case with the existing code).
> In future optimization, we could render the text only when we actually need
> it instead, and cache the result (which would be invalidated by
> update_text_extent). But this can be done later.
>

You still have to handle the case that HAVE_FREETYPE is not defined*.
So inside the text_renderer class, if HAVE_FREETYPE is not defined,
but the interpreter is 'none', then rep should be set to 0 (or nullptr
if that is our convention and the compiler supports it).  Then in all
text_renderer methods that use rep (including the destructor), there
needs to be nullptr checks on rep.

Would it be acceptable to check for the presence of the necessary
latex binaries at octave startup (rather than each time latex_renderer
is instantiated)?  Then we could use a static bool in latex_renderer
that is initialized during startup.  Would it make sense to print a
warning about missing latex binaries only the first time, or every
time latex_renderer is used?

* Unless you agree not to support FLTK or Qt if the text renderer is
unavailable.  This is what I was getting at with my point 2 in my last
message.

Patrick


reply via email to

[Prev in Thread] Current Thread [Next in Thread]