Back to index

nux  3.0.0
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes
nux::TextLoader Class Reference

#include <TextLoader.h>

Collaboration diagram for nux::TextLoader:
Collaboration graph

List of all members.


struct  Impl

Public Types


Public Member Functions

 TextLoader ()
 ~TextLoader ()
ObjectPtr< BaseTextureCreateTexture ()

Public Attributes

Property< TextAlignmentalignment
Property< Color > color
Property< std::string > font_name
Property< std::string > text
Property< int > font_size
Property< int > width
Property< int > minimum_width
Property< int > lines

Private Attributes


Detailed Description

Definition at line 27 of file TextLoader.h.

Member Enumeration Documentation


Definition at line 30 of file TextLoader.h.

Constructor & Destructor Documentation

Definition at line 197 of file TextLoader.cpp.

  : alignment(TextAlignment::ALIGN_CENTER)
  , font_name("Ubuntu")
  , font_size(10)
  , width(-1)
  , minimum_width(0)
  , lines(1)
  , pimpl(new TextLoader::Impl(this))


Definition at line 209 of file TextLoader.cpp.

  delete pimpl;

Member Function Documentation

Definition at line 214 of file TextLoader.cpp.

  ObjectPtr<BaseTexture> result;
  Size sz = pimpl->ComputeTextSize();

  if (sz.width == 0 || sz.height == 0)
    return result;

  CairoGraphics* cairo_graphics = new CairoGraphics(CAIRO_FORMAT_ARGB32, std::max<int>(sz.width, minimum_width()), sz.height);
  cairo_t* cairo_ctx = cairo_graphics->GetContext();
  cairo_set_operator(cairo_ctx, CAIRO_OPERATOR_CLEAR);
  cairo_set_operator(cairo_ctx, CAIRO_OPERATOR_OVER);

  pimpl->RasterizeText(cairo_ctx, color);

  NBitmapData* bitmap = cairo_graphics->GetBitmap();

  // NTexture2D is the high level representation of an image that is backed by
  // an actual opengl texture.

  BaseTexture* rasterized_text_texture = NULL;

  rasterized_text_texture = GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();

  result = rasterized_text_texture;
  rasterized_text_texture->UnReference(); // get rid of our ref so the owner is the only one who gets it
  rasterized_text_texture = NULL;

  delete bitmap;
  delete cairo_graphics;
  cairo_graphics = NULL;

  return result;

Here is the call graph for this function:

Member Data Documentation

Definition at line 40 of file TextLoader.h.

Definition at line 42 of file TextLoader.h.

Definition at line 44 of file TextLoader.h.

Definition at line 48 of file TextLoader.h.

Definition at line 54 of file TextLoader.h.

Definition at line 52 of file TextLoader.h.

Definition at line 59 of file TextLoader.h.

Definition at line 46 of file TextLoader.h.

Definition at line 50 of file TextLoader.h.

The documentation for this class was generated from the following files: