Fresco/Berlin/modules/Fonts Makefile.in,NONE,1.1 Font.cc,1.2,1.3 Font.hh,1.1,1.2 FontKitImpl.cc,1.3,1.4 FontKitImpl.hh,1.4,1.5 Glyph.cc,1.2,1.3 Glyph.hh,1.2,1.3
Nick Lewycky <[email protected]>
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/Berlin/modules/Fonts In directory purcel:/tmp/cvs-serv2948/Berlin/modules/Fonts Modified Files: Font.cc Font.hh FontKitImpl.cc FontKitImpl.hh Glyph.cc Glyph.hh Added Files: Makefile.in Log Message: It compiles. It doesn't work. --- NEW FILE: Makefile.in --- # $Id: Makefile.in,v 1.1 2003/02/16 03:47:47 nicholas Exp $ # # This source file is a part of the Fresco Project. # Copyright (C) 1999, 2000 Stefan Seefeld <[email protected]> # http://www.fresco.org # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 675 Mass Ave, Cambridge, # MA 02139, USA. SHELL := /bin/sh abs_top_srcdir := @abs_top_srcdir@ top_builddir := @top_builddir@ srcdir := $(abs_top_srcdir)/modules/Fonts cdir := $(top_builddir)/config include $(cdir)/local.mk EXTRA_CPPFLAGS += @FREETYPE_CPPFLAGS@ EXTRA_LIBS += @FREETYPE_LIBS@ SRC := Font.cc FontKitImpl.cc Glyph.cc MODULE := FontKit include $(cdir)/module.mk Index: Font.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Fonts/Font.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Font.cc 12 Jan 2003 02:54:09 -0000 1.2 +++ Font.cc 16 Feb 2003 03:47:47 -0000 1.3 @@ -24,82 +24,83 @@ namespace Berlin { -namespace Font +namespace FontKit { -Font::Font(const char *filename, int size, int xdpi, int ydpi, - FT_Library library) - : my_ftlib(library), my_size(size), my_xdpi(xdpi), my_ydpi(ydpi) +Font::Font(const char *filename, int size, FT_Library library) + : my_ftlib(library), my_size(size) { - FT_New_Face(my_ftlib, filename.c_str(), 0, &my_face); - FT_Set_Char_Size(my_face, 0, my_size*64, xdpi, ydpi); + FT_New_Face(my_ftlib, filename, 0, &my_face); + FT_Set_Char_Size(my_face, 0, my_size*64, 0, 0); } Font::~Font() {} -Glyph_ptr Font::glyph_char(Unichar c) +Fresco::Glyph_ptr Font::glyph_char(Fresco::Unichar c, short unsigned int xdpi, short unsigned int ydpi) { - return new Glyph(my_face, FT_Get_Char_Index(my_face, (FT_ULong)uc)); + FT_Set_Char_Size(my_face, 0, my_size*64, xdpi, ydpi); + GlyphImpl *glyph = new GlyphImpl(my_face, c); + return Fresco::Glyph_var(glyph->_this()); } -bool Font::has_char(Unichar c) +CORBA::Boolean Font::has_char(Fresco::Unichar c) { - return true; + return FT_Get_Char_Index(my_face, c); } -bool Font::can_display(Unichar begin, Unichar end) +CORBA::Boolean Font::can_display(Fresco::Unichar begin, Fresco::Unichar end) { return true; } -Unistring Font::encoding() +Fresco::Unistring *Font::encoding() { - // + return new Fresco::Unistring(Unicode::to_CORBA(Babylon::String("encoding NYI"))); } -Unistring Font::font_family() +Fresco::Unistring *Font::font_family() { - return new Unistring(Unicode::to_CORBA(Babylon::String(my_face->family_name))); + return new Fresco::Unistring(Unicode::to_CORBA(Babylon::String(my_face->family_name))); } -Unistring Font::font_style() +Fresco::Unistring *Font::font_style() { - return new Unistring(Unicode::to_CORBA(Babylon::String(my_face->style_name))); + return new Fresco::Unistring(Unicode::to_CORBA(Babylon::String(my_face->style_name))); } -Unistring Font::fullname() +Fresco::Unistring *Font::fullname() { - // ?? + return new Fresco::Unistring(Unicode::to_CORBA(Babylon::String("Fullname NYI"))); } -void Font::font_metrics(FontMetrics &fm) +void Font::font_metrics(Fresco::FontMetrics &fm) { fm.ascent = my_face->ascender; fm.descent = my_face->descender; fm.baseline = my_face->height; fm.underline_offset = my_face->underline_position; - fm.underline_thickness = my_face->underline_width; + fm.underline_thickness = my_face->underline_thickness; } -Coord height() const +Fresco::Coord Font::height() { return my_size; } -float angle() +CORBA::Float Font::angle() { float angle = 0.; void *htable = FT_Get_Sfnt_Table(my_face, ft_sfnt_hhea); if (htable) { - TT_HoriHeader *header = *htable; + TT_HoriHeader *header = (TT_HoriHeader*)htable; if (header->caret_Slope_Run != 0) angle = header->caret_Slope_Rise / header->caret_Slope_Run; } void *vtable = FT_Get_Sfnt_Table(my_face, ft_sfnt_vhea); if (vtable) { - TT_VertHeader *header = *vtable; + TT_VertHeader *header = (TT_VertHeader*)vtable; if (header->caret_Slope_Run != 0) angle = header->caret_Slope_Rise / header->caret_Slope_Run; } @@ -107,20 +108,20 @@ return angle; } -float caret_offset() +CORBA::Float Font::caret_offset() { float offset = 0.; void *htable = FT_Get_Sfnt_Table(my_face, ft_sfnt_hhea); if (htable) { - TT_HoriHeader *header = *htable; + TT_HoriHeader *header = (TT_HoriHeader*)htable; if (header->caret_Offset != 0) offset = header->caret_Offset; } void *vtable = FT_Get_Sfnt_Table(my_face, ft_sfnt_vhea); if (vtable) { - TT_VertHeader *header = *vtable; + TT_VertHeader *header = (TT_VertHeader*)vtable; if (header->caret_Slope_Run != 0) offset = header->caret_Offset; } Index: Font.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Fonts/Font.hh,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Font.hh 8 Jan 2003 01:42:31 -0000 1.1 +++ Font.hh 16 Feb 2003 03:47:47 -0000 1.2 @@ -19,41 +19,53 @@ * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, * MA 02139, USA. */ -#ifndef _Font_hh -#define _Font_hh +#ifndef _FontKit_Font_hh +#define _FontKit_Font_hh #include <Fresco/config.hh> #include <Fresco/Font.hh> -#include "Berlin/RefCountBaseImpl.hh" -#include "Berlin/IdentifiableImpl.hh" +#include <Fresco/Unicode.hh> +#include <Berlin/RefCountBaseImpl.hh> +#include <Berlin/IdentifiableImpl.hh> +#include "Glyph.hh" #include <ft2build.h> #include FT_FREETYPE_H +#include FT_TRUETYPE_TABLES_H + +namespace Berlin +{ +namespace FontKit +{ class Font : public virtual POA_Fresco::Font, public virtual RefCountBaseImpl, public virtual IdentifiableImpl { public: - Font(const char *filename, int size, int xdpi, int ydpi, - FT_Library library); - virtual ~Font(); + Font(const char *filename, int size, FT_Library library); + virtual ~Font(); - virtual Glyph_ptr glyph_char(Unichar c); - virtual CORBA::Boolean has_char(Unichar c); - virtual CORBA::Boolean can_display(Unichar begin, Unichar end); - virtual Unistring* encoding(); - virtual Unistring* font_family(); - virtual void font_metrics(FontMetrics& fm); - virtual Unistring* font_style(); - virtual Unistring* fullname(); - virtual Coord height(); - virtual Vertex kerning(Unichar first, Unichar second); - virtual CORBA::Float angle(); - virtual CORBA::Float caret_offset(); + virtual Fresco::Glyph_ptr glyph_char(Fresco::Unichar c, short unsigned int xdpi, short unsigned int ydpi); + virtual CORBA::Boolean has_char(Fresco::Unichar c); + virtual CORBA::Boolean can_display(Fresco::Unichar begin, + Fresco::Unichar end); + virtual Fresco::Unistring* encoding(); + virtual Fresco::Unistring* font_family(); + virtual void font_metrics(Fresco::FontMetrics& fm); + virtual Fresco::Unistring* font_style(); + virtual Fresco::Unistring* fullname(); + virtual Fresco::Coord height(); + virtual Fresco::Vertex kerning(Fresco::Unichar first, Fresco::Unichar second); + virtual CORBA::Float angle(); + virtual CORBA::Float caret_offset(); private: - FT_Face my_face; - int my_size, my_xdpi, my_ydpi; + FT_Library my_ftlib; + FT_Face my_face; + Fresco::Coord my_size; }; + +} // namespace +} // namespace #endif // header guard Index: FontKitImpl.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Fonts/FontKitImpl.cc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- FontKitImpl.cc 8 Jan 2003 01:42:31 -0000 1.3 +++ FontKitImpl.cc 16 Feb 2003 03:47:47 -0000 1.4 @@ -22,131 +22,183 @@ #include <Prague/Sys/Tracer.hh> #include <Fresco/config.hh> +#include <Fresco/DrawTraversal.hh> +#include <Berlin/MonoGraphic.hh> #include "FontKitImpl.hh" +#include "Font.hh" +using namespace Prague; using namespace Fresco; +using namespace Berlin::FontKit; class FontDecorator : public MonoGraphic { - public: - FontDecorator(Font f) : my_font(f) {} - virtual void - traverse(Traversal_ptr traversal) - { - traversal->visit(Graphic_var(_this())); - } - virtual void - draw(DrawTraversal_ptr traversal) - { - DrawingKit_var drawing = traversal->drawing(); - // and do... NOTHING! yet. - MonoGraphic::traverse(traversal); - } - virtual void - pick(PickTraversal_ptr traversal) - { - MonoGraphic::traverse(traversal); - } - private: - Font_ptr my_font; +public: + FontDecorator(Font_ptr f) : my_font(f) {} +#if 0 + virtual void traverse(Traversal_ptr traversal) + { + traversal->visit(Graphic_var(_this())); + } +#endif + virtual void draw(DrawTraversal_ptr traversal) + { + DrawingKit_var drawing = traversal->drawing(); + // and do... NOTHING! yet. + MonoGraphic::traverse(traversal); + } +#if 0 + virtual void pick(PickTraversal_ptr traversal) + { + MonoGraphic::traverse(traversal); + } +#endif +private: + Font_ptr my_font; }; class FontSizeDecorator : public MonoGraphic { - public: - FontSizeDecorator(Coord s) : my_size(s) {} - virtual void - traverse(Traversal_ptr traversal) - { - traversal->visit(Graphic_var(_this())); - } - virtual void - draw(DrawTraversal_ptr traversal) - { - DrawingKit_var drawing = traversal->drawing(); - // and do... NOTHING! yet. - MonoGraphic::traverse(traversal); - } - virtual void - pick(PickTraversal_ptr traversal) - { - MonoGraphic::traverse(traversal); - } - private: - Coord my_size; +public: + FontSizeDecorator(Coord s) : my_size(s) {} +#if 0 + virtual void traverse(Traversal_ptr traversal) + { + traversal->visit(Graphic_var(_this())); + } +#endif + virtual void draw(DrawTraversal_ptr traversal) + { + DrawingKit_var drawing = traversal->drawing(); + // and do... NOTHING! yet. + MonoGraphic::traverse(traversal); + } +#if 0 + virtual void pick(PickTraversal_ptr traversal) + { + MonoGraphic::traverse(traversal); + } +#endif +private: + Coord my_size; }; -class FontIterator : public virtual POA_Fresco::FontIterator, - public virtual RefCountBase +class FontIterator : public virtual POA_Fresco::FontIterator { - public: - FontIterator::FontIterator(FontKit_var fk) : - my_fk(fk) - {} - Font_ptr child() const +public: + FontIterator::FontIterator(FontKitImpl *fk) + : my_fk(fk) + { + Prague::Path path = RCManager::get_path("fontpath"); + scan(path); + } + Font_ptr child() const + { + return my_fk->_cxx_default(); + } + void next() { faces_iterator++;} + void prev() { faces_iterator--;} + void destroy() { delete this;}//deactivate();} + + void begin() { faces_iterator = faces.begin();} + void end() { faces_iterator = faces.end();} + void scan(Prague::Path path) + { + FT_Face my_face; + for (Prague::Path::iterator i = path.begin(); i != path.end(); ++i) { - return my_fk->default(); + Directory directory(*i, Directory::alpha); + for (Prague::Directory::iterator j = directory.begin(); j != directory.end(); ++j) + { + if ((*j)->name()[0] == '.') continue; + std::string file = (*j)->long_name(); + if (FT_New_Face(*(my_fk->get_ftlibrary()), file.c_str(), 0, &my_face)) + { + Logger::log(Logger::text) << "FontKit: file " << file << " is not a font." << std::endl; + continue; + } + faces.push_back(file); + } } - void next() {} - void prev() {} - void destroy() { deactivate();} - private: - FontKit_var my_fk; + } +private: + FontKitImpl *my_fk; + std::vector<std::string> faces; + std::vector<std::string>::iterator faces_iterator; }; -FontKitImpl::FontKitImpl(const std::string &id, const Fresco::Kit::PropertySeq &p) +FontKitImpl::FontKitImpl(const std::string &id, + const Fresco::Kit::PropertySeq &p) : KitImpl(id, p) { - FT_Init_Freetype(&my_library); + FT_Init_FreeType(&my_library); + FT_Face face; } FontKitImpl::~FontKitImpl() {} -Graphic_ptr -FontKitImpl::set_font(Graphic_ptr g, Font f) +Font_ptr FontKitImpl::_cxx_default() { - Trace trace("FontKitImpl::set_font"); - FontDecorator *decorator = new FontDecorator(f); - activate(decorator); - decorator->body(f); - return decorator->_this(); + return Font_ptr(new Font("/usr/share/fonts/truetype/commercial/arialuni.ttf", 12, my_library)); } -Graphic_ptr -FontKitImpl::size(Graphic_ptr g, Coord s) +Font_ptr FontKitImpl::filename(const char *fn, const Fresco::Unistring &style, + const Fresco::Coord size) { - Trace trace("FontKitImpl::size"); - FontSizeDecorator *decorator = new FontSizeDecorator(s); - activate(decorator); - decorator->body(f); - return decorator->_this(); + return Font_ptr(new Font(fn, size, my_library)); } -Graphic_ptr -FontKitImpl::style(Graphic_ptr g, const Unistring &style) +Font_ptr FontKitImpl::provide(const Fresco::Unistring &family, + const Fresco::Unistring &style, + const Fresco::Coord size) { - Trace trace("FontKitImpl::style"); - return Graphic::_nil(); + return _cxx_default(); + //return Font_ptr::_nil(); } -Graphic_ptr -FontKitImpl::delta_size(Graphic_ptr g, Coord ds) +Fresco::Graphic_ptr FontKitImpl::set_font(Fresco::Graphic_ptr g, Font_ptr f) +{ + Trace trace("FontKitImpl::set_font"); + return create_and_set_body<Graphic>(new FontDecorator(f), g); +} + +Fresco::Graphic_ptr FontKitImpl::size(Fresco::Graphic_ptr g, + const Fresco::Coord s) +{ + Trace trace("FontKitImpl::size"); + return create_and_set_body<Graphic>(new FontSizeDecorator(s), g); +} + +Fresco::Graphic_ptr FontKitImpl::style(Fresco::Graphic_ptr g, + const Fresco::Unistring &style) +{ + Trace trace("FontKitImpl::style"); + return Graphic::_nil(); +} + +Fresco::Graphic_ptr FontKitImpl::delta_size(Fresco::Graphic_ptr g, + const Fresco::Coord ds) { Trace trace("FontKitImpl::delta_size"); return Graphic::_nil(); } -Graphic_ptr -FontKitImpl::delta_style(Graphic_ptr g, const Unistring &style) +Fresco::Graphic_ptr FontKitImpl::delta_style(Fresco::Graphic_ptr g, + const Fresco::Unistring &style) { - Trace trace("FontKitImpl::delta_style"); - return Graphic::_nil(); + Trace trace("FontKitImpl::delta_style"); + return Graphic::_nil(); } -FontIterator_ptr -FontKitImpl::first_font() -{} +FT_Library *FontKitImpl::get_ftlibrary() +{ + return &my_library; +} -FontIterator_ptr -FontKitImpl::last_font() -{} +FontIterator_ptr FontKitImpl::first_font() +{ +} + +FontIterator_ptr FontKitImpl::last_font() +{ +} Index: FontKitImpl.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Fonts/FontKitImpl.hh,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FontKitImpl.hh 8 Jan 2003 01:42:31 -0000 1.4 +++ FontKitImpl.hh 16 Feb 2003 03:47:47 -0000 1.5 @@ -25,15 +25,21 @@ #include <Fresco/config.hh> #include <Fresco/FontKit.hh> #include <Fresco/Font.hh> +#include <Fresco/Graphic.hh> +#include <Fresco/Kit.hh> +#include <Fresco/Types.hh> +#include <Fresco/Unicode.hh> #include <Berlin/KitImpl.hh> +#include <Berlin/Logger.hh> +#include <Berlin/RCManager.hh> +#include <Prague/Sys/Directory.hh> +#include <Prague/Sys/Path.hh> #include <ft2build.h> #include FT_FREETYPE_H -namespace Berlin -{ -namespace FontKit -{ +namespace Berlin { +namespace FontKit { using namespace Fresco; @@ -41,28 +47,46 @@ public KitImpl { public: - FontKitImpl(const std::string &, const Fresco::Kit::PropertySeq &); - virtual ~FontKitImpl(); - virtual KitImpl *clone(const Fresco::Kit::PropertySeq &p) - { - return new FontKitImpl(repo_id(), p); - } - virtual Font_ptr _cxx_default(); - virtual Font_ptr filename(const char* file, const Fresco::Unistring& style, - Coord size); - virtual Font_ptr provide(const Unistring& family, const Unistring& style, - Coord size); - virtual Graphic_ptr set_font(Graphic_ptr g, Font_ptr f); - virtual Graphic_ptr size(Graphic_ptr g, Coord s); - virtual Graphic_ptr style(Graphic_ptr g, const Unistring& s); - virtual Graphic_ptr delta_size(Graphic_ptr g, Coord ds); - virtual Graphic_ptr delta_style(Graphic_ptr g, const Unistring& ds); + class FontIterator : public virtual POA_Fresco::FontIterator + { + public: + FontIterator::FontIterator(FontKitImpl *); + virtual Font_ptr child() const; + virtual void next(); + void prev(); + void destroy(); - virtual FontIterator_ptr first_font(); - virtual FontIterator_ptr last_font(); + void begin(); + void end(); + void scan(Prague::Path); + }; + + + FontKitImpl(const std::string &, const Fresco::Kit::PropertySeq &); + virtual ~FontKitImpl(); + KitImpl *clone(const Fresco::Kit::PropertySeq &p) + { + return new FontKitImpl(repo_id(), p); + } + + virtual Fresco::Font_ptr _cxx_default(); + virtual Fresco::Font_ptr filename(const char* file, const Fresco::Unistring& style, + Fresco::Coord size); + virtual Fresco::Font_ptr provide(const Fresco::Unistring& family, const Fresco::Unistring& style, + const Fresco::Coord size); + virtual Fresco::Graphic_ptr set_font(Fresco::Graphic_ptr g, const Fresco::Font_ptr f); + virtual Fresco::Graphic_ptr size(Fresco::Graphic_ptr g, const Fresco::Coord s); + virtual Fresco::Graphic_ptr style(Fresco::Graphic_ptr g, const Fresco::Unistring& s); + virtual Fresco::Graphic_ptr delta_size(Fresco::Graphic_ptr g, const Fresco::Coord ds); + virtual Fresco::Graphic_ptr delta_style(Fresco::Graphic_ptr g, const Fresco::Unistring& ds); + + virtual FT_Library *FontKitImpl::get_ftlibrary(); + + virtual Fresco::FontIterator_ptr first_font(); + virtual Fresco::FontIterator_ptr last_font(); private: - FT_Library my_library; + FT_Library my_library; }; } // namespace Index: Glyph.cc =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Fonts/Glyph.cc,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Glyph.cc 12 Jan 2003 02:54:09 -0000 1.2 +++ Glyph.cc 16 Feb 2003 03:47:47 -0000 1.3 @@ -24,25 +24,37 @@ #include <Berlin/RasterImpl.hh> #include "Glyph.hh" -Glyph::Glyph(FT_Face face, FT_ULong char_index) - : my_face(face) +GlyphImpl::GlyphImpl(FT_Face face, FT_ULong char_index) + : my_face(face) { + my_tr.xx = 0x10000; + my_tr.xy = 0x00000; + my_tr.yx = 0x00000; + my_tr.yy = 0x10000; FT_Load_Glyph(my_face, char_index, FT_LOAD_DEFAULT); } -Raster_ptr Glyph::bitmap() +Fresco::Raster_ptr GlyphImpl::bitmap() { RasterImpl *raster = new RasterImpl(); activate(raster); FT_Set_Transform(my_face, &my_tr, 0); + FT_Vector origin; + origin.x = 0; + origin.y = 0; + FT_Glyph glyph; FT_Get_Glyph(my_face->glyph, &glyph); FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, &origin, 1); FT_BitmapGlyph glyph_bitmap = (FT_BitmapGlyph)glyph; - Fresco::Raster::Data pixels; + unsigned char *buffer = glyph_bitmap->bitmap.buffer; + int width = glyph_bitmap->bitmap.width; + int height = glyph_bitmap->bitmap.rows; + + Fresco::Raster::ColorSeq pixels; switch (glyph_bitmap->bitmap.pixel_mode) { @@ -51,21 +63,21 @@ std::cout << "WTF;FT_PIXEL_MODE_NONE" << std::endl; break; case FT_PIXEL_MODE_MONO: // MSB 1 bpp - internal_format = GL_ALPHA; - format = GL_ALPHA; - type = GL_UNSIGNED_BYTE; for (int i = 0; i < height; i++) - for (int j = 0; j < width; j++) - pixels[i*w + j] = (buffer[i*(width/8)+(j/8)] & - (0x80 >> j%8)) ? 0xFF : 0; + for (int j = 0; j < width; j++) { + Fresco::Color c; + c.red = (buffer[i*(width/8)+(j/8)] & + (0x80 >> j%8)) ? 0xFFFFFF00 : 0; + c.green = c.red; c.blue = c.red; + } break; case FT_PIXEL_MODE_GRAY: // 8 bpp count of grey levels in num_bytes - internal_format = GL_ALPHA; - format = GL_ALPHA; - type = GL_UNSIGNED_BYTE; for (int i = 0; i < height; i++) - for (int j = 0; j < width; j++) - pixels[i*w+j] = buffer[i*width+j]; + for (int j = 0; j < width; j++) { + Fresco::Color c; + c.red = buffer[i*width+j]; + c.green = c.red; c.blue = c.red; + } break; case FT_PIXEL_MODE_GRAY2: // 2bpp (no known fonts) std::cout << "FontKit NYI: FT_PIXEL_MODE_GRAY2" << std::endl; @@ -81,26 +93,30 @@ break; default: std::cout << "FontKit unknown type : " - << glyph_bitmap->bitmap.pixel_mode << std::endl; + << glyph_bitmap->bitmap.pixel_mode << std::endl; break; } FT_Set_Transform(my_face, 0, 0); FT_Done_Glyph(glyph); - activate(pixels); - raster->store_pixels(pixels); + Fresco::Raster::Index lower; lower.x = 0; lower.y = 0; + Fresco::Raster::Index upper; upper.x = width; upper.y = height; + raster->load_pixels(lower, upper, pixels); - return raster; + return Fresco::Raster_ptr(raster); } -FontShape *Glyph::decompose() +Fresco::FontShape *GlyphImpl::decompose() { - FT_Set_Transform(that->my_face, &my_tr, 0); + FT_Set_Transform(my_face, &my_tr, 0); + Fresco::FontShape *f = new Fresco::FontShape(); f->length(0); // use FT_Outline_Decompose - FT_Set_Transform(that->my_face, 0, 0); + FT_Set_Transform(my_face, 0, 0); + + return f; } -void Glyph::char_info(GlyphMetrics *gm) +void GlyphImpl::char_info(Fresco::GlyphMetrics &gm) { double scale = 1.; gm.size.x = static_cast<CORBA::Long>(my_face->glyph->metrics.width / scale); @@ -116,12 +132,12 @@ void *table = FT_Get_Sfnt_Table(my_face, ft_sfnt_hhea); if (table) { - TT_HoriHeader *header = *table; + TT_HoriHeader *header = (TT_HoriHeader*)table; gm.italic_correction = header->caret_Offset / 64.; // XXX MAYBE WRONG } } -void Glyph::transform(Fresco::Transform_var tr) +void GlyphImpl::transformation(Fresco::Transform_ptr tr) { Fresco::Vertex o = {0, 0, 0}; Fresco::Vertex e1 = {1, 0, 0}; Index: Glyph.hh =================================================================== RCS file: /cvs/fresco/Fresco/Berlin/modules/Fonts/Glyph.hh,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Glyph.hh 12 Jan 2003 02:54:09 -0000 1.2 +++ Glyph.hh 16 Feb 2003 03:47:47 -0000 1.3 @@ -19,31 +19,37 @@ * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, * MA 02139, USA. */ -#ifndef _Glyph_hh -#define _Glyph_hh +#ifndef _FontKit_Glyph_hh +#define _FontKit_Glyph_hh #include <Fresco/config.hh> #include <Fresco/Font.hh> #include <Fresco/Transform.hh> +#include <Berlin/RefCountBaseImpl.hh> +#include <Berlin/IdentifiableImpl.hh> #include <ft2build.h> #include FT_FREETYPE_H +#include FT_GLYPH_H +#include FT_TRUETYPE_TABLES_H -class Raster; - +class Fresco::Raster; -class Glyph : public virtual POA_Fresco::Glyph, - public virtual RefCountBaseImpl, - public virtual IdentifiableImpl +class GlyphImpl : public virtual POA_Fresco::Glyph, + public virtual RefCountBaseImpl, + public virtual IdentifiableImpl { public: - Raster_ptr bitmap(); - FontShape *decompose(); - void char_info(GlyphMetrics *gm); - void transformation(Fresco::Transform_var); + GlyphImpl(FT_Face face, FT_ULong char_index); + virtual ~GlyphImpl(); + + virtual Fresco::Raster_ptr bitmap(); + virtual Fresco::FontShape *decompose(); + virtual void char_info(Fresco::GlyphMetrics &gm); + virtual void transformation(Fresco::Transform_ptr); private: - FT_Face my_face; - FT_Matrix my_tr; + FT_Face my_face; + FT_Matrix my_tr; }; #endif // header guard