Fresco/Berlin/modules/Fonts FontKitImpl.cc,1.7,1.8 Glyph.cc,1.5,1.6
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-serv31577
Modified Files:
FontKitImpl.cc Glyph.cc
Log Message:
Update for bug188 compliance.
Updated to fit new empty Raster semantics.
Index: FontKitImpl.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Fonts/FontKitImpl.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- FontKitImpl.cc 18 Feb 2003 15:06:48 -0000 1.7
+++ FontKitImpl.cc 20 Feb 2003 02:38:20 -0000 1.8
@@ -84,8 +84,19 @@
FontKitImpl::FontIterator::FontIterator(FontKitImpl *fk)
: my_fk(fk)
{
- Prague::Path path = RCManager::get_path("fontpath");
+ Prague::Path path = RCManager::get_path("unifontpath");
+ std::string file = path.lookup_file("unifont.bdf");
+ FT_Face my_face;
+ if (FT_New_Face(*(my_fk->get_ftlibrary()), file.c_str(), 0, &my_face) == 0)
+ faces.push_back(file);
+ if (!faces.size())
+ Logger::log(Logger::text) << "unifont.bdf not found. This may result in poor unicode rendering!" << std::endl;
+
+ path = RCManager::get_path("fontpath");
scan(path);
+ Logger::log(Logger::text) << faces.size() << " fonts found" << std::endl;
+ if (!faces.size())
+ throw std::runtime_error("no fonts found. Please check your font path !");
}
FontKitImpl::FontIterator::~FontIterator() {}
@@ -112,7 +123,7 @@
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;
+ Logger::log(Logger::text) << "file " << file << " is not a font." << std::endl;
continue;
}
faces.push_back(file);
@@ -155,6 +166,8 @@
{
return _cxx_default(); // XXX
}
+
+// pantone 1 and 2 font matching functions belong here.
Fresco::Graphic_ptr FontKitImpl::set_font(Fresco::Graphic_ptr g, Font_ptr f)
{
Index: Glyph.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Fonts/Glyph.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Glyph.cc 17 Feb 2003 02:10:33 -0000 1.5
+++ Glyph.cc 20 Feb 2003 02:38:20 -0000 1.6
@@ -42,22 +42,19 @@
Fresco::Raster_ptr GlyphImpl::bitmap(short unsigned int xdpi, short unsigned int ydpi)
{
- RasterImpl *raster = new RasterImpl();
- activate(raster);
-
if (FT_Set_Char_Size(my_face, 0, my_size*64, xdpi, ydpi) != 0)
- std::cerr << "set char size failed." << std::endl;
+ std::cerr << "FontKit bitmap: set char size failed." << std::endl;
FT_Set_Transform(my_face, &my_tr, 0);
if (FT_Load_Glyph(my_face, FT_Get_Char_Index(my_face, my_uc),
FT_LOAD_DEFAULT) != 0)
- std::cerr << "load glyph failed." << std::endl;
+ std::cerr << "FontKit bitmap: load glyph failed." << std::endl;
FT_Glyph glyph;
if (FT_Get_Glyph(my_face->glyph, &glyph) != 0)
- std::cerr << "get glyph failed." << std::endl;
+ std::cerr << "FontKit bitmap: get glyph failed." << std::endl;
if (FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, 0, 1) != 0)
- std::cerr << "glyph to bitmap failed." << std::endl;
+ std::cerr << "FontKit bitmap: glyph to bitmap failed." << std::endl;
FT_BitmapGlyph glyph_bitmap = (FT_BitmapGlyph)glyph;
unsigned char *buffer = glyph_bitmap->bitmap.buffer;
@@ -111,6 +108,15 @@
FT_Done_Glyph(glyph);
FT_Set_Transform(my_face, 0, 0);
+ // XXX we should be using the RasterKit.
+ Fresco::Raster::Info rinfo;
+ rinfo.colortype = 6; // PNG_COLOR_TYPE_RGB_ALPHA (sigh).
+ rinfo.depth = 8;
+ rinfo.width = width;
+ rinfo.height = height;
+ RasterImpl *raster = new RasterImpl(rinfo);
+ activate(raster);
+
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);
@@ -123,8 +129,8 @@
FT_Set_Char_Size(my_face, 0, my_size*64, 0, 0);
FT_Set_Transform(my_face, &my_tr, 0);
if (FT_Load_Glyph(my_face, FT_Get_Char_Index(my_face, my_uc),
- FT_LOAD_DEFAULT & FT_LOAD_IGNORE_TRANSFORM) != 0)
- std::cerr << "load glyph failed." << std::endl;
+ FT_LOAD_DEFAULT) != 0)
+ std::cerr << "FontKit decompose: load glyph failed." << std::endl;
Fresco::FontShape *f = new Fresco::FontShape(); f->length(0);
// use FT_Outline_Decompose
FT_Set_Transform(my_face, 0, 0);