~ubuntu-branches/debian/squeeze/inkscape/squeeze

« back to all changes in this revision

Viewing changes to src/libnrtype/FontInstance.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
        if ( a.stroke_width > 0.01 && b.stroke_width <= 0.01 ) return false;
68
68
        if ( a.stroke_width <= 0.01 && b.stroke_width > 0.01 ) return false;
69
69
        if ( a.stroke_width <= 0.01 && b.stroke_width <= 0.01 ) return true;
70
 
        
 
70
 
71
71
        if ( a.stroke_cap != b.stroke_cap ) return false;
72
72
        if ( a.stroke_join != b.stroke_join ) return false;
73
73
    if ( (int)(a.stroke_miter_limit*100) != (int)(b.stroke_miter_limit*100) ) return false;
125
125
static int ft2_conic_to(FREETYPE_VECTOR *control, FREETYPE_VECTOR *to, void *i_user)
126
126
{
127
127
        ft2_to_liv* user=(ft2_to_liv*)i_user;
128
 
        NR::Point   p(user->scale*to->x,user->scale*to->y),c(user->scale*control->x,user->scale*control->y);  
 
128
        NR::Point   p(user->scale*to->x,user->scale*to->y),c(user->scale*control->x,user->scale*control->y);
129
129
        //      printf("b c=%f %f  t=%f %f\n",c[0],c[1],p[0],p[1]);
130
130
        user->theP->BezierTo(p);
131
131
        user->theP->IntermBezierTo(c);
139
139
        ft2_to_liv* user=(ft2_to_liv*)i_user;
140
140
        NR::Point   p(user->scale*to->x,user->scale*to->y),
141
141
        c1(user->scale*control1->x,user->scale*control1->y),
142
 
        c2(user->scale*control2->x,user->scale*control2->y);  
 
142
        c2(user->scale*control2->x,user->scale*control2->y);
143
143
        //      printf("c c1=%f %f  c2=%f %f   t=%f %f\n",c1[0],c1[1],c2[0],c2[1],p[0],p[1]);
144
 
        user->theP->CubicTo(p,3*(c1-user->last),3*(p-c2)); 
 
144
        user->theP->CubicTo(p,3*(c1-user->last),3*(p-c2));
145
145
        user->last=p;
146
146
        return 0;
147
147
}
229
229
        }
230
230
        char*   res=NULL;
231
231
        bool    free_res=false;
232
 
        
 
232
 
233
233
        if ( strcmp(key,"name") == 0 ) {
234
234
                PangoFontDescription* td=pango_font_description_copy(descr);
235
235
                pango_font_description_unset_fields (td, PANGO_FONT_MASK_SIZE);
247
247
             bool o = (style == PANGO_STYLE_OBLIQUE);
248
248
             PangoWeight weight=pango_font_description_get_weight(descr);
249
249
             bool b = (weight >= PANGO_WEIGHT_BOLD);
250
 
   
251
 
             res = g_strdup_printf ("%s%s%s%s", 
252
 
                                    pango_font_description_get_family(descr), 
253
 
                                    (b || i || o) ? "-" : "", 
254
 
                                    (b) ? "Bold" : "", 
 
250
 
 
251
             res = g_strdup_printf ("%s%s%s%s",
 
252
                                    pango_font_description_get_family(descr),
 
253
                                    (b || i || o) ? "-" : "",
 
254
                                    (b) ? "Bold" : "",
255
255
                                    (i) ? "Italic" : ((o) ? "Oblique" : "")  );
256
256
             free_res = true;
257
257
         }
278
278
                        res="normal";
279
279
                } else if ( v <= PANGO_WEIGHT_BOLD ) {
280
280
                        res="bold";
281
 
                } else {
282
 
                        res="800";
 
281
                } else if ( v <= PANGO_WEIGHT_ULTRABOLD ) {
 
282
                    res="800";
 
283
                } else { // HEAVY
 
284
                        res="900";
283
285
                }
284
286
                free_res=false;
285
287
        } else if ( strcmp(key,"stretch") == 0 ) {
316
318
                if ( size > 0 ) str[0]=0;
317
319
                return 0;
318
320
        }
319
 
        
 
321
 
320
322
        if (res) {
321
323
                unsigned int len=strlen(res);
322
324
                unsigned int rlen=(size-1<len)?size-1:len;
432
434
                bool   doAdd=false;
433
435
 
434
436
#ifdef USE_PANGO_WIN32
 
437
 
 
438
#ifndef GGO_UNHINTED         // For compatibility with old SDKs.
 
439
#define GGO_UNHINTED 0x0100
 
440
#endif
 
441
 
435
442
        MAT2 identity = {{0,1},{0,0},{0,0},{0,1}};
436
443
        OUTLINETEXTMETRIC otm;
437
444
        GetOutlineTextMetrics(daddy->hScreenDC, sizeof(otm), &otm);
597
604
    rise=otm.otmsCharSlopeRise;
598
605
#else
599
606
        if ( !FT_IS_SCALABLE(theFace) ) return false; // bitmap font
600
 
        
 
607
 
601
608
    TT_HoriHeader *hhea = (TT_HoriHeader*)FT_Get_Sfnt_Table(theFace, ft_sfnt_hhea);
602
609
    if (hhea == NULL) return false;
603
610
    run = hhea->caret_Slope_Run;
606
613
        return true;
607
614
}
608
615
 
609
 
NR::Rect font_instance::BBox(int glyph_id)
 
616
NR::Maybe<NR::Rect> font_instance::BBox(int glyph_id)
610
617
{
611
618
        int no=-1;
612
619
        if ( id_to_no.find(glyph_id) == id_to_no.end() ) {
619
626
        } else {
620
627
                no=id_to_no[glyph_id];
621
628
        }
622
 
        if ( no < 0 ) return NR::Rect(NR::Point(0,0),NR::Point(0,0));
623
 
        NR::Point rmin(glyphs[no].bbox[0],glyphs[no].bbox[1]);
624
 
        NR::Point rmax(glyphs[no].bbox[2],glyphs[no].bbox[3]);
625
 
        NR::Rect  res(rmin,rmax);
626
 
        return res;
 
629
        if ( no < 0 ) {
 
630
            return NR::Nothing();
 
631
        } else {
 
632
            NR::Point rmin(glyphs[no].bbox[0],glyphs[no].bbox[1]);
 
633
            NR::Point rmax(glyphs[no].bbox[2],glyphs[no].bbox[3]);
 
634
            return NR::Rect(rmin, rmax);
 
635
        }
627
636
}
628
637
 
629
638
Path* font_instance::Outline(int glyph_id,Path* copyInto)
687
696
                }
688
697
        }
689
698
        return 0;
690
 
}       
691
 
 
692
 
 
693
 
raster_font* font_instance::RasterFont(const NR::Matrix &trs,double stroke_width,bool vertical,JoinType stroke_join,ButtType stroke_cap,float miter_limit)
 
699
}
 
700
 
 
701
 
 
702
raster_font* font_instance::RasterFont(const NR::Matrix &trs, double stroke_width, bool vertical, JoinType stroke_join, ButtType stroke_cap, float /*miter_limit*/)
694
703
{
695
704
        font_style  nStyle;
696
705
        nStyle.transform=trs;