From b981142137d9ca1d8356be0d019a10d5d0e4a270 Mon Sep 17 00:00:00 2001 From: cyreve Date: Wed, 3 May 2006 23:30:58 +0000 Subject: [PATCH] bug 1466130: operator== for font_style was not transitive, making hash_map get very confused and cause crashes --- src/libnrtype/FontInstance.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 01d008181..b63d5dfe6 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -33,11 +33,6 @@ size_t font_style_hash::operator()(const font_style &x) const { int h=0,n; - for (int i=0;i<6;i++) { - n=(int)floor(100*x.transform[i]); - h*=12186; - h+=n; - } n=(int)floor(100*x.stroke_width); h*=12186; h+=n; @@ -66,16 +61,9 @@ size_t font_style_hash::operator()(const font_style &x) const { } bool font_style_equal::operator()(const font_style &a,const font_style &b) { - NR::Matrix diff=a.transform.inverse(); - diff*=b.transform; - if ( diff.is_translation(0.01) ) { - if ( fabs(diff[4]) < 0.01 && fabs(diff[5]) < 0.01 ) { - } else { - return false; - } - } else { - return false; - } + for (int i=0;i<6;i++) { + if ( (int)(100*a.transform[i]) != (int)(100*b.transform[i]) ) return false; + } if ( a.vertical && b.vertical == false ) return false; if ( a.vertical == false && b.vertical ) return false; if ( a.stroke_width > 0.01 && b.stroke_width <= 0.01 ) return false; @@ -84,15 +72,12 @@ bool font_style_equal::operator()(const font_style &a,const font_style &b) { if ( a.stroke_cap != b.stroke_cap ) return false; if ( a.stroke_join != b.stroke_join ) return false; - if ( fabs(a.stroke_miter_limit-b.stroke_miter_limit) > 0.01) return false; + if ( (int)(a.stroke_miter_limit*100) != (int)(b.stroke_miter_limit*100) ) return false; if ( a.nbDash != b.nbDash ) return false; if ( a.nbDash <= 0 ) return true; - if ( fabs(a.dash_offset-b.dash_offset) < 0.01 ) { - for (int i=0;i= 0.01 ) return false; - } - } else { - return false; + if ( (int)floor(100*a.dash_offset) != (int)floor(100*b.dash_offset) ) return false; + for (int i=0;i