unsigned String0::LHashValue() const { int l = LLen(); if(l < 15) { dword w[4]; w[0] = w[1] = w[2] = w[3] = 0; memcpy(w, ptr, l); ((byte *)w)[SLEN] = l; return CombineHash(w[0], w[1], w[2], w[3]); } return memhash(ptr, l); }
bool Replace(Font fnt, int chr, Font& rfnt) { static Vector<int> rface; static Vector<dword> l, h; ONCELOCK { for(int i = 0; i < __countof(sFontReplacements) && rface.GetCount() < 20; i++) { int q = Font::FindFaceNameIndex(sFontReplacements[i].name); if(q > 0) { rface.Add(q); l.Add(sFontReplacements[i].l); h.Add(sFontReplacements[i].h); } } } Font f = fnt; // dword tl = chr < 4096 ? 0x80000000 >> (chr >> 7) : 0; // dword th = 0x80000000 >> ((dword)chr >> 11); for(int i = 0; i < rface.GetCount(); i++) { if(/*((l[i] & tl) || (h[i] & th)) && */IsNormal(f.Face(rface[i]), chr)) { int a = fnt.GetAscent(); int d = fnt.GetDescent(); if(f.GetAscent() > a || f.GetDescent() > d) { static sFontMetricsReplacement cache[256]; int q = CombineHash(fnt, f) & 255; if(cache[q].src != fnt || cache[q].dst != f) { cache[q].src = fnt; cache[q].dst = f; while((f.GetAscent() > a || f.GetDescent() > d) && f.GetHeight() > 1) { f.Height(max(1, min(f.GetHeight() - 1, f.GetHeight() * 9 / 10))); } cache[q].mdst = f; } else f = cache[q].mdst; } rfnt = f; return true; } } return false; }
unsigned GetHashValue() const { return CombineHash(name, surname); }
dword GetHashValue(const DocKey& k) { return CombineHash(GetHashValue(k.nameing), GetHashValue(k.nesting), GetHashValue(k.item)) << k.lang; }
unsigned GetHashValue() const { return CombineHash(fnt, chr, tolerance); }
unsigned GetHashValue() const { return CombineHash(lang, wrd); }
GlyphInfo GetGlyphInfoSys(Font font, int chr) { static Font fnt[GLYPHINFOCACHE]; static int pg[GLYPHINFOCACHE]; static GlyphInfo li[GLYPHINFOCACHE][256]; ONCELOCK { for(int i = 0; i < GLYPHINFOCACHE; i++) pg[i] = -1; } int page = chr >> 8; int q = CombineHash(font, page) % GLYPHINFOCACHE; if(fnt[q] != font || pg[q] != page) { fnt[q] = font; pg[q] = page; HFONT hfont = GetWin32Font(font, 0); if(!hfont) { GlyphInfo n; memset(&n, 0, sizeof(GlyphInfo)); return n; } HDC hdc = Win32_IC(); HFONT ohfont = (HFONT) ::SelectObject(hdc, hfont); int from = page << 8; GlyphInfo *t = li[q]; /* if(page >= 32) { wchar h[3]; h[0] = 'x'; h[1] = 'x'; h[2] = 'x'; int w0 = sGetCW(hdc, h, 2); for(int i = 0; i < 256; i++) { h[1] = from + i; t[i].width = sGetCW(hdc, h, 3) - w0; t[i].lspc = t[i].rspc = 0; } } else */{ bool abca = false, abcw = false; Buffer<ABC> abc(256); abcw = ::GetCharABCWidthsW(hdc, from, from + 256 - 1, abc); #ifndef PLATFORM_WINCE if(!abcw) abca = ::GetCharABCWidthsA(hdc, from, from + 256 - 1, abc); #endif if(abcw) { for(ABC *s = abc, *lim = abc + 256; s < lim; s++, t++) { t->width = s->abcA + s->abcB + s->abcC; t->lspc = s->abcA; t->rspc = s->abcC; } } else { Buffer<int> wb(256); #ifdef PLATFORM_WINCE ::GetCharWidth32(hdc, from, from + 256 - 1, wb); #else ::GetCharWidthW(hdc, from, from + 256 - 1, wb); #endif for(int *s = wb, *lim = wb + 256; s < lim; s++, t++) { t->width = *s - GetFontInfoSys(font).overhang; if(abca) { ABC aa = abc[(byte)ToAscii(from++)]; t->lspc = aa.abcA; t->rspc = aa.abcC; } else t->lspc = t->rspc = 0; } } } #ifndef PLATFORM_WINCE WORD pos[256]; WCHAR wch[256]; for(int i = 0; i < 256; i++) wch[i] = from + i; Win32_GetGlyphIndices(hdc, wch, 256, pos, 1); for(int i = 0; i < 256; i++) if(pos[i] == 0xffff) { li[q][i].width = (int16)0x8000; li[q][i].lspc = li[q][i].rspc = 0; } #endif ::SelectObject(hdc, ohfont); } return li[q][chr & 255]; }
unsigned GetHashValue() const { return CombineHash(fnt, chr); }