FontInstance.cpp revision 12214b32eca96826d1f77672779417d6a206836b
/*
* testICU
*
* Authors:
* fred
* bulia byak <buliabyak@users.sf.net>
*
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <libnrtype/font-glyph.h>
#include <libnrtype/font-instance.h>
/* #include <layout/LEGlyphStorage.h> */
#include "RasterFont.h"
/* Freetype 2 */
# include <pango/pangoft2.h>
int h=0,n;
for (int i=0;i<6;i++) {
h*=12186;
h+=n;
}
h*=12186;
h+=n;
n=(x.vertical)?1:0;
h*=12186;
h+=n;
if ( x.stroke_width >= 0.01 ) {
h*=12186;
h+=n;
if ( x.nbDash > 0 ) {
n=x.nbDash;
h*=12186;
h+=n;
h*=12186;
h+=n;
for (int i=0;i<x.nbDash;i++) {
h*=12186;
h+=n;
}
}
}
return h;
}
} else {
return false;
}
} else {
return false;
}
if ( a.stroke_cap != b.stroke_cap ) return false;
if ( a.stroke_join != b.stroke_join ) return false;
if ( a.nbDash <= 0 ) return true;
for (int i=0;i<a.nbDash;i++) {
}
} else {
return false;
}
return true;
}
#ifndef USE_PANGO_WIN32
/*
* Outline extraction
*/
typedef struct ft2_to_liv {
double scale;
} ft2_to_liv;
// outline as returned by freetype -> livarot Path
// see nr-type-ft2.cpp for the freetype -> artBPath on which this code is based
// printf("m t=%f %f\n",p[0],p[1]);
return 0;
}
{
// printf("l t=%f %f\n",p[0],p[1]);
return 0;
}
{
// printf("b c=%f %f t=%f %f\n",c[0],c[1],p[0],p[1]);
return 0;
}
{
// printf("c c1=%f %f c2=%f %f t=%f %f\n",c1[0],c1[1],c2[0],c2[1],p[0],p[1]);
return 0;
}
#endif
/*
*
*/
font_instance::font_instance(void)
{
//printf("font instance born\n");
refCount=0;
}
font_instance::~font_instance(void)
{
//printf("font instance death\n");
// if ( theFace ) FT_Done_Face(theFace); // owned by pFont. don't touch
for (int i=0;i<nbGlyph;i++) {
}
}
void font_instance::Ref(void)
{
refCount++;
//char *tc=pango_font_description_to_string(descr);
//printf("font %x %s ref'd %i\n",this,tc,refCount);
//free(tc);
}
void font_instance::Unref(void)
{
refCount--;
//char *tc=pango_font_description_to_string(descr);
//printf("font %x %s unref'd %i\n",this,tc,refCount);
//free(tc);
if ( refCount <= 0 ) {
delete this;
}
}
{
}
{
}
{
}
{
return 0;
}
bool free_res=false;
free_res=true;
#ifndef USE_PANGO_WIN32
#endif
free_res=false;
bool i = (style == PANGO_STYLE_ITALIC);
bool o = (style == PANGO_STYLE_OBLIQUE);
bool b = (weight >= PANGO_WEIGHT_BOLD);
(b || i || o) ? "-" : "",
(b) ? "Bold" : "",
(i) ? "Italic" : ((o) ? "Oblique" : "") );
free_res = true;
}
free_res=false;
if ( v == PANGO_STYLE_ITALIC ) {
res="italic";
} else if ( v == PANGO_STYLE_OBLIQUE ) {
res="oblique";
} else {
res="normal";
}
free_res=false;
if ( v <= PANGO_WEIGHT_ULTRALIGHT ) {
res="200";
} else if ( v <= PANGO_WEIGHT_LIGHT ) {
res="300";
} else if ( v <= PANGO_WEIGHT_NORMAL ) {
res="normal";
} else if ( v <= PANGO_WEIGHT_BOLD ) {
res="bold";
} else {
res="800";
}
free_res=false;
if ( v <= PANGO_STRETCH_EXTRA_CONDENSED ) {
res="extra-condensed";
} else if ( v <= PANGO_STRETCH_CONDENSED ) {
res="condensed";
} else if ( v <= PANGO_STRETCH_SEMI_CONDENSED ) {
res="semi-condensed";
} else if ( v <= PANGO_STRETCH_NORMAL ) {
res="normal";
} else if ( v <= PANGO_STRETCH_SEMI_EXPANDED ) {
res="semi-expanded";
} else if ( v <= PANGO_STRETCH_EXPANDED ) {
res="expanded";
} else {
res="extra-expanded";
}
free_res=false;
if ( v == PANGO_VARIANT_SMALL_CAPS ) {
res="small-caps";
} else {
res="normal";
}
free_res=false;
} else {
free_res=false;
}
return 0;
}
if (res) {
if ( str ) {
}
return len;
}
return 0;
}
void font_instance::InitTheFace()
{
#ifdef USE_PANGO_WIN32
if ( !theFace ) {
}
#else
if ( theFace )
#endif
}
void font_instance::FreeTheFace()
{
#ifdef USE_PANGO_WIN32
#endif
}
{
if ( !iFace )
return;
InitTheFace();
if ( pFont && IsOutlineFont() == false ) {
FreeTheFace();
}
}
bool font_instance::IsOutlineFont(void)
{
InitTheFace();
#ifdef USE_PANGO_WIN32
#else
return FT_IS_SCALABLE(theFace);
#endif
}
{
#ifdef USE_PANGO_WIN32
return pango_win32_font_get_glyph_index(pFont,c);
#else
int res=0;
if ( c > 0xf0000 ) {
} else {
}
return res;
#endif
}
#ifdef USE_PANGO_WIN32
{
*(long*)&p.y / 65536.0 * scale);
}
#endif
{
InitTheFace();
#ifndef USE_PANGO_WIN32
#endif
}
bool doAdd=false;
#ifdef USE_PANGO_WIN32
DWORD bufferSize=GetGlyphOutline (daddy->hScreenDC, glyph_id, GGO_GLYPH_INDEX | GGO_NATIVE | GGO_UNHINTED, &metrics, 0, NULL, &identity);
if ( bufferSize == GDI_ERROR) {
// shit happened
} else if ( bufferSize == 0) {
// character has no visual representation, but is valid (eg whitespace)
doAdd=true;
} else {
if ( GetGlyphOutline (daddy->hScreenDC, glyph_id, GGO_GLYPH_INDEX | GGO_NATIVE | GGO_UNHINTED, &metrics, bufferSize, buffer.get(), &identity) <= 0 ) {
// shit happened
} else {
// Platform SDK is rubbish, read KB87115 instead
DWORD polyOffset=0;
while ( polyOffset < bufferSize ) {
case TT_PRIM_LINE:
while ( p != endp )
break;
case TT_PRIM_QSPLINE:
{
endp -= 2;
while ( p != endp ) {
++p;
}
break;
}
case 3: // TT_PRIM_CSPLINE
while ( p != endp ) {
n_g.outline->CubicTo(pointfx_to_nrpoint(p[2], scale), pointfx_to_nrpoint(p[0], scale), pointfx_to_nrpoint(p[1], scale));
p += 3;
}
break;
}
}
}
}
doAdd=true;
}
}
#else
// shit happened
} else {
if ( FT_HAS_HORIZONTAL(theFace) ) {
} else {
n_g.h_width=n_g.h_advance=((double)(theFace->bbox.xMax-theFace->bbox.xMin))/((double)theFace->units_per_EM);
}
if ( FT_HAS_VERTICAL(theFace) ) {
} else {
}
0, 0
};
}
doAdd=true;
}
#endif
if ( doAdd ) {
}
nbGlyph++;
}
} else {
}
}
{
InitTheFace();
#ifdef USE_PANGO_WIN32
#else
#endif
return true;
}
{
run = 0.0;
rise = 1.0;
InitTheFace();
#ifdef USE_PANGO_WIN32
#else
#endif
return true;
}
{
int no=-1;
// didn't load
} else {
}
} else {
}
return res;
}
{
int no=-1;
// didn't load
} else {
}
} else {
}
if ( copyInto ) {
return copyInto;
}
return src_o;
}
{
int no=-1;
// didn't load
} else {
}
} else {
}
}
{
int no=-1;
// didn't load
} else {
}
} else {
}
if ( no >= 0 ) {
if ( vertical ) {
} else {
}
}
return 0;
}
raster_font* font_instance::RasterFont(const NR::Matrix &trs,double stroke_width,bool vertical,JoinType stroke_join,ButtType stroke_cap,float miter_limit)
{
return RasterFont(nStyle);
}
{
// for some evil reason font_style doesn't have a copy ctor, so the
// stuff that should be done there is done here instead (because the
// raster_font ctor copies nStyle).
}
} else {
}
return res;
}
{
//g_print("RemoveRasterFont failed \n");
// not found
} else {
//g_print("RemoveRasterFont\n");
Unref();
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :